CWebBrowser2 ctrl provide two method to link a web page:
Navigate2(VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
Navigate(LPCTSTR URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
My requirement is very simple, give a link: such as www.sina.com, navigate to web page.
At first, I use method Navigate because it is easy to use.
But sometimes I find that it get a error page while I can link the web page with other browser.
After a long time research, I can not find a good solution, then I found the method Navigate2. I wrote a method to rope it as follow:
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
1 void Navigate2(CString szHtmlUrl)
2 {
3 try
4 {
5 VARIANT vFlags = {VT_I4, navNoReadFromCache};
6 VARIANT vUrl;
7 VariantInit(&vUrl);
8 BSTR bstrUrl = szHtmlUrl.AllocSysString();
9 vUrl.vt = VT_BSTR;
10 vUrl.bstrVal = bstrUrl;
11 m_web.Navigate2(&vUrl, &vFlags, NULL, NULL, NULL);// refresh top browser's content
12 g_Logger.Add(LOGLEVEL_FYI, _T("Navigate2TopBanner, Top link Url: %s"), szHtmlUrl);
13 ::SysFreeString(bstrUrl);
14 }
15 catch(){}
16 }
It works well....
Compare the implements:
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->1 void CWebBrowser2::Navigate(LPCTSTR URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
2 {
3 static BYTE parms[] =
4 VTS_BSTR VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
5 InvokeHelper(0x68, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
6 URL, Flags, TargetFrameName, PostData, Headers);
7 }
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->1 void CWebBrowser2::Navigate2(VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers)
2 {
3 static BYTE parms[] =
4 VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
5 InvokeHelper(0x1f4, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
6 URL, Flags, TargetFrameName, PostData, Headers);
7 }
I find that they invoked different
dwDispID
of
InvokeHelper, get the explain from MSDN:
Parameters
dwDispID
Identifies the method or property to be invoked.
Who can tell me what's the differents of
0x1f4 between 0x68?
分享到:
相关推荐
Chapter 2. Knowing the Basics Section 2.1. Parts of a Program Section 2.2. Classes and Modules Section 2.3. Procedures Section 2.4. Variables Section 2.5. Conditional Statements Section ...
The selected text compare allows you to select portions of text between 2 files and execute a compare on ONLY the se Using the SSH/telnet console A tutorial for UltraEdit/UEStudio's SSH/telent ...
However it does provide a ‘lens’ to use to compare their current implementations with an idealized approach. The document can also be used by suppliers to help position their products in relation ...
Learn how Linux organizes files and navigate its filesystem Use basic developer commands such as gzip and grep Edit programs with vi and vim, and explore alternative editors Perform basic sysadmin...
• Navigate through a file's constituent revisions Timeline View: • Compact horizontal timeline • Compare history for multiple items • Powerful set of filters • Branch points are clearly marked ...
Learn how Linux organizes files and navigate its filesystem Use basic developer commands such as gzip and grep Edit programs with vi and vim, and explore alternative editors Perform basic sysadmin ...
Navigate the dangers of Martian soil, complete with hidden gas pockets, earthquakes, and other surprises. Purchase powerful upgrades for your Mining Pod with the fruits of your labor. Compare high ...
2. Getting Started: The first chapter helps reader with setting up their development environment. We also take a closer look at the Windows 8 simulator and the difference between running native. a. ...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
The SQL Window will now navigate to the offending cell in the result set after an insert or update with a column-specific error. The rowid column is now omitted when exporting a result set grid in SQL...
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution...