Capture IWebBrowser image (call IViewObject::Draw from a different thread)



Hi,

I'm trying to integrate IE in my application. So far it runs well in a
single thread, but I need to call IViewObject::Draw method from
different thread than the one that's creating the IWebBrowser.

Here's my pseudo code to initialize the browser into a hidden window:

void Web_GoTo(WCHAR *pURL)
{
AtlAxWinInit();
RECT rc={0,0,100, 100);
hWBWindow = CreateWindowEx(0, L"AtlAxWin80", 0, WS_POPUP, rc.left,
rc.top, rc.right - rc.left, rc.bottom - rc.top, 0, 0, 0, 0);

hr = CoCreateInstance(CLSID_WebBrowser, 0, CLSCTX_ALL,
IID_IWebBrowser2, (void**)&ibrowser);
hr = AtlAxAttachControl(ibrowser, ctrl, 0);
hr = ibrowser->QueryInterface(__uuidof(IVewObject), (void**)
&viewobject);
....
ibrowser->Navigate(pURL, NULL, NULL, NULL, NULL);
}

When I call the IViewObject->Draw in a different thread (than the one
that has created the AtlAxWin window I get an exception 0xC0000005:
Access violation reading location 0x000000e0. The same code works if I
use this method inside the same thread I created the browser object.

Anyone knows what's going on ?

PS: I've called CoInitializeEx(NULL, COINIT_MULTITHREADED) in the
beginning of the creating thread.
.


Loading