Click here to Skip to main content
13,086,019 members (83,402 online)
Rate this:
Please Sign up or sign in to vote.
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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2017
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