Posted on 2001-09-03
Last Modified: 2010-04-06

Is there any way to print TRichedit without warptext?

Question by:pmarkov
  • 6
  • 2
  • 2
  • +3
LVL 27

Expert Comment

ID: 6450570


what's warptext?

Author Comment

ID: 6450588
I am so sorry...

WRAP text.

If a line is too long it is wraping to the next line.
I don't want wraping. I just want to cut lines.
LVL 27

Expert Comment

ID: 6450619
what about to set worwrpa to false before printing?

(just a guess)
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!


Author Comment

ID: 6450627
It doesn't help.

Author Comment

ID: 6450654
It doesn't help.

Expert Comment

ID: 6450706
Just created this, and i hope it help:

function Printwithoutwrap(Text: string):string;
st := tstringlist.Create;
st.Text := Text;
st.Text := StringReplace(st.Text, #13#10, ' ', [rfReplaceAll]);
st.Text := StringReplace(st.Text, '  ', ' ', [rfReplaceAll]);
st.Text := StringReplace(st.Text, '   ', ' ', [rfReplaceAll]);
result := st.Text;

RichEdit2.Text := Printwithoutwrap(RichEdit1.Text);
//Then maybe u would print it from RichEdit2?
//Or do what u want

It returns the string, but in one long line.
If u wan tit should not be to hard to change it to strings intead, that way it supports bigger text.


Author Comment

ID: 6450731
Sorry but it is NOT the ansewr which I expected.

RichEdit has got a WordWrap property. If it is false RichEdit will be DISPLAY the text without wrap. But it doesn't affected to PRINTING of RichEdit.

RichEdit.Print uses SendMessage(PRichEdit.Handle, EM_FORMATRANGE, 1, Longint(@Range)) to print it. And I want to cut lines when they are printing, not when they are displaing on the screen.

LVL 10

Expert Comment

ID: 6450920
Does this help (I didn't test this yet):

  SendMessage(RichEdit1.Handle, EM_FMTLINES, 0, 0);

If you send this message before printing?

Regards Jacco

Author Comment

ID: 6452214
I had sent this message before printing RichEdit.Print('');
but it didn't help...
LVL 33

Expert Comment

ID: 6459610
hello pmarkov, , some time ago I needed to print a richedit with special margins, different on the top than the bottom, but showing this in the Richedit. I think maybe the windows printing is what is wraping your text, not the rich edit. But to get the margins I wanted, I had to use something like Printer.Canvas.TextOut(margin1, Printer.Canvas.TextHeight( RichEdit.Lines[CurrentLine]) * CurrentLine, RichEdit.Lines[CurrentLine]); I had to set the Printer.Canvas.Font also. I don't have that code anymore, but you may look to the printer settings to change the wrapping or go through the trouble of Printer.Canvas.TextOut.

Author Comment

ID: 6469829
Thank you Slick812 for idea.

I had tried this and it work good, but I have had a problem.

Printer.Canvas.TextWidth() returns wrond result. When I print something to the printer then this returns right result. Why? What must I do before acess TextWidth for the first time?

Thanks again.
LVL 33

Accepted Solution

Slick812 earned 200 total points
ID: 6472359
pmarkov, the printer uses a totally different numbering for Canvas placement, it does not use the "Pixels" we are used to using in delphi. AND these numbers are Different depending on the type of printer you are using. I haven't worked with Printer.Canvas in a while, Here is some code that seems to do what you want. When I printed this, it CUT OFF the lines that were too long . . . .

procedure TForm1.ButtonPrintCanvasClick(Sender: TObject);
i, PrintXpix, PrintYpix, TextHeight: Integer;
PrintXpix := GetDeviceCaps(Printer.Handle,LOGPIXELSX);
PrintYpix := GetDeviceCaps(Printer.Handle,LOGPIXELSY);
RichEdit1.WordWrap := False;
TextHeight := Printer.Canvas.TextHeight('M');
  for i := 0 to RichEdit1.Lines.Count-1 do
  Printer.Canvas.TextOut(PrintXpix div 3, (PrintYpix div 3)+ (TextHeight*i), RichEdit1.Lines.Strings[i]);

 - - - - - - - - - - - - -  --
notice that I used the
to get a pixel to inch thing. . . . if you call textWidth after BeginDoc and
 then you should get the right textWidth in the device units of the printer (NOT PIXELS), you may want to get a reference book for delphi and the Tprinter, or do a search here for "Printer.Canvas" or other printer things

Expert Comment

ID: 6900916
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
Magic Software info 18 132
Tviruailstringtree sort multi columns on header click 1 66
how to resize animated Gif image in delphi ? 1 31
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

831 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