How to embed ie in the VC application (dialog box) to view the web page in the program

Source: Internet
Author: User
First, you must Program Window embedded in IE browser. There are two implementation methods: one is to add the chtmlview class, and the other is to add the ActiveX Control of IE browser. In fact, no matter what method is used, except for the slightly different function names, they eventually call Microsoft's iwebbrowser2 interface. Iwebbrowser2 is very powerful. Its technology is DHTML (Dynamic HTML, which will be introduced later ). In this article Article . For more functions, refer to msdn.
The example program is embedded with IE ActiveX in the dialog window as the demonstration basis. You can use chtmlview to modify it. Compiled and run in vc6.

Ii. methods and steps:
1. Create an MFC Application in dialog window format. Be sure to select ActiveX controls on the 2nd page of the navigation. This is also the default option.
2. Add the Microsoft Web browser ActiveX control to the project.
Run Project/Add to project/components and controls... select the registered ActiveX controls directory, find Microsoft Web browser, and insert. In this way, MFC will generate an iwebbrowser2 packaging class cwebbrowser2.
3. In the dialog window resource editor, place the IE control on the toolbar in your dialog window. Start classwizard and map this IE control to an object of cwebbrowser2 (the object name in the demo is m_ie)

3. Some knowledge to be explained in the demo: (for more details, see the msdn description of chtmlview and iwebbrowser2)
1. use the navigate ()/navigate2 () function to view an HTML file (or an activex file, such as Word or PDF).
2. the display of background music, image files, and Flash files is actually directly written in HTML files according to HTML syntax tags.
3. For the printing function, you must call the execwb () function. This function has many functions. According to the parameter command (olestmid), it can implement more than 30 functions, such as printing, saving, and cropping.
4. The IE control has a very important event (when the HTML connection is enabled ). After the onbeforenavigate2 () function is overloaded, you can achieve connection redirection and extract user input form data in HTML. In the demo, we also showed you how to obtain data and how to use a security array.
5. In the demo program, to highlight the key points. HTML template files are very basic and simple. If you have a deep knowledge of HTML, let's take full advantage of it.

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.