Autor Beitrag
Theophilus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16


D6
BeitragVerfasst: So 10.10.04 00:50 
Ich möchte in einem Formular, das über meinem Hauptformular erscheint, den Cursor automatisch über die sehr wahrscheinlich zu drückende Schaltfläche positionieren (mit SetCursorPos). Wenn ich die gewünschte Position mit den Fensterkoordinaten berechne, erscheint der Cursor zu hoch, offensichtlich fehlen die Breiten der beiden Formular-Titelleisten. Kennt jemand eine Möglichkeit, die absolute Bildschirmposition einer Schaltfläche (oder eines beliebigen sichtbaren Objektes) zu ermitteln?

Ciao
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 10.10.04 01:48 
ClientToScreen \ ScreenToClient :D

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Theophilus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16


D6
BeitragVerfasst: So 10.10.04 09:37 
Danke für den flotten Hinweis. Meine ersten Versuche damit sind aber gescheitert. So probierte ich z.B. folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  XY.X := btnOK.Width  div 2;
  XY.Y := btnOK.Height div 2;
  XY   := btnOK.ClientToScreen(XY);
  SetCursorPos( XY.X, XY.Y );


Die neue Cursor-Position hatte nichts mit der Schaltfläche zu tun (und variierte mit der Position meines Hauptfensters am Bildschirm, konnte sogar außerhalb des Hauptfensters liegen!).

Ciao