2

The title says it all really...

I'm using IWebBrowser2 to display web pages in my application, however, when I call IWebBrowser2::Navigate() a white background is displayed whilst the target page is loading, which conflicts with the colour scheme of my app.

I tried creating a "background.html" and pre-loading that before calling Navigate(), but as soon as I navigate to the new URL, the background changes to white.

j b
  • 5,147
  • 5
  • 41
  • 60

1 Answers1

1

This is untested:

  1. Hide the browser window. As I remember calling ShowWindow(SW_HIDE) would not work because the browser control doesn't do anything when its window is hidden. Instead you could MoveWindow() it outside of the client area to effectively hide it while it still thinks it is visible.
  2. Draw your custom background in the parent window of the browser control.
  3. Call IWebBrowser2::Navigate()
  4. Handle the NavigateComplete event where you show the browser window again. It should quickly redraw itself without first showing white background.
zett42
  • 25,437
  • 3
  • 35
  • 72
  • Thanks! Actually `ShowWindow(SW_HIDE)` does seem to work for me, so I'll use that. – j b Jun 06 '17 at 11:57
  • @JamieBullock: On which window have you invoked ShowWindow(SW_HIDE)? Were you using CHtmlView? – Hemant Jun 27 '18 at 10:33