it's rather silly that one has to resort to winapi to retrieve a mousepointer location
to keep old code functioning i would like to suggest to add these two commands that return the coordinates of the mouse in the client area
see also viewtopic.php?t=11233
clientmousex() clientmousey()
clientmousex() clientmousey()
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: clientmousex() clientmousey()
At the moment the WindowX() and WindowY() functions are total useless, because they start outside the client-area (the gadget has a diffrent zero-point). And the problem: there is no PB-only way to find out, how big the "title-bar" of a window is, so nobody can translate the points.
It would be nice to change the WindowX() and WindowY() to client-Koordinates.
It would be nice to change the WindowX() and WindowY() to client-Koordinates.
Code: Select all
Id=GadgetID(gadget)
GetCursorPos_(mouse.POINT)
MapWindowPoints_(0,Id,mouse,1)
euh, gpi, you are refering to windowmousex() and windowmousey()? correct? 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
then you stand corrected 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Code: Select all
;
; by Danilo, 30.04.2003 - german forum
;
; modified 11.12.2003
;
Procedure WindowClientMouseX(win) ; added param, 11.12.03
; Returns X-Position of MouseCursor
; in the current window's client area
; or -1 if mouse cursor isnt in this area.
GetCursorPos_(mouse.POINT)
ScreenToClient_(WindowID(win),mouse)
GetClientRect_(WindowID(win),rect.RECT)
If mouse\x < 0 Or mouse\x > rect\right
ProcedureReturn -1
ElseIf mouse\y < 0 Or mouse\y > rect\bottom ; added 11.12.03
ProcedureReturn - 1
Else
ProcedureReturn mouse\x
EndIf
EndProcedure
Procedure WindowClientMouseY(win) ; added param, 11.12.03
; Returns Y-Position of MouseCursor
; in the current window's client area
; or -1 if mouse cursor isnt in this area.
GetCursorPos_(mouse.POINT)
ScreenToClient_(WindowID(win),mouse)
GetClientRect_(WindowID(win),rect.RECT)
If mouse\y < 0 Or mouse\y > rect\bottom
ProcedureReturn -1
ElseIf mouse\x < 0 Or mouse\x > rect\right ; added 11.12.03
ProcedureReturn - 1
Else
ProcedureReturn mouse\y
EndIf
EndProcedure
OpenWindow(1,200,200,300,300,#PB_Window_SystemMenu,"MousePos")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Default
StartDrawing(WindowOutput())
Box(0,0,300,300,0)
DrawingMode(1):FrontColor($FF,$FF,$00)
Locate(30,100)
DrawText("MouseX: "+Str( WindowClientMouseX(1) ))
Locate(30,120)
DrawText("MouseY: "+Str( WindowClientMouseY(1) ))
StopDrawing()
EndSelect
ForEver
but looks like he forgot it...