1. Christopher Craft
  2. PowerBuilder
  3. Thursday, 27 January 2022 22:06 PM UTC

Just wondering why the X and Y Position of a maximized Frame would be a negative number (ie. -37 and -32) instead of it being zero?  Since I am saving the position of the frame in order to restore it I want to make sure that I am not missing anything.  I thought if the X position was negative then it essentially means it is on a secondary monitor (the one to the left of the primary).

I assume it is the border of the frame...

Chris Craft

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 05:24 AM UTC
  2. PowerBuilder
  3. # Permalink

That IS a good question!

I experimented with this a little tonight, adding a menu item to a test app's frame menu to issue a message box that displays the frame window's X, Y position, Width and Height in PBU's and in pixels.

When the frame is maximized, I get these values:

I moved the message box prior to taking the snapshot to be able to keep the snapshot small. My monitor's resolution is 1920 x 1080 pixels. The Windows task bar occupies 40 pixels along the bottom of the screen, making the usable screen area 1920 x 1040.

Note the reported size of the maximized window is 2 x 8 = 16 pixels wider and higher than the usable area, or an extra 8 pixels on all sides.

Then the script changes the WindowState to Normal!, moves the window to -8, -8 (pixels, converted to PBU's) and resizes the window to 1936 x 1056 (pixels, converted to PBU's)... the same values as reported when the window is maximized, then the properties are displayed once more in a message box:

It's a little difficult to discern from these snapshots, but even though the window's reported position and size are the same, it is being rendered a little differently (note the X-position of the app's icon and how it aligns differently over the menu item "File"). You can't see it with these images displayed against a white background, but in the second image the icon and window title are a few pixels closer to the top edge of the screen.

What does it mean? I'm not sure. I'm guessing that PB assigns these property values as a "special case" when the window is maximized. Therefore, I would be hesitant to use these properties to "restore" a window if it were maximized. I would instead set the WindowState property to Maximized! and use Move & Resize methods only when the WindowState = Normal!, or keep track of the windows position & size PRIOR to it being maximized/minimized and save those values, then restore these values and set the WindowState to Maximized!

I guess it depends how nit-picky you want to be with the window save/restore functionality. Still, a very interesting issue!

Comment
  1. John Fauss
  2. Monday, 31 January 2022 01:24 AM UTC
Chris C, - Yes, you are over-engineering it. However, to answer your question: (1) You realize that negative coordinates may indeed be "valid", depending on how multiple monitors are configured. Refer to the following URL:

https://docs.microsoft.com/en-us/windows/win32/gdi/the-virtual-screen

(2) Use MonitorFromPoint API function and a WinAPI POINT structure (comprised of two Long's) with the desired X,Y coordinates (not negative values, as there will not be on the desired monitor). Use MONITOR_DEFAULTTONULL (which is defined as zero) fir the dwFlags argument.

(3) If the specified point does not reside on any current monitor, the function will return NULL (this is a Windows API NULL, which is zero, not a PB Null). If the point does exist in any monitor, the function will return the HMONITOR (Handle to the Monitor), which can be used to identify the particular monitor.
  1. Helpful
  1. Christopher Craft
  2. Wednesday, 2 February 2022 00:14 AM UTC
Chris P...That is funny - I think most of our customers have 3 minimum! We even have some that have 6 huge monitors in a sales office - 3 top and 3 bottom that display certain things for all the sales people.



Thank you all for your input on this. Couldn't do it without you!



Chris
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 2 February 2022 00:18 AM UTC
Wow ... Your company sounds advanced IT & budget wise. Most PB user companies & government agencies that I know of have a hard time just getting 2 monitors .... LOL
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 27 January 2022 22:35 PM UTC
  2. PowerBuilder
  3. # 1

Hi Chris;

  FWIW: I can conform that is what my STD framework captures as well but, I have no idea why the negative numbers. A great question!

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.