Solved

Printing contents of a CRichtEditCtrl looses part of characters

Posted on 2003-11-24
5
201 Views
Last Modified: 2013-11-20
I have a CRichEditCtrl which contents I like to print. I am using PrintClient on a printer dc. However, sometimes characters are printed only partly (the right part is cut off). The characters cut off are or on the end of a line (but not on all lines) or after a tab character (also not after every tab).
What is causing this strange behaviour?
0
Comment
Question by:ble
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 250 total points
ID: 9809508
Use FormatRange

eg:
                                FORMATRANGE fr;
            fr.hdc = dc;
            fr.hdcTarget = dc;
            fr.rc = CRect((rect.Width( ) / 2), (_border / 2) ,m_size.cx*15, m_size.cy*15);
            fr.rcPage = CRect(0,0,0,0);
            fr.chrg.cpMin = 0;
            fr.chrg.cpMax = -1;
            
            _richCtrl->FormatRange( &fr );


And print the content of fr.hdc

Good Luck
0
 

Author Comment

by:ble
ID: 9809520
Is it a problem with the FormatRange? Can this cause some part of a character after a tab to be lost?
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9809564
PrintClient is the member function of CWnd, so It may not gave the correct format. Format range is implemented in RICHEDT itself, so this will work.
0
 

Author Comment

by:ble
ID: 9809714
In your example you are using rect, _border and m_size. What are these variables?
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9809729
Just use the GetClientRect of RichEdit. Thatz just a sample code from the MSDN
Rosh :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now