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.