How to get IHTMLDocument object to load an image?

24 Views Asked by At

I am using mshtml.h and mshtml.dll in a Visual Studio C++ based application. I show tooltips using the Microsoft Web Browser control. When I do this, I calculate a width and height using IHTMLTextContainer::get_scrollHeight() as to avoid scroll bars. I have an issue where I don't get scroll bars but the height of my window is not correct, leading to clipping of the data I am showing.

This only happens on a scaled desktop. I have found that if I don't replace an image I have at the top of my web page that I am loading and modifying, the size of the window I calculate is fine. I have a placeholder for my image, which is a bitmap that is 32 pixels high. I replace that image using IHTMLImgElement::put_source(). The web browser is zoomed calling Exec() with OLECMDID_OPTICAL_ZOOM and the desktop DPI. I also call IHTMLDocument3::recalc() with VARIANT_TRUE.

For debugging, both before and after the call to put the image source, and after making that call and doing a recalc(), I have added a call to IHtmlElement1::get_scrollHeight(). Both calls return 32 (my placeholder image height). I am trying to force the web browser to recalculate the document so that it loads the actual image I am showing, so that when I get the entire scroll height, I get back a valid value. Apparently this image loading only happens when the window/page is rendered.

Does anyone know how I might get my image to load so the size I calculate is correct?

0

There are 0 best solutions below