打印richeditcntrl的内容 [英] printing contents of a richeditcntrl

查看:124
本文介绍了打印richeditcntrl的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在cview派生的类中放置了丰富的编辑控件..我想打印contrl的内容.请帮助我做同样的事情..

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.....

推荐答案

如果您在OnPrint方法中要求使用丰富的编辑控件进行打印:

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

void CMyView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	FORMATRANGE fr;
	CRect rect;
	
	// offset by printing offset
	pDC->SetViewportOrg(-pDC->GetDeviceCaps(PHYSICALOFFSETX),
		-pDC->GetDeviceCaps(PHYSICALOFFSETY));
	
	// adjust DC because richedit doesn't do things like MFC
	if (::GetDeviceCaps(pDC->m_hDC, TECHNOLOGY) != DT_METAFILE && pDC->m_hAttribDC != NULL)
	{
		::ScaleWindowExtEx(pDC->m_hDC,
			::GetDeviceCaps(pDC->m_hDC, LOGPIXELSX),
			::GetDeviceCaps(pDC->m_hAttribDC, LOGPIXELSX),
			::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY),
			::GetDeviceCaps(pDC->m_hAttribDC, LOGPIXELSY),
			NULL);
	}
	// 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);
}




那只是打印方法.您应该在OnBeginPrinting&中进行一些设置.如果需要在打印之前进行更改设置或在此之后进行清理,则为OnEndOPrinting.




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.


这篇关于打印richeditcntrl的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆