Navigate2 compare with Navigate

系统 1577 0
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?

Navigate2 compare with Navigate


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论