Solved

TRichEdit

Posted on 2001-09-03
13
481 Views
Last Modified: 2010-04-06
Hello

Is there any way to print TRichedit without warptext?

Thanks
0
Comment
Question by:pmarkov
  • 6
  • 2
  • 2
  • +3
13 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
?

richedit1.print;

what's warptext?
0
 

Author Comment

by:pmarkov
Comment Utility
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
what about to set worwrpa to false before printing?

(just a guess)
0
 

Author Comment

by:pmarkov
Comment Utility
It doesn't help.
0
 

Author Comment

by:pmarkov
Comment Utility
It doesn't help.
0
 
LVL 1

Expert Comment

by:Dennis9
Comment Utility
Hi.
Just created this, and i hope it help:

function Printwithoutwrap(Text: string):string;
Var
st:tstringlist;
begin
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;
st.Free;
end;

//use:
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.

Dennis
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:pmarkov
Comment Utility
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.

0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
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
0
 

Author Comment

by:pmarkov
Comment Utility
I had sent this message before printing RichEdit.Print('');
but it didn't help...
0
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
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.
0
 

Author Comment

by:pmarkov
Comment Utility
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?

pmarkov@mail.com

Thanks again.
0
 
LVL 33

Accepted Solution

by:
Slick812 earned 200 total points
Comment Utility
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);
var
i, PrintXpix, PrintYpix, TextHeight: Integer;
begin
PrintXpix := GetDeviceCaps(Printer.Handle,LOGPIXELSX);
PrintYpix := GetDeviceCaps(Printer.Handle,LOGPIXELSY);
RichEdit1.WordWrap := False;
Printer.BeginDoc;
Printer.Canvas.Font.Assign(RichEdit1.DefAttributes);
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]);
Printer.EndDoc;
end;

 - - - - - - - - - - - - -  --
notice that I used the
GetDeviceCaps(Printer.Handle,LOGPIXELSX);
to get a pixel to inch thing. . . . if you call textWidth after BeginDoc and
Printer.Canvas.Font.Assign(RichEdit1.DefAttributes);
 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
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

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.
http://www.experts-exchange.com/questions/Q.20067808.html
http://www.experts-exchange.com/questions/Q.20076302.html
http://www.experts-exchange.com/questions/Q.20119597.html
http://www.experts-exchange.com/questions/Q.20154073.html
http://www.experts-exchange.com/questions/Q.20163542.html
http://www.experts-exchange.com/questions/Q.20165037.html
http://www.experts-exchange.com/questions/Q.20172049.html
http://www.experts-exchange.com/questions/Q.20177761.html
http://www.experts-exchange.com/questions/Q.20190253.html
http://www.experts-exchange.com/questions/Q.20193197.html
http://www.experts-exchange.com/questions/Q.20254828.html
http://www.experts-exchange.com/questions/Q.20265479.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20206809.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  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 http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Save pdf file to other location 3 72
Delphi XE2 application frozen on Windows 10 10 226
code issue 8 84
Multiple image collision 13 41
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

10 Experts available now in Live!

Get 1:1 Help Now