Instead of
hr = m_pWebBrowser->Navigate((BSTR)t_pURL, NULL, NULL, NULL, NULL);
the suggested workaround IN MFC is:
COleVariant noArg;
hr = m_pWebBrowser->Navigate((BSTR)t_pURL, &noArg, &noArg, &noArg,
&noArg);
I'm sure you can figure out the Non-MFC equivalent.
Regards,
Murali Krishna Devarakonda
Murali Krishna Devarakonda
I'm using the WebBrowser control since the first realease of the
Internet Explorer supporting it (3.01 I think). It works real fine inside my
C++ application's container. I can almost do everything.
Recently I wanted to pilot the Internet Explorer with direct automation
control : Open up the Internet Explorer Application and go to a specific
URL. Unfortunatly I'm having a probleme using the Navigate and the Navigate2
methods. Almost everthing I need works fine except these two functions. Each
time I want to navigate to an URL I have this 0x800706f4 undocumented.
Why is this happening to me ?
does any body have any idea how could I resolve this probleme ?
PS : I'm programming in pure C++, No MFC, no ATL, nothing but independant
pure C++ code with VC5.
This is my way of using the Navigate and Navigate2 functions that works real
fine inside a control container and not at all in automation:
BOOL CWPWebBrowser::Navigate(LPCTSTR p_pURL)
{
HRESULT hr;
BSTR t_pURL;
BOOL bRet = FALSE;
OLECHAR t_UnicodeURL[2*256];
if ((m_pWebBrowser == NULL) || (p_pURL == NULL)) return FALSE;
ConvertToUnicode((char FAR*)p_pURL, t_UnicodeURL);
if ((t_pURL = SysAllocString(t_UnicodeURL)) != NULL) {
hr = m_pWebBrowser->Navigate((BSTR)t_pURL, NULL, NULL, NULL, NULL);
bRet = (hr == S_OK);
SysFreeString(t_pURL);
}
return bRet;
}
BOOL CWPWebBrowser::Navigate2(LPCTSTR p_pURL)
{
HRESULT hr;
BOOL bRet = FALSE;
OLECHAR t_UnicodeURL[2*256];
VARIANT *vt_URL = new VARIANT;
VariantInit(vt_URL);
if (m_pWebBrowser == NULL) return FALSE;
if ((dwVersion != IE_VER_4) && (dwVersion != IE_VER_4_95)) return FALSE;
ConvertToUnicode((char FAR*)p_pURL, t_UnicodeURL);
if ((vt_URL->bstrVal = SysAllocString(t_UnicodeURL)) != NULL) {
vt_URL->vt = VT_BSTR;
hr = ((IWebBrowser2*)m_pWebBrowser)->Navigate2(vt_URL, NULL, NULL, NULL,
NULL);
bRet = (hr == S_OK);
SysFreeString(vt_URL->bstrVal);
}
delete vt_URL;
return bRet;
}
I do QueryInterface CLSID_InternetExplorer either for IID_IWebBrowserApp in
IE 3.01 or IID_IWebBrowser2 for IE4 and over.
Please Where is My Error ?
A+
Pierre Chehwan ;Ţ
pche...@ixo.fr
Although I don't have any access violation, putting empty VARIANT instead of
NULL in the optional parameters resolves my problem. Now I can navigate
without any problem.
Thank again
Pierre
Murali Krishna Devarakonda wrote in message ...