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
chrisbroadhurstAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.