?
Solved

CHtmlView and printing

Posted on 2003-02-25
3
Medium Priority
?
796 Views
Last Modified: 2008-02-01
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
Comment
Question by:chrisbroadhurst
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
aamironline earned 200 total points
ID: 8022969
////// 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
 
LVL 1

Expert Comment

by:aamironline
ID: 8023008
////// 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
 

Author Comment

by:chrisbroadhurst
ID: 8024371
Fantastic - thank you very much
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question