Page 1 of 1

WindowX/Y negative when maximized

Posted: Fri Nov 01, 2013 12:35 am
by ozzie
I'm trying to get the 'true' visible WindowX and WindowY of a maximized window, but I get small negative values. In a test program (see below) the negative values are -3, but in my own program I get -8. Any idea why they are negative and is there a Windows system metric value or something that corresponds to these offsets?

For example, in the following:

Code: Select all

If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  Debug "(open) WindowX(0)=" + WindowX(0) + ", WindowY(0)=" + WindowY(0) + ", WindowWidth(0)=" + WindowWidth(0) + ", WindowHeight(0)=" + WindowHeight(0)
  
  Delay(2000)
  SetWindowState(0, #PB_Window_Maximize)
  Debug "(max) WindowX(0)=" + WindowX(0) + ", WindowY(0)=" + WindowY(0) + ", WindowWidth(0)=" + WindowWidth(0) + ", WindowHeight(0)=" + WindowHeight(0)
  
  Delay(2000)
  SetWindowState(0, #PB_Window_Normal)
  Debug "(normal) WindowX(0)=" + WindowX(0) + ", WindowY(0)=" + WindowY(0) + ", WindowWidth(0)=" + WindowWidth(0) + ", WindowHeight(0)=" + WindowHeight(0)
  
EndIf

I get the following debug messages:

Code: Select all

(open) WindowX(0)=100, WindowY(0)=200, WindowWidth(0)=195, WindowHeight(0)=260
(max) WindowX(0)=-3, WindowY(0)=-3, WindowWidth(0)=1366, WindowHeight(0)=716
(normal) WindowX(0)=100, WindowY(0)=200, WindowWidth(0)=195, WindowHeight(0)=260
My monitor size is 1366x768, but when the window is maximized WindowX(0) and WindowY(0) both return -3. Why don't they return 0?

Re: WindowX/Y negative when maximized

Posted: Fri Nov 01, 2013 12:48 am
by STARGÅTE
Use the parameter Mode:
http://purebasic.com/documentation/window/windowx.html
Mode (optional) The mode used to calculate the x position of the window. It can be one of the following value:
#PB_Window_FrameCoordinate: x position of the window, including borders (default).
#PB_Window_InnerCoordinate: x position of the window inner area (where gadget can be added), excluding borders.

Re: WindowX/Y negative when maximized

Posted: Fri Nov 01, 2013 12:52 am
by IdeasVacuum
It may also be related to how your Monitor is actually setup - the desktop itself could be slightly left and up, mine is slightly right and down.

Re: WindowX/Y negative when maximized

Posted: Fri Nov 01, 2013 1:29 am
by ozzie
STARGÅTE wrote:Use the parameter Mode:
http://purebasic.com/documentation/window/windowx.html
Thanks, but this gives different results again:

Code: Select all

(open) WindowX(0, #PB_Window_InnerCoordinate)=103, WindowY(0, #PB_Window_InnerCoordinate)=225, WindowWidth(0)=195, WindowHeight(0)=260
(max) WindowX(0, #PB_Window_InnerCoordinate)=0, WindowY(0, #PB_Window_InnerCoordinate)=22, WindowWidth(0)=1366, WindowHeight(0)=716
(normal) WindowX(0, #PB_Window_InnerCoordinate)=103, WindowY(0, #PB_Window_InnerCoordinate)=225, WindowWidth(0)=195, WindowHeight(0)=260
For the maximized window I do now get WindowX = 0 :D , but WindowY = 22 :( . For the normal window state, the window that was created at 100, 200 now returns 103, 225. Interesting that the X difference is 3, and my original WindowX(0) for the maximized window returned -3. So using #PB_Window_InnerCoordinate has added 3 to the Window X value, and 25 to the Window Y value. :?
IdeasVacuum wrote:It may also be related to how your Monitor is actually setup - the desktop itself could be slightly left and up, mine is slightly right and down.
That's possible, although I can't see how I can check or adjust that on the primary screen of my Toshiba laptop. But if the offset is due to how the monitor is set up, then the actual X and Y values returned may not matter for what I want to do.

Re: WindowX/Y negative when maximized

Posted: Fri Nov 01, 2013 2:25 am
by PB
> WindowX and WindowY of a maximized window, but I get small negative values

That's perfectly normal for Windows. The X and Y are indeed negative because
the window position, when maximized, is slightly off the top-left corner of the
monitor. Observe for yourself with a third-party app:

Image