@Saki
I agree wholeheartedly..
Here's another example: Simple window and canvas (WindowMouseX/Y)
Edit:
For it to work you must use: DesktopUnscaledX(WindowMouseX(0)) and the same for Y.
I just find it extremely tedious to remember to do it like this..
Anyway...I do not expect an automated solution and know it's an annoying Windows feature
which we must live with.
Take the feature request as a rant to let off some steam.
Code: Select all
;Switch dpi awareness on/off
Structure Centerpos
x.i
y.i
EndStructure
Structure Positions
c.Centerpos
w.f
h.f
EndStructure
Structure Object
id.i
pic.i
pos.Positions
EndStructure
Global NewList o.Object()
Declare.i InsertObject()
OpenWindow(0, 0, 0, 1024, 768, "Test", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
BindEvent(#PB_Event_LeftClick, @InsertObject())
Repeat
ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow
Procedure.i InsertObject()
AddElement(o())
o()\pos\c\x = WindowMouseX(0)
o()\pos\c\y = WindowMouseY(0)
o()\pos\w = 200
o()\pos\h = 40
o()\pic = CreateImage(#PB_Any, 512, 128)
StartDrawing(ImageOutput(o()\pic))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor(0) : BackColor($AAAAAA)
LinearGradient(0, 0, OutputWidth(), OutputHeight())
Box(0, 0, OutputWidth(), OutputHeight())
DrawingMode(#PB_2DDrawing_Default)
Box(4, 4, OutputWidth()-8, OutputHeight()-8, RGB(Random(255, 20), Random(255, 20), Random(255,20)))
StopDrawing()
o()\id = CanvasGadget(#PB_Any, o()\pos\c\x - o()\pos\w / 2, o()\pos\c\y - o()\pos\h / 2, o()\pos\w, o()\pos\h)
StartDrawing(CanvasOutput(o()\id))
DrawImage(ImageID(o()\pic), 0, 0, OutputWidth(), OutputHeight())
StopDrawing()
EndProcedure