Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto a line of a TRichEdit 1

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
Sorry to pester everyone again!

Does anyone know how to move the cursor to the beginning of, for example, line 50 in a TRichEdit component at run-time?

Your help would be much appreciated

Clive [infinity]
 
I haven't played with this at all, but I found this on google.

From Team B on borland boards:

var
curLine: integer;
begin
with RichEdit1 do
begin
curLine := Perform(EM_LINEFROMCHAR, -1, 0);
SelStart := Perform(EM_LINEINDEX, curLine, 0);
SelLength := Length(Lines[curLine]);
SelAttributes.Color := clRed;
SelLength := 0;
SetFocus;
end;
end;

 
I have done somthing simular useing the 'sendmessage' API call. this gets the cursor to the right place using a search.

SelStart := FoundAt;
SelLength := Length(SearchText);
Line:= SendMessage(Handle, EM_EXLINEFROMCHAR, 0, selstart);
All.Add(lines[Line]);
selstart := selstart + sellength;
SelLength := selstart - Length(SearchText);

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top