C
Chris Miller
Hi Folks,
I have developed a port monitor with WebDAV behavior. One feature available
during port configuration is a "Test" button which automates IE and shows
the user a page from the webserver. That works. If I invoke the same code
from EndDocPort I get no failures from COM (ActiveX?) but the call to set
the instance visible has no effect -- I get no error and I also get no
visibility. I am able to fire up MessageBox displays.
My COM code is almost trivial -- 5 steps: Initialize COM, Create an
Instance, Allocate a BSTR, Call the Navigate Method of the instance, Set the
instance Visible.
Is there some subtlety about the spooler EndDocPort routine that I don't
understand? Can anybody see anything wrong in my code?
void Test(tstring *url)
{
HRESULT hr;
IWebBrowserApp* ie = NULL;
BSTR u;
VARIANT flags = {0};
VARIANT frame = {0};
VARIANT post = {0};
VARIANT hdr = {0};
if (FAILED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if (FAILED(hr = CoCreateInstance(CLSID_InternetExplorer,
NULL,
CLSCTX_SERVER,
IID_IWebBrowserApp,
(LPVOID*)&ie)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if ((u = SysAllocString(url->c_str())) == NULL){Notify(_T("Test URL"),
__LINE__);}
if (FAILED(hr = ie->Navigate(u, &flags, &frame, &post, &hdr)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if (FAILED(hr = ie->put_Visible(VARIANT_TRUE)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
I have developed a port monitor with WebDAV behavior. One feature available
during port configuration is a "Test" button which automates IE and shows
the user a page from the webserver. That works. If I invoke the same code
from EndDocPort I get no failures from COM (ActiveX?) but the call to set
the instance visible has no effect -- I get no error and I also get no
visibility. I am able to fire up MessageBox displays.
My COM code is almost trivial -- 5 steps: Initialize COM, Create an
Instance, Allocate a BSTR, Call the Navigate Method of the instance, Set the
instance Visible.
Is there some subtlety about the spooler EndDocPort routine that I don't
understand? Can anybody see anything wrong in my code?
void Test(tstring *url)
{
HRESULT hr;
IWebBrowserApp* ie = NULL;
BSTR u;
VARIANT flags = {0};
VARIANT frame = {0};
VARIANT post = {0};
VARIANT hdr = {0};
if (FAILED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if (FAILED(hr = CoCreateInstance(CLSID_InternetExplorer,
NULL,
CLSCTX_SERVER,
IID_IWebBrowserApp,
(LPVOID*)&ie)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if ((u = SysAllocString(url->c_str())) == NULL){Notify(_T("Test URL"),
__LINE__);}
if (FAILED(hr = ie->Navigate(u, &flags, &frame, &post, &hdr)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}
if (FAILED(hr = ie->put_Visible(VARIANT_TRUE)))
{
SetLastError(hr);
Notify(_T("Test URL"), __LINE__);
}