MFC controls Microsoft Web browser Simple Browser implementation

Source: Internet
Author: User

Environment: VS2013

New Project: Dialog box based

① Adding Controls to the dialog box Microsoft Web Browser (Note: The name of the control on VS2013 is Microsoft Web Browser, other compiler amounts are not known)

② Header function:

#include <afxinet.h>       

② set the environment variable for the added control (I set the environment variable to M_SA here)

③ set the page you want to open in OnInitDialog ()

M_sa. Navigate ("http://www.baidu.com", NULL, NULL, NULL, NULL);
Do this when a Web page can be displayed, but you will find that there are a lot of problems for us to solve

④ Problem One: Open the Web page is also open, but then click on one of the news, will be braking back to IE browser.

Workaround: At this point we need to add a message function (NEWWINDOW3) to prevent it from jumping to ie.

(Open the Class Wizard, under Command object ID (B): Find the ID number of the control you added, and then find the right message (S): NEWWINDOW3 message function found)

void Cmfcapplication1dlg::onnewwindow3explorer1 (lpdispatch* ppdisp, bool* Cancel, unsigned long dwFlags, LPCTSTR Bstrurlcontext, LPCTSTR bstrURL) {//TODO:  Add the message handler code here/*//  only in one dialog box to manipulate the page *cancel = TRUE; CString Strurl;strurl = bstrURL; VARIANT Vinfo; VariantInit (&vinfo); This->m_sa. Navigate (strURL, &vinfo, &vinfo, &vinfo, &vinfo);    This->showwindow (sw_show); *///*************************************** two methods required ********************************  Web page operation in multiple dialog boxes *cancel = TRUE; CString Strurl;strurl = bstrurl;//New dialog box  cmfcapplication1dlg *pnewdlg = new Cmfcapplication1dlg;pnewdlg->create (Idd_mfcapplication1_dialog, this);p Newdlg->showwindow (sw_show);//Web Navigation, New dialog box WebBrowser controls!  VARIANT Vinfo; VariantInit (&vinfo);p Newdlg->m_sa. Navigate (strURL, &vinfo, &vinfo, &vinfo, &vinfo);}

⑤ finally solved a small problem: there will be a warning when you open the Web page


Workaround: Find the property of the control and change the value of silent to true.


PostScript: I Caishuxueqian, welcome to propose bug

MFC controls Microsoft Web browser Simple Browser implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.