When we click "print" on the toolbar to implement the print function of IE, we find that "print" does not exist.
The host installation dialog box is displayed, and the program starts to print documents automatically. This feature is also usedMicrosoft
Word. To implement this feature in an application, the encoding is as follows:
Void CMyBrowser: OnPrint ()
{
LPOLECOMMANDTARGET pCmdTarg = NULL;
M_pDisp = m_WebBrowser2.GetDocument (); // get the IDispatch interface pointer
ASSERT (m_pDisp );
M_pDisp-> QueryInterface (IID_IOleCommandTarget, (LPVOID *) & pCmdTarg); // query for olecommandtarget interface
ASSERT (pCmdTarg );
PCmdTarg-> Exec (NULL, // call the olecommandtargets Exec method
OLECMDID_PRINT,
0,
NULL,
NULL
);
If (pCmdTarg)
PCmdTarg-> Release (); // release documents command target
If (m_pDisp)
M_pDisp-> Release (); // release documents dispatch interfac
}