Click here to Skip to main content
11,640,907 members (61,660 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VC6 VC7 VC10.0 VC
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 Mika Wendelius 380
1 OriginalGriff 205
2 DamithSL 153
3 CPallini 125
4 Afzaal Ahmad Zeeshan 124
0 Mika Wendelius 370
1 OriginalGriff 205
2 CPallini 125
3 DamithSL 105
4 Afzaal Ahmad Zeeshan 70

Advertise | Privacy | Mobile
Web03 | 2.8.150731.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