Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Memo.CaretPos in Pixeln ? (https://www.delphipraxis.net/69879-memo-caretpos-pixeln.html)

lizardking 21. Mai 2006 17:37


Memo.CaretPos in Pixeln ?
 
Moin ;-)

Meine Delphi-Hilfe (D7) sagt mir Folgendes:

Zitat:

Use CaretPos to determine the coordinates of the cursor. CaretPos defines a pixel location onscreen, with the origin in the top left corner of the memo.
Keine Ahnung warum, aber bei liefert die Property ganz klar Zeile und Spalte, an der der Cursor steht, aber definitiv keine Position in Pixeln. Ich moechte auf eine bestimmte Tastenkombination eine Combo-Box an der aktuellen Cursorposition erscheinen lassen. Aber wie berechne ich die genauen Koordinaten ?

Wo liegt mein Denkfehler ?

Gruesse,

Lizzy

marabu 21. Mai 2006 19:10

Re: Memo.CaretPos in Pixeln ?
 
Moin Lizzy,

deine Delphi Hilfe lügt - soviel zur Qualitätskontrolle bei Hilfe-Dateien. Hier ein Stück Code aus einem Demo-Projekt, in welchem ich allerdings eine ListBox verwende:

Delphi-Quellcode:
procedure TDemoForm.MemoKeyPress(Sender: TObject; var Key: Char);
var
  pt: TPoint;
begin
  if Key <> '.' then
    Exit;
  GetCaretPos(pt);
  with Sender as TMemo do
    pt := ClientToParent(pt);
  with ListBox do
  begin
    Left := pt.X + 6;
    Top := pt.Y - Memo.Font.Height * 6 div 5;
    ItemIndex := 0;
    Visible := true;
    SetFocus;
  end;
end;
Grüße vom marabu

lizardking 21. Mai 2006 19:31

Re: Memo.CaretPos in Pixeln ?
 
Zitat:

Zitat von marabu
Moin Lizzy,
deine Delphi Hilfe lügt - soviel zur Qualitätskontrolle bei Hilfe-Dateien. Hier ein Stück Code aus einem Demo-Projekt, in welchem ich allerdings eine ListBox verwende:
...

Urgh.. Danke ! :) So funkioniert es. Da haette ich ja ewig suchen koennen.

Dankende Gruesse,

Lizzy

P.S.: Ich wollte die Frage jetzt irgendwie als beantwortet markieren. Aber wie mach ich das ? *schaem*


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:51 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