Hackerdude

Hello, I have a toolbar in C++ that has pointers to the underlying IWebBrowser2. I am keeping things such as the Current URL on the browser as a std:Tongue Tiedtring and other diagnostic information in it. I also have an URL monitor introspector. On the BeginningTransaction, I do something like:


CComPtr<IWindowForBindingUI> objWindowForBindingUI;
HRESULT hret = QueryServiceFromClient(&objWindowForBindingUI);
if( (SUCCEEDED(hret)) && (objWindowForBindingUI) )
{
HWND hwndIEServer = NULL;
//Should return InternetExplorerServer HWND
objWindowForBindingUI->GetWindow(IID_IHttpSecurity, &hwndIEServer);
if(hwndIEServer)
{
HRESULT hresult = 0;
// Now this is the top-level window for IE. Get the document, then the iWebBrowser2, then
// Find the tabs and.. TODO: This will STILL have problems with tabs - need to get the appropriate tab
CMyAppWnd window = CMyUrlMon::RetrieveToolbarInstance(&hwndIEServer);
controllingWindow = &window;
}
}


I also have a map keeping my toolbar instances, something like this:

static map<HWND, CMyAppWnd> toolbarInstanceMap;

The toolbars register themselves here, then RetrieveToolbarInstance searches for them. This is so I can get to the current URL and extra diagnostic info I have on the toolbar.

There's two problems with this:

1) The controllingWindow is actually the main IE window, not the tab. I am able to get to the tab window on the toolbar itself.
2) When trying to call the functions in CMyAppWnd from within the context of URL monitoring, all calls throw illegal access exceptions. I probably need to marshal them but I'm not sure how to do that - even if I send buffers to be filled I still get illegal access.
3) Maybe there's a better way of doing this but I can't find one.

I'd appreciate any help you can provide with this.


Thanks!