Click here to Skip to main content
11,804,574 members (73,474 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VC6 VC7 C++ VC10.0 VisualC++
I have place a rich edit control in a class derived from cview.. I want to print the contents of the contrl.Please help me in doing the same.....
Posted 25-Jul-12 1:34am
Sandeep Mewara at 25-Jul-12 13:42pm
I want to print the contents of the contrl
So, did you try to do it? Where are you stuck?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The rich edit control do the printing if you ask it in the OnPrint method:

void CMyView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
	CRect rect;
	// offset by printing offset
	// adjust DC because richedit doesn't do things like MFC
	if (::GetDeviceCaps(pDC->m_hDC, TECHNOLOGY) != DT_METAFILE && pDC->m_hAttribDC != NULL)
			::GetDeviceCaps(pDC->m_hDC, LOGPIXELSX),
			::GetDeviceCaps(pDC->m_hAttribDC, LOGPIXELSX),
			::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY),
			::GetDeviceCaps(pDC->m_hAttribDC, LOGPIXELSY),
	// Set range for rendering
	fr.hdcTarget = pDC->m_hAttribDC;
	fr.hdc = pDC->m_hDC;
	fr.rcPage = GetPageRect();
	fr.rc = GetPrintRect();
	fr.chrg.cpMin = 0;
	fr.chrg.cpMax = fr.chrg.cpMin + GetWindowTextLength();
	GetRichEditCtrl().FormatRange(&fr, TRUE);

That's only the print method. You should to do some settings in the OnBeginPrinting & OnEndOPrinting if you need change settings before print or clean up after that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,205
1 Maciej Los 1,950
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100