(CodeLib-Manager)
Registriert seit: 9. Jul 2003
Ort: Ensdorf
6.723 Beiträge
Delphi XE Professional
|
Position des Cursors im Richedit
27. Jul 2004, 02:46
Hi!
Da kürzlich mal in einem Thread danach gefragt wurde:
Delphi-Quellcode:
uses richedit;
procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
var
line, Pos: Integer;
begin
Line := 1 + SendMessage(RichEdit1.Handle, EM_EXLINEFROMCHAR, 0,
RichEdit1.SelStart);
Pos := 1 + (RichEdit1.SelStart - SendMessage(RichEdit1.Handle,
EM_LINEINDEX, line - 1, 0));
Label1.Caption := Format('Zeile %d Position %d', [Line, Pos]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with RichEdit1.CaretPos do
ShowMessage(Format('Zeile %d Position %d', [y + 1, x]));
RichEdit1.SetFocus;
end;
von DelphiMania
Ciao fkerber
Frederic Kerber
|
|
Zitat
|