Rich Text Drawing, Printing Preview and Printing (GDI only)
Author homepage: Introduction"Why the drawing and printing preview of my rich text work fine, but when I tried to print to paper, it cann't work?" I had found that there are many people ucancode.neted for this question many many times, I hope this article and codes can help you. This small application demoed how to draw rich text on the canvas, and then you can print preview or print to paper with the same look. Full source codes are contained within the zip file. There is no limit, you can use it freely. How it works?1.we defined a rich text control within the header file of class: CTestRichEditPrintView,as below: [code] // CRichEditCtrl for drawing. [/code] 2.We modify the OnDraw method of class: CTestRichEditPrintView, the following codes are used for drawing to canvas: [code] m_nLogPixelsX = ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSX); [/code] These codes can be used for printing preview, it will works fine. But we cann't used them for printing to paper. 3.For printing to paper mode, we use the following codes: [code] szWinExt = pDC->GetWindowExt(); [/code] we must change the map mode, window ext and viewport ext before start to print, and when we finish to print, we need get it back. |
|
Copyright ?1998-2024 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.
Please direct your questions or comments to webmaster@ucancode.net