May 5th, 1999, 03:24 AM
Hi:
i have a problem printing a web page with de CWebBrowser class. i have a button and when a i press on it the follow function is executed, the first time that i push de button only print a blank page and the printer queue shows me: about::blank; the second time all works fine and printsde web page. Why de first time is not working?
thanks!
void CViewUnidDesc::OnPrintUDHTML ()
{
OnToolBarCambiaModoVerUD (ID_CONS_UD_HTML); /* shows the web page in a property page, works fine */
CWnd * pPadre = m_PageTabUnidDesc.m_PageHTML.CWnd::GetParent(); /* m_PageTabUnidDesc is de property page and
m_PageHTML is member of CViewUnidDesc and
a instance of a derivated class of CWebBrowser
called CBFCWebBroser that implements the
write of an HTML file on a disk */
if (((CBFCBrowser*)pPadre->GetDlgItem(IDC_HTML_CTRL))->SetFocus ()!=NULL) /* the web control obtains the focus */
{
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
lpDispatch = m_PageTabUnidDesc.m_PageHTML.GetDocument();
ASSERT(lpDispatch);
lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
ASSERT(lpOleCommandTarget);
lpDispatch->Release();
// Print contents of WebBrowser control.
HRESULT hRes;
hRes=lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, NULL ,NULL);
/* warning: i want that de IE Control print dialog box don't prompt user so i put the right parameter in Exec function */
if (hRes==S_OK)
{
MessageBox ("The command was executed successfully.");
}
if (hRes==OLECMDERR_E_UNKNOWNGROUP)
{
MessageBox ("The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.");
}
if (hRes==OLECMDERR_E_NOTSUPPORTED)
{
MessageBox ("The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup");
}
if (hRes==OLECMDERR_DISABLED)
{
MessageBox ("The command identified by nCmdID is currently disabled and cannot be executed");
}
if (hRes==OLECMDERR_NOHELP)
{
MessageBox ("The caller has asked for help on the command identified by nCmdID, but no help is available.");
}
if (hRes==OLECMDERR_CANCELED)
{
MessageBox ("Canceled");
}
lpOleCommandTarget->Release();
}
else
{
MessageBox ("Ctrl IE is not focused");
}
}
i have a problem printing a web page with de CWebBrowser class. i have a button and when a i press on it the follow function is executed, the first time that i push de button only print a blank page and the printer queue shows me: about::blank; the second time all works fine and printsde web page. Why de first time is not working?
thanks!
void CViewUnidDesc::OnPrintUDHTML ()
{
OnToolBarCambiaModoVerUD (ID_CONS_UD_HTML); /* shows the web page in a property page, works fine */
CWnd * pPadre = m_PageTabUnidDesc.m_PageHTML.CWnd::GetParent(); /* m_PageTabUnidDesc is de property page and
m_PageHTML is member of CViewUnidDesc and
a instance of a derivated class of CWebBrowser
called CBFCWebBroser that implements the
write of an HTML file on a disk */
if (((CBFCBrowser*)pPadre->GetDlgItem(IDC_HTML_CTRL))->SetFocus ()!=NULL) /* the web control obtains the focus */
{
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
lpDispatch = m_PageTabUnidDesc.m_PageHTML.GetDocument();
ASSERT(lpDispatch);
lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
ASSERT(lpOleCommandTarget);
lpDispatch->Release();
// Print contents of WebBrowser control.
HRESULT hRes;
hRes=lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, NULL ,NULL);
/* warning: i want that de IE Control print dialog box don't prompt user so i put the right parameter in Exec function */
if (hRes==S_OK)
{
MessageBox ("The command was executed successfully.");
}
if (hRes==OLECMDERR_E_UNKNOWNGROUP)
{
MessageBox ("The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.");
}
if (hRes==OLECMDERR_E_NOTSUPPORTED)
{
MessageBox ("The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup");
}
if (hRes==OLECMDERR_DISABLED)
{
MessageBox ("The command identified by nCmdID is currently disabled and cannot be executed");
}
if (hRes==OLECMDERR_NOHELP)
{
MessageBox ("The caller has asked for help on the command identified by nCmdID, but no help is available.");
}
if (hRes==OLECMDERR_CANCELED)
{
MessageBox ("Canceled");
}
lpOleCommandTarget->Release();
}
else
{
MessageBox ("Ctrl IE is not focused");
}
}