Search code examples
themesinternet-explorer-9embedding

No theming on buttons when embedding IE9


I'm using the IWebBrowser2 interface to IE9 in a standard Win32 app. Pages with controls like buttons are rendered without theming, so look like something from the Windows 2000 era. The identical page displays correctly using the stand-alone IE9. All pages have

<meta http-equiv="X-UA-Compatible" content="IE=9"/>

in the header

Any thoughts?

Unthemed button snap


Solution

  • You must implement IDocHostUIHandler, then in the method GetHostInfo append the DOCHOSTUIFLAG_THEME to the dwFlags:

    STDMETHODIMP GetHostInfo(DOCHOSTUIINFO *pInfo)
    {
        pInfo->cbSize = sizeof(DOCHOSTUIINFO);
        pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER|DOCHOSTUIFLAG_DIALOG|DOCHOSTUIFLAG_THEME;
        pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
        return S_OK;
    }