Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to specify a line break in a TRichEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
42
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I need to be able to (preferrably dynamically as the user is typing text) to 
specify a line break of say 70 characters so that the cursor will go to a new line 
upon reaching the 70 character limit. Actually it would be best to break on the 
last word boundary but even a break at 70 characters would give me a start.

Answer:

I've had a play with this and the following is the best I could come up with 
quickly. At least it may give you a start:

Set a Variable called Backpace : Boolean = False ;
1   
2   procedure GetCurrentRC(re1: TRichedit; var row, col: LongInt);
3   begin
4     {Get Current Row and Column Values for Richedit Control}
5     with re1 do
6     begin
7       Row := sendMessage(handle, EM_LINEFROMCHAR, Selstart, 0);
8       Col := selstart - sendmessage(handle, EM_LINEINDEX, row, 0);
9     end;
10  end;
11  
12  procedure TForm1.re1SelectionChange(Sender: TObject);
13  var
14    RTRow, RTCol: LongInt;
15  begin
16    GetCurrentRC(re1, RTRow, RTCol);
17    if (rtCol = 70) and (not Backspace) then
18      re1.Lines[rtRow] := Memo1.Lines[rtRow] + #13#10;
19  end;
20  
21  procedure TForm1.Re1KeyPress(Sender: TObject; var Key: Char);
22  begin
23    {If Backspacing we don't want it to jump down again}
24    if key = #8 then
25      backspace := True
26    else
27      backspace := False;
28  end;


I think that's about right. You would have to search on the position of any space if you wanted to break on a word boundary.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC