Implement print web page similar to IE

zhaozj2021-02-11  239

When we click on the "Print" button on the toolbar to implement the IE print function function, it is found that there is no "print"

The Machine Security dialog is displayed, and the program will automatically start printing documents. This feature is also used for Microsoft

Word. This feature is implemented in the application, the encoding is as follows:

Void cmybrowser :: onprint ()

{

LPOLECOMMANDTARGET PCMDTARG = NULL;

M_PDISP = m_webbbrowser2.getdocument (); // get the idispatch interface Pointer

Assert (m_pdisp);

m_pdisp-> queryinterface (IID_IOLCOMMANDTARGET, (LPVOID *) & pcmdtarg); // Query for OleCommandTarget Interface

Assert (pcmdtarg);

PCMDTARG-> EXEC (Null, // Call the olecommandtarget's exec method

OLECMDID_PRINT,

0,

NULL,

NULL

);

IF (PCMDTARG)

PCMDTARG-> Release (); // Release Document's Command Target

IF (m_pdisp)

m_pdisp-> release (); // Release Document's Dispatch Interfac

}

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

New Post(0)