Bug or Feature: WindowX() / WindowY()
Bug or Feature: WindowX() / WindowY()
I noticed that WindowX() and WindowY() returning negative values if window is minimized. Is this a Windows-Only thingie or cross-over behavior?
Is there a way to get the original window-dimensions even if the window is minimized?
Is there a way to get the original window-dimensions even if the window is minimized?
Tranquil
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Code: Select all
Procedure.l sp_GetDefaultRect(hwnd, *rc.RECT)
GetWindowPlacement_(hwnd, @wp.WINDOWPLACEMENT)
*rc\left = wp\rcNormalPosition\left
*rc\top = wp\rcNormalPosition\top
*rc\right = wp\rcNormalPosition\right
*rc\bottom = wp\rcNormalPosition\bottom
ProcedureReturn *rc
EndProcedure
Procedure.l EnumWindowsProc(hwnd, lParam)
If hwnd
If IsWindowVisible_(hwnd)
st$ = Space(256)
GetWindowText_(hwnd, @st$, 256)
If st$
sp_GetDefaultRect(hwnd, @winRc.RECT)
AddGadgetItem(1, -1, st$ + Chr(10) + Str(winRc\left) + Chr(10) + Str(winRc\top) + Chr(10) + Str(winRc\right) + Chr(10) + Str(winRc\bottom) + Chr(10) + Str(winRc\right - winRc\left) + Chr(10) + Str(winRc\bottom - winRc\top))
EndIf
EndIf
result = #True
Else
result = #False
EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(0, 10, 10, 800, 500, "Sparked Window Rect", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
TextGadget(0, 10, 10, 780, 30, "These values indicate the default normal (non-maximized) coordinates of each window.")
ListIconGadget(1, 10, 50, 780, 440, "Window", 480, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(1, 1, "Left", 50)
AddGadgetColumn(1, 2, "Top", 50)
AddGadgetColumn(1, 3, "Right", 50)
AddGadgetColumn(1, 4, "Bottom", 50)
AddGadgetColumn(1, 5, "Width", 50)
AddGadgetColumn(1, 6, "Height", 50)
EnumWindows_(@EnumWindowsProc(), 0)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
I tested your code on my system. For one particular program I received these values:
The program runs from the system tray (a.k.a. System notification area) . So it would seem that negative coordinates are still possible. I was just wondering how to interpret this information. Or to put it another way, when would the cordinates be negative for a program's window (using the code you provided)?
Code: Select all
Left:-1476,Top:-1580,Right:-1020,Bottom:-1346,Width:456,Height:234
I have a dual monitor setup, with my main monitor(1) on the right and secondary monitor(2) on the left. This causes any and all windows on monitor 2 to have negative left/right values.
Another thought that comes to mind is maybe the developer is using it as a way to hide the window.
Using the hwnd from the EnumWindowsProc() in my code, maybe you can move the window into view with MoveWindow_(hwnd, 0, 0, width, height)?
Another thought that comes to mind is maybe the developer is using it as a way to hide the window.
Using the hwnd from the EnumWindowsProc() in my code, maybe you can move the window into view with MoveWindow_(hwnd, 0, 0, width, height)?
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Words would help explain what you mean but I'll take a stab at it anyway.Mistrel wrote::roll:The program runs from the system tray (a.k.a. System notification area) .
The program does display a window upon request. When the window is displayed it has the dimensions that were reported by Sparkie's code. I also ran Sparkie's code after displaying the window and it still reported the co-ordinates as negative values. I had naively thought if I displayed the window it would report positive values instead, which it didn't.
@Sparkie: I am using only a single monitor setup. I'll get back to you on what happens by attempting to move the window into positive territory.
@Sparkie: I have tried your suggestion and here are my results.Sparkie wrote:Another thought that comes to mind is maybe the developer is using it as a way to hide the window.
Using the hwnd from the EnumWindowsProc() in my code, maybe you can move the window into view with MoveWindow_(hwnd, 0, 0, width, height)?
The window that became visible for the program in question was it's "About" window. When that menu option is selected for the program it adds 2048 to the x,y co-ordinates to show the window then adds a few buttons to it as well. It subtracts 2048 from the x,y co-ordinates to hide it again.

So your first idea seems to be correct, that it is being hidden by making it's coordinates negative.
Thanks for your input.
