Question

I have a Win32 application which converts HTML into an image without displaying the control. (I dont have much experience to use ActiveX in a Win32 application).

I followed this MSDN article to create the control and call Navigate(): http://msdn.microsoft.com/en-us/library/aa451946.aspx

When I need to convert the image, I call IViewObjec::Draw(). The problem is the control is always visible even if I call the following function:

browser->put_Visible(VARIANT_FALSE); // browser is IWebBrowser2

When I stepped into the code I found out that when I call

mOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, mControlSite, 0, NULL, NULL)

the control becomes visible immediately. But from what I can see from MSDN is that OLEIVERB_INPLACEACTIVATE means

Activates an object in place without displaying tools, such as menus and toolbars, that end users need to change the behavior or appearance of the object. Single-clicking such an object causes it to negotiate the display of its user-interface tools with its container. If the container refuses, the object remains active but without its tools displayed.

I am a bit confused, I only want to hide it.

Was it helpful?

Solution 2

I found another solution.

I just make normal window and put the html control into the windown and hide it, which solves all the problems that I mentioned above.

In the ControlSite I implemented IOleWindow::GetWindow() to put control like following code (mWindow is just my Basic window class), just return this normal window's handle.

HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR* theWindow)
{   
    *theWindow = mWindow.GetHandle();
    return S_OK;    
}

OTHER TIPS

Try calling DoVerb() for the instance of IOleObject type (in your case, mOleObject) and pass OLEIVERB_HIDE as verb.

Update:

The IHTMLElementRender interface would be better to solve the problem (see Capture an HTML document as an image).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top