We have a VSTO plugin, and we are required to black out the email window of open mails. If it has to be done via SetWindowDisplayAffinity, how do we get the right handle to SetWindowDisplayAffinity via a VSTO plugin?
We did attempt to SetWindowDisplayAffinity via the handle we got via the process but it had no effect
2
Answers
Cast the
Inspector
Outlook object to the IOleWindow interface (also works with theExplorer
objects too) and callIOleWindow::GetWindow
to get itsHWND
.You can retrieve the window handle that can be used for the function by casting the Outlook window instance like Explorer or Inspector to the
IOLEWindow
interface and using the IOleWindow::GetWindow method which retrieves a handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).Here is the sample code which shows how to use the IOLEWindow interface with Outlook windows: