"Hosted HWND must be a child window of the specified parent."

Pino Carafa 121 Reputation points
2021-02-11T18:35:38.597+00:00

Update: the colleague mentioned below was looking at the wrong machine. See also conversation with @Sam of Simple Samples - I would still be interested in knowing why this setting might be missing on some machines, but there is a lot less of an urgency about this now.

Hello there......

We have created an Outlook Add-in that we've used without problems for years. One of the things this Add-in does is show dialogs from which users can select files to either attach to an email they're composing or files attached to an incoming email they're processing with our Add-in.

As an added feature we allow the user to view the document.

Traditionally we have always used a WebBrowser control for this. The dialogs are WPF windows. We would convert each document to a HTML representation of same and then show that HTML document in the WebBrowser control.

Lately we have started getting occasional reports from users that this Preview is no longer working. The users are also reporting the appearance of "phantom" dialogs when hovering over the Outlook thumbnail in their task bar when this preview fails
67112-image1.jpg

The good news is that this can be addressed quite simply by setting an outlook setting. Go to File - Options and on the General tab there is a section "User Interface Options" and if you choose "Optimize for compatibility" there the problem goes away.
67141-image2.jpg

Great, right?

Until I asked my colleague who had the problem to do this. On his machine the options simply weren't there. I also looked at his registry, and while in my own registry the value RenderForMonitorDpi was present in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Options, in his registry that value was completely missing.

What's going on here and what could I do about it?

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,687 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sam of Simple Samples 5,521 Reputation points
    2021-02-11T20:15:56.713+00:00

    "Optimize for compatibility" strongly implies there is a compatibility problem. You need to determine what old library is causing that and then modernize what you use. Nearly certainly it is the WebBrowser control. It has been more than two years since I have done that type of thing but apparently you need to convert to the WebView2 Class (WebView2 control).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful