PowerBuilder ‘Gotcha’ – pfc Resize service and Tabpages

Posted on Wednesday, September 8th, 2010 at 8:20 pm in

The window resize service is one of the best features of the PFC. With a few lines of code you can easily make your application much more resolution independent and user friendly. Something else which makes this service pretty cool is that it can be easily un-copoled from the rest of the pfc. All you need is n_base, n_cst_resize, and n_cst_resizeattrib which you can make by exporting the corresponding ‘pfc_’ objects, renaming them in the export file, and then importing them. You have to handle instantiating and destroying the object but that’s pretty minor.

Anyway I’m working on an existing multi tab window to which I want to add resize functionality. Using standard convention I use a ‘registration’ event posted from the window’s ‘Open’ event to create the service, set various parameters, and register the objects with the service. In the resize event of the window I trigger the pfc_resize event on the service but put some limiting logic if the window’s width is too large (my intention is to show all the columns in various datawindows but I don’t want a large blank area to the right of the datawindow control if the user is on a large monitor).

Everything seems fine in my testing so the code is checked in. Fast forward a couple of months and a co-worker is regression testing my code and I notice that sometimes a white rectangle is appearing between the bottom of the window and tabpage. I check the objects on the window, check the background colors, try tweeking the dimensions, etc. without luck. A google search brought me to this page on pfcguide.com. (As of 9-12-2011 this link is broken.) (Updated March 2021 to link to old PB9 PFC guide but not page I originally found.)

Notice this section:

In your Tab's Constructor event:

// Nothing is needed here...
// Because the tab pages are automatically resized when the tab control resizes

// Do not register the tabpages themselves or you will notice slight resize problems
// with your tabpages, since they are then being resized twice.

When I removed the registration of the tab pages themselves (not the objects on the tabs) – no more white rectangles.

You might also be interested in