Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IOleClientSite->GetContainer fails with E_UNEXPECTED

Status
Not open for further replies.

rossk14

Programmer
Feb 23, 2005
1
US
Hi all,

I am trying to develop an Active X control that fires off a thread that processes some information and invokes a callback function in the control that calls a Javascript function.

My member function ReturnReading is called by the thread and then calls a function to invoke the Javascript function. This currently fails. When i call the ReturnReading function from within the control itself it works. I'm posting some code below. Any help would be much appreciated.

Code:
void CTakeFourCtrl::ReturnReading()
{
    CStringArray params;
    params.Add("Hello!");

    CComPtr<IOleContainer> container; 
    // IOleContainer * container = NULL;
    IOleClientSite * site = this->GetClientSite();
    [i]// the following line fails and hr contains E_UNEXPECTED[/i]
    HRESULT hr = site->GetContainer(&container); 
    [i]//  container still == 0x00000000[/i]
    CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> doc(container);
    InvokeScript("Notify", params);
}
The variable 'site' contains a valid pointer and after peeking at its memory location it seems to contain valid information. If you have any idea why the GetContainer function is failing (only when ReturnReading is invoked from a thread) please let me know.

Thanks,

ross
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top