Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi "Gehe zu Zeile" in TRichEdit bzw. TSynEdit (https://www.delphipraxis.net/7006-gehe-zu-zeile-trichedit-bzw-tsynedit.html)

mirage228 29. Jul 2003 20:14


"Gehe zu Zeile" in TRichEdit bzw. TSynEdit
 
Hallo,

ich wollte für mein Programm eine "Gehe zu Zeile" funktion machen..
aber irgendwie klappt mein Code nicht:

Delphi-Quellcode:
procedure TMainForm.GotoLine(Line: Integer);
var
  Pos: TPoint;
  HwnD: Integer;
begin
  if (Documents.PageCount <= 0) or (Documents.ActivePage = nil) then Exit;
  Pos.X := 0;
  if not Dokumente[Documents.ActivePage.TabIndex+1].EditorMode then
    HwnD := (FindComponent('RichEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TRichEdit).Handle else
    HwnD := (FindComponent('SynEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TSynEdit).Handle;
  Pos.Y := Line;
  if not Dokumente[Documents.ActivePage.TabIndex+1].EditorMode then
  begin
    SendMessage(HwnD,EM_LINESCROLL,0,-1 * SendMessage(hWnD, EM_EXLINEFROMCHAR, 0, (FindComponent('RichEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TRichEdit).SelStart) );
    (FindComponent('RichEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TRichEdit).SelStart := SendMessage(hwnd,EM_LINEINDEX,Pos.Y -1,0);
  end else
  begin
    SendMessage(hwnd,EM_LINESCROLL,0,-1 * SendMessage(hwnd, EM_EXLINEFROMCHAR, 0, (FindComponent('SynEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TSynEdit).SelStart) );
    (FindComponent('SynEdit'+IntToStr(Documents.ActivePage.TabIndex+1)) as TSynEdit).SelStart := SendMessage(hwnd,EM_LINEINDEX,Pos.Y,0);
  end;
  SendMessage(hwnd,EM_SCROLLCARET,0,0);
  Sendmessage(hwnd,EM_LINESCROLL,0, Pos.Y - 1);
end;
kann mir jemand weiterhelfen?


mfG
mirage228

Alexander 30. Jul 2003 06:54

Re: "Gehe zu Zeile" in TRichEdit bzw. TSynEdit
 
:shock:
das Synedit hat doch (soweit ich weiß) CaretX und CaretY, womit du es auf eine gewünschte Zeikle setzen kannst, Warum so umständlich?


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz