[Win32] MouseX/Y auf beliebigem Gadget
Übersicht

![]() |
LunatixBetreff: [Win32] MouseX/Y auf beliebigem Gadget |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich glaub, das könnte manchen ganz nützlich sein:
Code: [AUSKLAPPEN] ?Win32
Extern "Win32" Function GetCursorPos_(lpPoint:Byte Ptr) = "GetCursorPos@4" Function ScreenToClient(hWnd:Int,lpPoint:Byte Ptr) Function GetWindowRect:Int(hWnd:Int,rect:Byte Ptr) End Extern Function posx:Int(gadget:TGadget) Local clRect:Int[4] GetWindowRect(QueryGadget(gadget,1),clRect) Return clRect[0] End Function Function posy:Int(gadget:TGadget) Local clRect:Int[4] GetWindowRect(QueryGadget(gadget,1),clRect) Return clRect[1] End Function Function GadgetMouseX:Int(gadget:TGadget) Local Coord:Int[2] GetCursorPos_(Coord) Return Coord[0]-posx(gadget) End Function Function GadgetMouseY:Int(gadget:TGadget) Local Coord:Int[2] GetCursorPos_(Coord) Return Coord[1]-posy(gadget) End Function Bei "ScreenToClient" der Pararmeter "hWnd" muss die Id eines Windows tragen (zur info: auch ein Panel, eien textarea etc. ist ein Window). Dies geht zum Beispiel mit QueryGadget. So kann man auch ohne Canvas die Maus positionen abfragen ![]() [Edit1] Nun, hab selbst gemerkt, so ganz gehts nicht... [Edit2] So, nun funktionierts. Mfg |
||
[size=9]Pro|gram|mier|er: Ein Organismus, der Koffein in Software umwandelt.
Geben Sie eine beliebige 11-stellige Primzahl ein, um fortzusetzen... |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group