Common features for Microsoft Web Browser controls

xiaoxiao2021-03-06  70

Microsoft's Web Browse control

How to use, select Menu Project -> Add to Project -> Components and Controls ..., select the Registered ActiveX Controls folder in the pop-up dialog, then select the Microfost web browsing control in the list. Or Edit the dialog resource, right-click Select the Insert ActiveX control option, or select the control in the list.

The main function:

First: Browse the web

With the Navigate interface of the control, the prototype is as follows:

Void CWebbrowser2 :: Navigate (LPCTSTSTER URL, VARIANT * FLAGS, VARIANT * TARGETFRAMENAME, VARIANT * POSTDATA, VARIANT * HEADERS)

As long as the first parameter fills the full path name of the HTML file (cannot use a relative path name), the remaining parameters can be NULL.

It is a very ordinary function, but sometimes flexible use will also receive a lot of unexpected effects, such as:

>> Beautify Interface: Design a cool page with this control to display the beauty of the interface

>> Play music: Play music (MID or WAV) in the web, while hiding the control, you can implement the playback of the program background music. Example HTML file:

>> Play video: You can support ASF and MPEG format

>> Display Image: Use a web browser to simply display pictures such as GIF, JPEG, BMP. Example HTML file

>> Browse DOC Documents, PDF files: Use the control's NaviGate interface, you can browse Word documents and PDF files, as long as the first parameter fills the full path name of the file, the back parameters can be NULL

Second: Print

Print the content displayed in the control through the control of the control, and the print preview can be easily implemented, and the paper size is set.

// m_webbrowse is a variable corresponding to the control

M_WebBrowse.execwb (Olecmdid_Print, Olecmdexecopt_Promptuser, Null, Null); // Print

// Use the OLECMDEXECOPT_PROMPTUSER parameter to print the dialog box, let the user choose the printer, page layout, etc., so that the // will not pop up with OLECMDEXECOPT_DONTPROMPTUSER

M_ WebBrowse.execwb (Olecmdid_PrintPreview, Olecmdexecopt_dontpromptuser, null, null); // Print Preview

m_webbrowse.execwb (OlecmDid_pagesetup, Olecmdexecopt_Promptuser, Null, Null); // Paper Size Settings

Third: Intercepting the submitted data, further use DHTML display submitted data

Implementing these functions Mainly by modifying the processing of the control, the prototype is as follows:

OnBeforenaviGate2Explorer1 (// This function calls LPDispatch PDISP before the HTML connection,

Variant Far * URL, // Prepare the URL of the browse, modify it to achieve the steering

Variant Far * Flags,

Variant Far * TargetFrameName,

Variant Far * PostData,

Variant Far * Headers,

Bool Far * Cancel) // True: Stop False: Continue

转载请注明原文地址:https://www.9cbs.com/read-92105.html

New Post(0)