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.
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
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);
}
Thanks,
ross