Article ID: 156732
Article Last Modified on 7/1/2004
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ctlWebBrowser.Navigate(_T("http://www.microsoft.com"),
NULL, NULL, NULL, NULL);
return TRUE;
}
void CAboutDlg::OnPrint()
{
CWnd* pWnd = GetFocus ();
m_ctlWebBrowser.SetFocus ();
// send Ctrl-P
keybd_event (VK_CONTROL, 0, 0, 0);
keybd_event ('P', 0, 0, 0);
// set focus to control that previously had focus
if (pWnd);
pWnd->SetFocus ();
}
// DOCOBJ.H comes with the Internet Client SDK and is installed by
// default in the "\INetSDK\Include" directory
#include <docobj.h>
void CAboutDlg::OnPrint()
{
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
lpDispatch = m_ctlWebBrowser.GetDocument();
ASSERT(lpDispatch);
lpDispatch->QueryInterface(IID_IOleCommandTarget,
(void**)&lpOleCommandTarget);
ASSERT(lpOleCommandTarget);
lpDispatch->Release();
// print contents of web browser control
lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, 0, NULL,NULL);
lpOleCommandTarget->Release();
}
Keywords: kbhowto kbprint KB156732