1. Yiannis Papadomichelakis
  2. Beta Testing
  3. Thursday, 13 February 2020 14:52 PM UTC

Hi Powerbuilder developers!

I want to create a popup that will start from the same position as the application frame window.

I open the popup window and then change it's X coordinate to match the MDI frame X position.

In the attached picture you will see the result of this process. Both windows have the same X position, however it's obvious that they are placed in a different position.

I just want the popup window to appear like a panel, inside the MDI frame window, so I need it to begin at the edge of the MDI.

Any ideas?

 

 

Attachments (1)
Accepted Answer
Brad Wery Accepted Answer Pending Moderation
  1. Sunday, 16 February 2020 04:07 AM UTC
  2. Beta Testing
  3. # Permalink

Looks like you need to account for the windows border size. Look up the GetSystemMetrics win API function. You'll want to pass in SM_CXBORDER to get the size of the left border in pixels.

GetSystemMetrics (SM_CXBORDER)

You'll then need to convert that to PB Units.

It looks like the border shadow is missing when themes are enabled. You'll have to account for that as well.

You'll run into other issues with multiple monitors as well.

If you need a panel in your MDI window, why not just use a userobject?

Comment
  1. Yiannis Papadomichelakis
  2. Monday, 17 February 2020 10:21 AM UTC
Unfortunately, that was now the case.

GetSystemMetrics (SM_CXBORDER) returned only 1 pixel, which is a lot less than the difference between the frame and the popup window.

On the other hand, using win.WorkspaceX() - win.X made the difference and eliminated the difference between the frame and the popup window. That worked well in my simple test application, but it's of no use in my real application, since it contains a user object on the MDIFrame, and in that cases WorkSpaceX() returns always 0...
  1. Helpful
  1. Brad Wery
  2. Monday, 17 February 2020 13:37 PM UTC
Sorry, should have said to use SM_CXSIZEFRAME instead. Just going from memory.
  1. Helpful
  1. Yiannis Papadomichelakis
  2. Tuesday, 18 February 2020 10:11 AM UTC
Thanks Brad, that did work!
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 15:01 PM UTC
  2. Beta Testing
  3. # 1

Hi Yannis,

if you want the popup inside the MDI window maybe it helps you to start from mdi_1.X of the frame window?

HTH,

René

Comment
  1. Yiannis Papadomichelakis
  2. Thursday, 13 February 2020 15:41 PM UTC
mdi_1 coordinates are relative to MDI frame window, while popup is relative to screen.

So, when I open that popup window, mdi_1.x = 0....
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 15:47 PM UTC
  2. Beta Testing
  3. # 2

Hi Yiannis,

I'm encapsulating "UI positioning" logic into an NVO inspired by a similar question.

Stay tuned if you can wait a few days. When centering a window relative to a control (here MDI_1) inside another window you need to involve both that control's relative position and its parentwindow's position. Latter includes monitor selection via its X, Y coordinates.

HTH /Michael

Comment
  1. Yiannis Papadomichelakis
  2. Thursday, 13 February 2020 16:00 PM UTC
Thank you!

Of course I will wait. I am very curious about this one....!

  1. Helpful
  1. Michael Kramer
  2. Thursday, 13 February 2020 16:13 PM UTC
Thanks. My own setup is a Surface Laptop with its 3:2 ratio + a 27" 4K monitor, so each monitor has different dimensions and perhaps even different PBUs per pixel ratio. So I can battle test even at home pc.
  1. Helpful
There are no comments made yet.
Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 15:59 PM UTC
  2. Beta Testing
  3. # 3

I just made another interesting "discovery".

If I try to resize the popup using mdi width, then my popup is quite bigger than the original mdi!

 

 

 

Attachments (1)
Comment
There are no comments made yet.
Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 17:17 PM UTC
  2. Beta Testing
  3. # 4

Another discovery!

When a theme is selected, the popup is displayed in the proper position!

Correct me if I am wrong, but this seems to be a bug...!

 

 

 

Attachments (1)
Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 18:23 PM UTC
  2. Beta Testing
  3. # 5

Hi Yainnis;

   The POP-UP Menu feature is working great for me in 2019 and 2019 R2.

FYI: Example from STD Framework's OrderEntry App running on R2 beta ...

Probably your code (just a guess)

Regards ... Chris

Comment
There are no comments made yet.
Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 18:46 PM UTC
  2. Beta Testing
  3. # 6

Hi Chris!

This code :

open(w_mdi);
open(w_popup);
w_popup.x = w_mdi.x;
w_popup.y = w_mdi.y;

 

Produces the following result when no theme is selected.

and this when a theme is selected:

 

I don't think that it has anything to do with my code (only 4 lines!)

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 14 February 2020 19:49 PM UTC
Hmmm ... when I tested my code changes on your example test case, the window borders now seemed to be "spot on".
  1. Helpful
  1. Yiannis Papadomichelakis
  2. Friday, 14 February 2020 19:59 PM UTC
...which means that something is affecting it's behaviour?

Any ideas about that?

Unfortunately (!) I left office and I cannot make any more tests. I will try some more cases on Monday morning and I will come back...
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 14 February 2020 20:30 PM UTC
Do you run your MS-Windows PC > 100% display mode as set in the Control Panel in the "Ease of Access" section?
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 19:16 PM UTC
  2. Beta Testing
  3. # 7

Ahhh .. thought you were talking about a Pop-up menu not a Pop-up Window.
Hmm .. if this is repeatable, then please open a Support Ticket.

FYI:  Pop-Up window test worked OK for me ...

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 21:01 PM UTC
  2. Beta Testing
  3. # 8

Hi Yiannis, on your popup ending out-of-place.

For all window types - EXCEPT CHILD:

  • <X, Y> is outer top-left corner of the window relative to monitor (incl. which monitor in multi-monitor setup).
  • <WorkSpaceX( ), WorkspaceY( )> is inner top-left corner of window relative to monitor.
    • This adjusts for window border, titlebar, menubar, etc.
    • For non-MDI frame windows this also adjusts for toolbar

For MDI frames in particular:

  • <MDI_1.X, MDI_1.Y> is MDI client area's top-left corner within the workspace adjusted for MDI toolbar

For CHILD windows in particular

  • <X, Y> is outer top-left corner of the window relative to its "parent" window.
    • <0, 0> = top-left corner inside "parent" window's workarea.

Here follows code to move any window type to top-left corner or the practical work area of a previously defined "origin" window. When that origin is MDI frame the code coordinate logic also needs reference to the built-in MDI client area inside that MDI frame.

// Instance variables
Window    iw_origin
Boolean   ib_isMDI
MDIClient imdi_area
// - - - -
FUNCTION of_SnapTopLeft(window aw_object)
long newX, newY

if aw_object.WindowType <> Child! then
   newX = iw_origin.WorkSpaceX( )
   newY = iw_origin.WorkSpaceX( )
end if

if ib_isMDI then
   newX += imdi_area.X
   newY += imdi_area.Y
end if

aw_object.Move(newX, newY)
END FUNCTION
Comment
  1. Michael Kramer
  2. Tuesday, 18 February 2020 18:18 PM UTC
Hi Chris, problem on custom MDI frame => WorkspaceX( ) and WorkspaceY( ) return zero instead of position of window's interior.

All Workspace functions work fine across all window types under all circumstances - EXCEPT MDI frames having 2+ controls. When I add CommandButton or RibbonBar inside my MDI Frame's workspace and resize MDI_1 explicitly, the workspace functions tell me that window frame + title bar + menu bar have a combined height of negative 1400. My eyes tell me that is 1600+ PBU short of correct value.

Today I completed NVO calculating coordinates correctly despite known issues without calling Win APIs - now documenting that NVO before publishing code with article as docs.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 18 February 2020 19:58 PM UTC
FYI: I have noticed that when you add & run a RibbonBar control within an MDI Frame, the PBVM changes and wants to now control the MDI_1 area.
  1. Helpful
  1. Michael Kramer
  2. Tuesday, 18 February 2020 20:23 PM UTC
Yup, New combos hide unexpected features -- I call SetRredraw(false) and wish for no screen updates -- but ApplyTheme(...) refreshes window immediately.

I decided better focus on looking for new job since R2 beta is officially closed,
  1. Helpful
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.