1. Tracy Lamb
  2. PowerBuilder
  3. Sunday, 27 March 2022 18:25 PM UTC

Hi Friends,

I'm migrating to PB 2021, and the most recent PFC.  My old PFC files are over 20 years old!  We have several windows that use something like "home made" split bar in conjunction with the linking service.  We had written code to do our own split bar, and that still works fine, but I thought I'd try out the PFC split bar, as it seems to have a lot less code involved.  

I reviewed the PFC example app, and decided to try a very simple split-bar in my main app.  I have a window with a tree view on the left (inherited from u_tv), a split bar in the middle (inherited from u_st_splitbar), and a list view on the right (inherited from u_lv).  I copied the code from the example into my new window, modifying the object names accordingly.  The only code in the example is the the pfc_preopen event.  

Here's my code:

// Register the controls with the Vertical SplitBar
st_v1.of_Register(tv_1, st_v1.LEFT)
st_v1.of_Register(lv_1, st_v1.RIGHT)

// Window Resize Behavior
of_SetResize(True)
// Left Side Object
inv_resize.of_Register(tv_1, 0, 0, 0, 100)
inv_resize.of_Register(st_v1, 0, 0, 0, 100)
// Right side object
inv_resize.of_Register(lv_1, 0, 0, 100, 100)

I can move the split bar and the tv and lv resize horizontally accordingly.  But the tv and lv are the same size they were when I designed the screen.  They aren't resizing to fill up the screen.  Neither horizontally or vertical.  I'm thinking I need something more than the code above, but can't figure out what it would be.  There's nothing else in PFC example.

TIA,
~~~Tracy

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 17:31 PM UTC
  2. PowerBuilder
  3. # Permalink

Thank you Benjamin and John for responding.  I got it fixed... I had to resize the objects before registering the resize service, as pointed out by Benjamin.

I put the following code in the window's open event:

// Resize objects...
tv_1.Height = this.WorkspaceHeight() - 40
lv_1.Height = this.WorkspaceHeight() - 40
lv_1.Width = this.WorkspaceWidth() - lv_1.x - 40
st_v1.Height = this.WorkspaceHeight() - 40

// Register the controls with the Vertical SplitBar
st_v1.of_Register(tv_1, st_v1.LEFT)
st_v1.of_Register(lv_1, st_v1.RIGHT)

// Window Resize Behavior
of_SetResize(True)

// Left Side Object
inv_resize.of_Register(tv_1,"ScaleToBottom")
//Split Bar
inv_resize.of_Register(st_v1,"ScaleToBottom")
// Right side object
inv_resize.of_Register(lv_1, "ScaleToRight&Bottom")

~~~Tracy

 

Comment
  1. John Fauss
  2. Monday, 28 March 2022 17:35 PM UTC
Glad to hear you found the problem, Tracy - Thanks for letting us know the solution!
  1. Helpful
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 12:48 PM UTC
  2. PowerBuilder
  3. # 1

But the tv and lv are the same size they were when I designed the screen.  They aren't resizing to fill up the screen.

Do they resize at all when you change the window size? Maybe the window is resized before the resize-service code is being executed? The resize service always resizes controls based on their position relative to the parent object at the precise moment they are registered with the service.

Comment
  1. Tracy Lamb
  2. Monday, 28 March 2022 16:32 PM UTC
They do resize when I change the window size. My app is an MDI app, and the window initially opens to fill the workspace (but not maximized). How do I resize the objects as soon as the window opens? I keep getting the error "private or protected function cannot be accessed: of_resize() ". The code I used in the window open event is:

inv_resize.of_Resize(this.WorkspaceWidth(), this.WorkspaceHeight())
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 01:50 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Tracy - 

Please try the following:

Put the calls to the splitbar object's of_Register function in the splitbar's Constructor event script instead of the window's pfc_PreOpen event.

This is where original PFC documentation on the u_splitbar object says the registering of controls with the u_splitbar object should be done.

Unless you are very comfortable using the format of the Resize service's of_Register object that specifies the MoveX, MoveY, ScaleX, and ScaleY numeric argument values, I suggest you instead use the "named" resize method format, as it is much more intuitive. The three calls you have coded then become:

inv_resize.of_Register(tv_1,"ScaleToBottom")
inv_resize.of_Register(st_v1,"ScaleToBottom")
inv_resize.of_Register(tv_1,"ScaleToRight&Bottom")

When I tried a test window using these changes, it seems to work as I believe you are wanting.

HTH, John

Comment
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Monday, 28 March 2022 16:25 PM UTC
  2. PowerBuilder
  3. # 3

I moved the code to the split bar's constructor, with changes recommended...

// Register the controls with the Vertical SplitBar
st_v1.of_Register(tv_1, st_v1.LEFT)
st_v1.of_Register(lv_1, st_v1.RIGHT)

// Window Resize Behavior
of_SetResize(True)

// Left Side Object
inv_resize.of_Register(tv_1,"ScaleToBottom")
//Split Bar
inv_resize.of_Register(st_v1,"ScaleToBottom")
// Right side object
inv_resize.of_Register(lv_1, "ScaleToRight&Bottom")

Nothing seems to be scaling to the bottom, and the objects don't resize when the window initially opens.  It makes sense that the object's size needs to be adjust upfront.  The objects do adjust left and right, and when I manually resize the window the objects resize up/down/left/right accordingly.  I tried resizing objects to accommodate for the window size, in both the constructor of the the split bar as well as the open event of the window.  I keep getting the error  "private or protected function cannot be accessed: of_resize() ".  The code I used in the split bar constructor is:

inv_resize.of_Resize(parent.WorkspaceWidth(), parent.WorkspaceHeight())

Changed "parent" to "this" in the window open event.

~~~Tracy

 

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.