.netwinformsoutlookpaintsetparent

Outlook: How to SetParent(_form.Handle, Outlook.Handle) without Paint issues?


I would like to set the top level window handle of Outlook to be the parent of a Settings form in my add-in (so it appears on top, stays in Outlook, etc).

Using SetParent in other Office apps works fine, but in Outlook I get rendering errors. The form doesn't repaint correctly when Outlook is the parent (so if I drag it around or click out and back, other parts of Outlook are drawn on top of it).

Any Invalidate-ing I do is ignored.

Anybody know a good solution? Thanks!

EDIT: The form I want to add is a .Net form, which might be part of the problem.


Solution

  • I still haven't figured out a way to make this work as a form, but one work-around that works is to open the Form as a dialog (modal).

    That is .ShowDialog()

    I'll mark this as accepted if I don't get a better answer.