1. Miguel Leeuwe
  2. PowerBuilder
  3. Wednesday, 20 January 2021 15:50 PM UTC

Hi,

I'm having to apply vScroll and HScroll bars to a window on some big windows that we have which wouldn't fit an smaller screen resolutions. If the WorkSpaceHeight() is smaller than a certain values, I want to set the width and height of the window to it's 'original' value and show scrollbars.

As an example, I'm setting the width and height in the 'other' tabpage to 4000 and 2000.

The problem I'm having is obtaining the 'original' value from code:

Exported code PB 6.5:
global type w_genapp_sheet from Window
int X=672
int Y=264
int Width=4000
int Height=2000
boolean TitleBar=true
string Title="Sheet"

When running, the only difference I seem to get is in the height: a bit less, probably caused by the windows title occupying some space.

Exported code PB 12.6, PB 2017, PB2019:

global type w_genapp3_sheet1 from w_genapp3_basesheet
string tag = "Untitled for Sheet 1"
integer width = 4037
integer height = 2180

Then when I run the application, I'm getting these values:

Width 7333 and height 2548, pretty different from the specified values of 4000x2000.

If I set my 'windows scaling' to 125% I'm getting these values:

 

Is there any explanation for this? What I'm I missing?

Do I have to convert units to pixels and vice versa or something?

TIA

 

Accepted Answer
Arthur Hefti Accepted Answer Pending Moderation
  1. Wednesday, 20 January 2021 16:40 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Miguel

use the ClassDefinition Object to get the original value from the class. See sample below.

Regards
Arthur

classdefinition       lcd_Class
variabledefinition   ldc_Var
integer                 li_Counter, li_OrgWidth

lcd_Class= FindClassDefinition ( This.ClassName() )
FOR li_Counter = 1 TO UpperBound( lcd_Class.VariableList )
   ldc_Var = lcd_Class.VariableList[li_Counter]
   IF ldc_Var.Name = "width" THEN
      li_OrgWidth = ldc_Var.InitialValue
     EXIT
   END IF
NEXT

Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 January 2021 16:55 PM UTC
Maybe PFC resizing and adjusting is also responsible here for what "fits in the IDE with size 'X' and what fits when running, maybe after a re-scale of everything".
  1. Helpful
  1. René Ullrich
  2. Thursday, 21 January 2021 06:15 AM UTC
Hi Miguel,

there is a difference between "original" width and height values and the correct window size because of different window settings. I found out that options border, resizeable, clientedge, titlebar, palettewindow, scrollbars and menu makes the difference.

Here my code:

li_vars = UpperBound ( lcd_class.VariableList )

For li_v = 1 to li_vars

If lcd_class.VariableList[li_v].Name = "width" Then li_origwidth = Integer ( lcd_class.VariableList[li_v].InitialValue )

If lcd_class.VariableList[li_v].Name = "height" Then li_origheight = Integer ( lcd_class.VariableList[li_v].InitialValue )

If li_origwidth > 0 And li_origheight > 0 Then Exit

Next



IF this.Border THEN

li_origheight -= 8

li_origwidth -= 10

END IF

IF this.Resizable THEN

li_origheight -= 24

li_origwidth -= 27

END IF

IF this.Clientedge THEN

li_origheight -= 16

li_origwidth -= 21

END IF

IF this.Titlebar THEN

IF this.PaletteWindow THEN

li_origheight -= 12

ELSE

li_origheight -= 72

END IF

END IF

IF this.HScrollbar THEN

li_origheight -= 73

END IF

IF this.VScrollbar THEN

li_origwidth -= 64

END IF

IF IsValid (this.MenuId) THEN

li_origheight -= 76

END IF





  1. Helpful 1
  1. Miguel Leeuwe
  2. Thursday, 21 January 2021 09:46 AM UTC
Thank you very much René, I'll add them to my calculation.

Very useful!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 20 January 2021 17:28 PM UTC
  2. PowerBuilder
  3. # 1

To make it a bit clearer something seems to be off, I've made a small sample app and attached the GIF video of it in zipped format.

"weird.zip".

Thanks!

Attachments (1)
Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 January 2021 22:39 PM UTC
Hi Chris, still doesn't explain the difference in sizes expressed in pb units when simply changing the windows scaling or why in PB 6.5 I'm getting correct values.

Yes I also think it has something to do with whatever windows does to an opening window.

NOTE: The little app and the images I've shown, have all been made with a simple app which has NOT been made using PFCs.

Anyway, problem solved, I'll use ClassDefinition().

regards

  1. Helpful
  1. Arthur Hefti
  2. Thursday, 21 January 2021 05:21 AM UTC
Hi Miguel

The values describe the size within the border. You have to take the border thickness and the title into account.

With the external function: Function Int GetSystemMetrics( int nIndex ) Library "USER32"

You can get borders and title in pixels and do something like that:

li_BorderWidth = PixelsToUnits( GetSystemMetrics( 32 ), XPixelsToUnits! ) // SM_CXFRAME

li_BorderHeight = PixelsToUnits( GetSystemMetrics( 33 ), YPixelsToUnits! ) // SM_CYFRAME

li_Title = PixelsToUnits( GetSystemMetrics( 31 ), YPixelsToUnits! ) // SM_CYSIZE

Parent.Width = <Original Width by Class Definition> + li_BorderWidth

Parent.Height = <Original Height by Class Definition> - li_Title + 2 * li_BorderHeight

-> Or better do a resize with both values.

Regards

Arthur







  1. Helpful 1
  1. Miguel Leeuwe
  2. Thursday, 21 January 2021 10:08 AM UTC
Great Arthur! Thank you!
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 20 January 2021 16:57 PM UTC
  2. PowerBuilder
  3. # 2

Hi Miguel;

  Somehow that does not make sense as you are opening the Window Class as a "Sheet" thus, the size is controlled by a) The OpenSheet's arrangement option and b) the size of the current MDI window that you are attaching it to. Thus, the original "main" window size in the Class definition should not be a concern. Just my $0.02.

Regards ... Chris

Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 January 2021 17:03 PM UTC
Hi Chris,

Not sure if I totally understand what you are saying.

a) = Original!

b) how does the size of "current MDI window" (do you mean the size of the "frame"?), interfere with the sheet that I'm opening? (taking in account a) ).

regards
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 20 January 2021 17:09 PM UTC
Correct, the MDI Window == aka Frame

Considering all the other factors, like Window border size, Zoom, Font, Window Title height, etc - the original Main window class size seems irrelevant to me. I have scrollbars on Window and CVUO's all the time and don not need to do this to make scrolling and object appearances work OK. Can you explain better why you need to do this?
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 21 January 2021 01:27 AM UTC
Sorry for the late answer to your question "why I need to do this":

- we have an mdi application and our 'product manager' likes to assume that most people have 1920x1080 monitors

- to avoid problems with certain big mdi sheet windows on lower resolutions, I have to "stop" them from automatically being resized by pfc services and instead show them with their scroll bars. (in the resize event I'm setting them to that 'original' size and having the scrollbars everything can still be viewed).

- if I activate the scrollbars and first simply resize them to the size I'm getting in the pfc_preopen event, the height I'm getting is already too small to fit everything that has to fit on that window. Therefore I'm looking to find the 'original / IDE' height, assuming that at least that size would allow to show all objects correctly. (which btw will be my second problem to solve, as that's not true either). I know I'll have to make some adjustments due to toolbars, window titles, borders etc.

- in previous companies, we would make a decision on which minimum resolution to support and build all the windows using that size. That's not possible in this company and also screen resolutions nowadays are a much wider range than in the old days anyway.

- When you maximize a sheet window, it will automatically be adjusted to fit the size of the frame, so I also need a criteria to be able to decide to prevent that from happening when I'm showing the window with the scrollbars.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 20 January 2021 16:29 PM UTC
  2. PowerBuilder
  3. # 3

What option did you select for WindowState?  If you have maximized! it will change when opened.  Also you may have specified an option for the arrangeopen parameter of opensheet or opensheetwithparm.  If you specify Layered! it will open in full size instead of the specified size.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 January 2021 16:38 PM UTC
The disappointing thing here, is that the least windows 10 compatible version ( pb 6.5) does a much better job when it comes to this :(
  1. Helpful
  1. Kevin Ridley
  2. Wednesday, 20 January 2021 17:37 PM UTC
Wow, that is odd.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 21 January 2021 04:39 AM UTC
Conclusion:

Response windows do behave 'sort of' as expected.

MDI Sheet windows open with whichever width and height, even when specifying "Original!" in the opensheet.

To obtain the original width and height, Arthur's solution of using ClassDefinition works pretty well.

When you specify a size in the other attributes of a window for width and height, those values are not exactly what you find in the exported code. (they're close to the values but not the same (a bit higher, like 180+ which is probably the space occupied by the windows title and maybe also border widths play a role in the differences).

Thanks to all of you guys!

  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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.