1. kevin kevin rowe
  2. PowerBuilder
  3. Thursday, 23 November 2023 10:12 AM UTC

I have an ancestor window with a general move and resize everything event in it that happily moves all controls as you resize the window that inherits it.

The inheritor runs super::resize(...) to actually run the move/grow.

When I try an implement a min/max size on the window it does not work.

In the resize event there is a set instance variable ii_base_minheight and it is set by an accessor function in the inherited window to (this.height)

and another that is set on open ii_win_original_height = this.height

so that the window should be able to grow but not shrink from original size

in the resize event a decimal is generated

ld_vconv = newheight / il_win_original_height

This factor is used to resize and move all controls, and it works.

so for all controls, using the decimal

ld_work = control.y * ld_vconv  

control.y = ld_work

etc.

However, when I do this in resize

 

if (ii_base_minheight <> 0) and ( newheight < ii_base_minheight) then
    newheight = ii_base_minheight
end if

ld_work = this.height * ld_vconv
this.height = ld_work 

I can see the variables being set but the window height is still reduced to below the minimum. `

Can this be done?

Is there a better way to enforce min and max on resize in the ancestor?

Currently each window (not using the ancestor) implements its own code in the resize event

if this.height < n then

  this.height = n

end if 

 

Any help gratefully received.

Kevin.

 

 

 

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 23 November 2023 21:27 PM UTC
  2. PowerBuilder
  3. # 1

Hi Kevin;

  My STD Framework has had this feature implemented in its base ancestor window for over a decade now. You can download the Order Entry Demo App & check out how it works.

   If you like the implementation, please feel free to use my code as the framework is free & open source. HTH

https://chrispollach.blogspot.com/2023/10/2023r2.html

Regards .... Chris. 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 23 November 2023 19:48 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Kevin -

What a coincidence! I'm getting extremely close to finishing a new example PB application to be submitted in CodeXchange that already contains an ancestor window such as what you have described. As Rene has outlined, it uses the pbm_getminmaxinfo event to enforce an optional minimum and/or maximum window size percentage (100% being the window's designed size) and this feature is very easy to use. For the resizing functionality, the example app uses a stand-alone version of the window resize service taken from the PowerBuilder Foundation Class libraries.

It is a national holiday today here in the U.S., so I'm spending most of the day with family, but I anticipate finishing the new example application (named "Grid Heading" by the end of this weekend and submitting it for review and subsequent publishing. Be on the lookout for it, if you are interested.

Best regards, John

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 23 November 2023 13:18 PM UTC
  2. PowerBuilder
  3. # 3

Hi Kevin,

you can't change the window size by changing the arguments of resize event. This argument are just to inform about the new size but not to change it.

You could try to resize the window by calling the Resize function (maybe you have to Post the function call!) to change the window size from the event. I've never tried this.

Another way is to use Windows API.

// external functions
subroutine GetMinMaxInfo (ref s_minmaxinfo d, long s, long l) library 'kernel32.dll' alias for "RtlMoveMemory;Ansi" 
subroutine SetMinMaxInfo (long d, s_minmaxinfo s, long l) library 'kernel32.dll' alias for "RtlMoveMemory;Ansi"


// structures
global type s_point from structure
	long		x
	long		y
end type

global type s_minmaxinfo from structure
	s_point		ptreserved
	s_point		ptmaxsize
	s_point		ptmaxposition
	s_point		ptmintracksize
	s_point		ptmaxtracksize
end type



// use it (here to set the min size)
// event getminmaxinfo with event ID pbm_getminmaxinfo in the window

//Populate the structure
GetMinMaxInfo(lstr_MinMaxInfo, al_minmaxinfo, 40)
	
//Determine the minimum size of the window (the original size)
lstr_MinMaxInfo.ptMinTrackSize.x = UnitsToPixels (il_resizeminwidth, XUnitsToPixels!)
lstr_MinMaxInfo.ptMinTrackSize.y = UnitsToPixels (il_resizeminheight, YUnitsToPixels!)
	
//Now set the Min/Max info
SetMinMaxInfo (al_minmaxinfo, lstr_MinMaxInfo, 40)
Comment
  1. Arnd Schmidt
  2. Thursday, 23 November 2023 21:35 PM UTC
  1. Helpful 2
  1. René Ullrich
  2. Friday, 24 November 2023 05:34 AM UTC
:-)
  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.