The code below is meant to center the window where the mouse is, when the app is compiled with DPI awareness set.
But depending on where my mouse is when I run it, the window is either near the mouse (if the mouse is near the top left of the desktop), or not even shown (when the mouse is near the bottom right of the desktop). It's like DesktopMouseX() and DesktopMouseY() isn't getting where the mouse actually is?
The code works perfectly when my desktop's DPI is set to 100% (but not 150%), so how do I fix this? Thanks.
Code: Select all
; Enable DPI aware in Compiler Options.
ww=600
wh=100
OpenWindow(0,0,0,ww,wh,"Window should be centered on the mouse",#PB_Window_SystemMenu|#PB_Window_Invisible)
mx=DesktopMouseX()
my=DesktopMouseY()
ResizeWindow(0,mx-(ww/2),my-(wh/2),ww,wh)
HideWindow(0,0)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

