Maustaste gedrückt halten - gelöst (auf viele Arten ;)
Verfasst: 20.04.2006 22:48
Wie kann ich abfragen, ob die Maustaste gedrückt ist (Also wie Mousebutton(x) unter DirectX, aber eben im Fenster, über einem Gadget)
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
GetAsyncKeyState_(#VK_LBUTTON)
Code: Alles auswählen
Repeat
a = GetAsyncKeyState_(#VK_LBUTTON)
If a <> b
Debug a
b=a
EndIf
ForEver
MSDN hat geschrieben:[...]If the most significant bit is set, the key is down[...]
das ist dann die -32767benpicco hat geschrieben:MSDN hat geschrieben:[...]If the most significant bit is set, the key is down[...]
Code: Alles auswählen
global old
procedure wndproc(hwnd,msg,wp,lp)
IF msg = #WM_LBUTTONDOWN
DEBUG "DOWN"
Endif
ProcedureReturn CallWindowProc_(old,hwnd,msg,wp,lp)
EndProcedure
*hWindow.long = OpenWindow(#PB_Any,#PB_Ignore,#PB_Ignore,400,400,"")
CreateGadgetList(*hWindow\l)
*con.long = ContainerGadget(#pb_any,10,10,200,200,#PB_Container_Single)
old = SetWindowLong_(*con\l,#GWL_WNDPROC,@wndproc())
Repeat
Until WaitWindowEvent() = #WM_CLOSE
Code: Alles auswählen
Repeat
wert=GetAsyncKeyState_(#VK_LBUTTON)
If PeekB(@wert+1)
Debug "DOWN"
EndIf
Delay(20)
Until 0
Code: Alles auswählen
Global old
Procedure wndproc(hwnd,msg,wp,lp)
If msg = #WM_LBUTTONDOWN
Debug "DOWN"
EndIf
ProcedureReturn CallWindowProc_(old,hwnd,msg,wp,lp)
EndProcedure
*hWindow.LONG = OpenWindow(#PB_Any,100,100,400,400,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
CreateGadgetList(*hWindow\l)
*con.LONG = ContainerGadget(#PB_Any,10,10,200,200,#PB_Container_Single)
old = SetWindowLong_(*con\l,#GWL_WNDPROC,@wndproc())
Repeat
Until WaitWindowEvent() = #WM_CLOSE
Code: Alles auswählen
global old.l
global lb.l
procedure wndproc(hwnd,msg,wp,lp)
IF msg = #WM_LBUTTONDOWN
lb = 1
Endif
IF msg = #WM_LBUTTONUP
lb = 0
Endif
ProcedureReturn CallWindowProc_(old,hwnd,msg,wp,lp)
EndProcedure
*hWindow.long = OpenWindow(#PB_Any,#PB_Ignore,#PB_Ignore,400,400,"")
CreateGadgetList(*hWindow\l)
*con.long = ContainerGadget(#pb_any,10,10,200,200,#PB_Container_Single)
old = SetWindowLong_(*con\l,#GWL_WNDPROC,@wndproc())
Repeat
debug lb
Until WaitWindowEvent(10) = #WM_CLOSE