Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 807
  • Last Modified:

CHtmlView and printing

Hi,  I'm a pretty dumb MFC guy - I've developed a view class derived from CHtmlView and can not find how to override the print function (as I want to be able to print without headers).  
Can somebody point me in the right direction please
Thanks Chris
0
chrisbroadhurst
Asked:
chrisbroadhurst
  • 2
1 Solution
 
aamironlineCommented:
////// Add following Header files

#include <afxhtml.h>        // MFC support for Web browser
#include <mshtml.h>         //IWeb objects
#include <atlconv.h>        //Conversion routines



// Add following code on CMyHtmlView OnPrint  /////////////////

void CMyHtmlView::OnPrint()
{
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;

lpDispatch = m_Browser.GetHtmlDocument();
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();

}

0
 
aamironlineCommented:
////// Add following Header files

#include <afxhtml.h>        // MFC support for Web browser
#include <mshtml.h>         //IWeb objects
#include <atlconv.h>        //Conversion routines



// Add following code on CMyHtmlView OnPrint  /////////////////

void CMyHtmlView::OnPrint()
{
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;

lpDispatch = m_Browser.GetHtmlDocument();
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();

}

0
 
chrisbroadhurstAuthor Commented:
Fantastic - thank you very much
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now