06-05-2024, 11:33 PM
(06-05-2024, 11:21 PM)TerryRitchie Wrote: Here's some tinkering code I've been working on. When the _DELAY is removed you can see you get different results.
Code: (Select All)$RESIZE:ON
OPTION _EXPLICIT
TYPE TYPE_IPOINT
x AS LONG
y AS LONG
END TYPE
TYPE TYPE_RECT
left AS LONG
top AS LONG
right AS LONG
bottom AS LONG
END TYPE
DECLARE DYNAMIC LIBRARY "user32"
'get current mouse x/y position
'http://allapi.mentalis.org/apilist/GetCursorPos.shtml
FUNCTION GetCursorPos% (lpPoint AS TYPE_IPOINT)
'system window metrics in pixels
'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
FUNCTION GetSystemMetrics% (BYVAL nIndex AS INTEGER)
FUNCTION GetWindowRect% (BYVAL hWnd AS _INTEGER64, lpRect AS TYPE_RECT) ' returns desktop coordinates (_SCREENX, _SCREENY)-(x2, y2)
FUNCTION GetClientRect% (BYVAL hWnd AS _INTEGER64, lpRect AS TYPE_RECT) ' returns (0, 0)-(_WIDTH, _HEIGHT)
FUNCTION IsZoomed% (BYVAL hWnd AS _INTEGER64) ' reports a maximized window (_FULLSCREEN)
END DECLARE
TYPE TYPE_PROGRAMWINDOW
HWND AS _INTEGER64 ' operating system window handle (_WINDOWHANDLE)
Main AS TYPE_RECT ' window coordinates (absolute to desktop)
Client AS TYPE_RECT ' client coordinates (absolute to desktop)
Caption AS TYPE_RECT ' caption coordinates (absolute to desktop)
Border AS INTEGER ' border width/height
MainWidth AS INTEGER
MainHeight AS INTEGER
ClientWidth AS INTEGER
ClientHeight AS INTEGER
CaptionWidth AS INTEGER
CaptionHeight AS INTEGER ' height of caption
END TYPE
DIM MOUSE_Window AS TYPE_PROGRAMWINDOW
DIM HWND AS _INTEGER64
DIM rect AS TYPE_RECT
DIM Test AS INTEGER
SCREEN _NEWIMAGE(640, 480, 32)
_DELAY .25
HWND = _WINDOWHANDLE
Test = GetWindowRect(HWND, MOUSE_Window.Main) ' get program window desktop coordinates
MOUSE_Window.MainWidth = MOUSE_Window.Main.right - MOUSE_Window.Main.left ' calculate program window width
MOUSE_Window.MainHeight = MOUSE_Window.Main.bottom - MOUSE_Window.Main.top ' calculate program window height
MOUSE_Window.ClientWidth = _WIDTH
MOUSE_Window.ClientHeight = _HEIGHT
MOUSE_Window.Border = (MOUSE_Window.MainWidth - _WIDTH) \ 2
MOUSE_Window.CaptionWidth = _WIDTH
MOUSE_Window.CaptionHeight = MOUSE_Window.MainHeight - _HEIGHT - MOUSE_Window.Border * 2
MOUSE_Window.Client.left = MOUSE_Window.Main.left + MOUSE_Window.Border
MOUSE_Window.Client.top = MOUSE_Window.Main.top + MOUSE_Window.Border + MOUSE_Window.CaptionHeight
PRINT " Left :"; MOUSE_Window.Main.left
PRINT " Top :"; MOUSE_Window.Main.top
PRINT " Right :"; MOUSE_Window.Main.right
PRINT " Bottom :"; MOUSE_Window.Main.bottom
PRINT " Main Width :"; MOUSE_Window.MainWidth
PRINT " Main Height :"; MOUSE_Window.MainHeight
PRINT " Client Width :"; MOUSE_Window.ClientWidth
PRINT " Client Height :"; MOUSE_Window.ClientHeight
PRINT " Caption Width :"; MOUSE_Window.CaptionWidth
PRINT " Caption Height :"; MOUSE_Window.CaptionHeight
PRINT " Border Size :"; MOUSE_Window.Border
PRINT " Client Left :"; MOUSE_Window.Client.left
PRINT " Client Top :"; MOUSE_Window.Client.top
You certain this is with v3.13? Can you do a quick "HELP/ABOUT" and get the version number there?
I can't reproduce any issues with this -- at least not on my laptop.
