0

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.

Jason Evans
  • 28,906
  • 14
  • 90
  • 154
cHiWa
  • 383
  • 1
  • 3
  • 14

2 Answers2

1

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).

  • Thank you for reply. I have tried OLEIVERB_HIDE, there will be no window shown. But I dont get pixels by calling IViewObjec::Draw() – cHiWa Jan 29 '13 at 10:06
  • Yes, I tried that code from beginning, it has other problems. 1. It uses MFC. 2. The result does not show any flash or and 3. microsoft said that the function is deprecated. 4. I tried to use ATL template class to show put IWebBrowser control, and when I create the window, my own main window suddenly become inactive. – cHiWa Jan 29 '13 at 11:40
0

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;    
}
cHiWa
  • 383
  • 1
  • 3
  • 14