IWebBrowser2: Navigate2 ignored

T

Tim Bücker

Hello.

I am trying to launch the internet explorer from my program using the code
seen below but unfortunately the Navigate2 command is ignored.
So Navigate2 is not working but calling GoHome() the start page is being
displayed...???

Has someone an idea what I am doing wrong?
Here´s the code:

HRESULT hr;
IWebBrowser2* pWebBrowser = NULL;
HRESULT comInit = CoInitializeEx(NULL,COINIT_MULTITHREADED);
hr = CoCreateInstance (CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (LPVOID*)&pWebBrowser);
if (SUCCEEDED (hr) && (pWebBrowser != NULL))
{
m_pWebBrowser = pWebBrowser;
m_pWebBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
m_pWebBrowser->put_AddressBar(VARIANT_FALSE);
m_pWebBrowser->put_MenuBar(VARIANT_FALSE);
m_pWebBrowser->put_StatusBar(VARIANT_FALSE);
m_pWebBrowser->put_ToolBar(VARIANT_FALSE);
m_pWebBrowser->put_Visible (VARIANT_TRUE);
m_pWebBrowser->put_Offline(VARIANT_FALSE);
}
else
{
if (pWebBrowser)
pWebBrowser->Release ();
}
CComVariant *url = new CComVariant("http://localhost/");
// VARIANT* url = new "http://www.microsoft.com";
m_pWebBrowser->Navigate2(url, NULL, NULL, NULL, NULL);

Thanks a lot for any help!
Greetings,
Tim.
 
R

rixil

You probably would have better luck getting these types of questions
answered in one of the following groups:
comp.os.ms-windows.programmer.ole
comp.os.ms-windows.programmer.win32

At the same time, giving zero assistance is not my style...

While I haven't checked out your sample in detail, I can tell you that
Navigate2 responds better if you pass an empty variant rather than NULL
for parameters 2-5. In other words, assuming everything else is right,
you should try something like this:

CComVariant url("http://localhost/");
CComVariant empty;
m_pWebBrowser->Navigate2(&url, &empty, &empty, &empty, &empty);
Regards,

Michael Loritsch
 
T

Tim Bücker

You probably would have better luck getting these types of questions
answered in one of the following groups:
comp.os.ms-windows.programmer.ole
comp.os.ms-windows.programmer.win32

Hello Michael Loritsch,

thanks for pointing out some newsgroups where to post my question legally
;-)
At the same time, giving zero assistance is not my style...

And a big thanks also to your attitude as your answer is totally correct!
While I haven't checked out your sample in detail, I can tell you that
Navigate2 responds better if you pass an empty variant rather than NULL
for parameters 2-5. In other words, assuming everything else is right,
you should try something like this:

CComVariant url("http://localhost/");
CComVariant empty;
m_pWebBrowser->Navigate2(&url, &empty, &empty, &empty, &empty);

I didn´t tried it out yet but later I posted the question to
"microsoft.public.inetsdk.programming.webbrowser_ctl"
and I got this answer:

CComVariant url(OLESTR("http://localhost/"));
CComVariant varEmpty;
m_pWebBrowser->Navigate2(&url,&varEmpty, &varEmpty, &varEmpty, &varEmpty);

So again a big thanks to you!
And sorry for posting my question here.

Greetings,
Tim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top