Delphi-PRAXiS
Seite 1 von 2  1 2      

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 Richedit, Curet an X,Y Pos setzten (https://www.delphipraxis.net/49507-richedit-curet-x-y-pos-setzten.html)

TPeterT 12. Jul 2005 13:46


Richedit, Curet an X,Y Pos setzten
 
Hallo!
Wie kann ich in einem RichEdit den Curet an eine bestimmte Psoition (X,Y) setzten?

Danke und liebe Grüsse
Peter

sniper_w 12. Jul 2005 13:53

Re: Richedit, Curet an X,Y Pos setzten
 
Zitat:

The SetCaretPos function moves the caret to the specified coordinates. If the window that owns the caret was created with the CS_OWNDC class style, then the specified coordinates are subject to the mapping mode of the device context associated with that window.

BOOL SetCaretPos(

int X, // horizontal position
int Y // vertical position
);


Parameters

X

Specifies the new x-coordinate of the caret.

Y

Specifies the new y-coordinate of the caret.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

SetCaretPos moves the caret whether or not the caret is hidden.
The caret is a shared resource; there is only one caret in the system. A window can set the caret position only if it owns the caret.

TPeterT 12. Jul 2005 14:44

Re: Richedit, Curet an X,Y Pos setzten
 
Hi!
Danke für die Antwort.
Leider weiss ich nun trotzdem nicht weiter...
Wie ist das zum einbauen udn wo?

Danke und liebe Grüsse

Flocke 12. Jul 2005 14:47

Re: Richedit, Curet an X,Y Pos setzten
 
Meinst du mit X, Y Bildschirmkoordinaten oder Zeile, Spalte?

TPeterT 12. Jul 2005 14:49

Re: Richedit, Curet an X,Y Pos setzten
 
Hallo!
Bildschirmkordinaten..

Flocke 12. Jul 2005 14:53

Re: Richedit, Curet an X,Y Pos setzten
 
Dann mit SetCaretPos(X, Y) so wie sniper_w schon geschrieben hat.

Wird dir aber nicht viel nützen, weil das RichEdit das Ding wieder auf die aktuelle Eingabeposition zurücksetzen wird.

TPeterT 12. Jul 2005 14:55

Re: Richedit, Curet an X,Y Pos setzten
 
hi!
ja.. stimmt.. funktioniert nicht wirklich (gar nicht)...
es geht darum, dass ich aus einem Grid mittels Drag&Drop einen String in das RichEdit ziehen möchte...

Marphy 12. Jul 2005 15:10

Re: Richedit, Curet an X,Y Pos setzten
 
Liste der Anhänge anzeigen (Anzahl: 1)
Projekt im Anhang...

TPeterT 13. Jul 2005 09:24

Re: Richedit, Curet an X,Y Pos setzten
 
Hi!
Danke für das Projekt!
Der Curet wird zwar reingesetzt, aber ich müsste genau an der Stelle dann einen Text in das RichEdit Feld einfügen (Editor.SelText := 'KeyWord';)
Wird aber an einer ganz anderen Stelle eingefügt.. woran kann das liegen?
Danke und liebe Grüsse

Flocke 13. Jul 2005 09:33

Re: Richedit, Curet an X,Y Pos setzten
 
Hmmmm...

und wenn du einfach ein WM_LBUTTONDOWN, WM_LBUTTONUP mit den Koordinaten an das RichEdit-Control schickst? Dann sollte es den Eingabecursor doch so setzen, als wenn du an die Stelle mit der Maus geklickt hättest.

[Update]

Gibt eine bessere Methode, einen Moment...

Hier:

Delphi-Quellcode:
procedure SetRichEditCaret(RichEdit: TCustomRichEdit; X, Y: Integer);
var
  pt: TPoint;
begin
  pt.x := X;
  pt.y := Y;
  RichEdit.SelStart := SendMessage(RichEdit.Handle, EM_CHARFROMPOS, 0, Integer(@pt));
end;
Nicht ausprobiert!


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:16 Uhr.
Seite 1 von 2  1 2      

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