Schultz’s PowerBuilder Notes

PFC Window Resize Service


The resize service provides support for resizing controls when the window or tab control
is resized. It includes the following features:

— Determine the four extreme points of all controls within a window
— Choose which controls are eligible for automatic moving and/or resizing
— Move or resize controls
— Choose the minimum window size where automatic resizing should stop

How do I turn on the resize service

  • In the Window PFC_PREOPEN event, determine the original values for the window width and height

// To obtain the accurate size, you must open window in its
// ORIGINAL size and add the following MessageBox to find out the
// Window's Width & Height
// (It is not necessarily the same as the "Window’s Position Tab"
// Width & Height)

MessageBox("Window Size”, “Width: " + string(this.WorkSpaceWidth()) + &
                  "~r~nHeight: "+ string(this.WorkSpaceHeight()))
  • In the Window PFC_PREOPEN event turn on resize service and set original size with the values found in the previous step.

//// To obtain the accurate size, you must open window in its
//// ORIGINAL size and add the following MessageBox to find out the
//// Window's Width & Height
//// (It is not necessarily the same as the "Window’s Position Tab"
//// Width & Height)
//
//MessageBox("Window Size","Width: " + string(this.WorkSpaceWidth())+&
//           "~r~nHeight: "+ string(this.WorkSpaceHeight()))
this.of_SetResize(TRUE)
IF IsValid(this.inv_resize) THEN
   this.inv_resize.of_SetOrigSize(2899,1281) //Then Plug in the width & height here
                                             //and comment out temporary MessageBox
   //Then continue with registering objects
   this.inv_resize.of_Register(tab_1, "Scale")
END IF

  • Another way

this.of_SetResize(TRUE)
this.inv_resize.of_GetMinMaxPoints(this.control[], li_min_x, li_min_y, li_max_x, li_max_y)
this.inv_resize.of_SetOrigSize(li_max_x + 50, li_max_y + 35)
this.inv_resize.of_Register(dw_report, this.inv_resize.SCALE)

  • What about a tab page?

this.of_SetResize(True)
if IsValid(this.inv_resize) then
   this.inv_resize.of_SetOrigSize(3566, 1916)
   this.inv_resize.of_Register(tab_p2b_reconciliation, this.inv_resize.SCALE)
   this.inv_resize.of_Register(tab_p2b_reconciliation.tabpage_bulk.dw_bulk, this.inv_resize.SCALE)
end if

  • What about objects on a tabpage

If a window contains a tab user object, and this tab contains user object tabpages, you need to modify the constructor event of the user object:

this.of_SetResize(True)
this.inv_resize.of_Register(dw_versions, "Scale")
this.inv_resize.of_Register(cb_all, "FixedToBottom")
this.inv_resize.of_Register(cb_some, "FixedToBottom")
  • On a user object which appears on a parent window or other custom visual user object:
// no need to set original size
lw.of_SetResize(TRUE)
lw.inv_resize.of_register(dw_application_grid, "Scale")
lw.inv_resize.of_register(dw_application_ff,   "Scale")

  • I have a window with two objects in a master detail relationship. The detail object on the bottom should simply moved fixed to the bottom. The object on top should resize to fill in the space which opens up when the detail is lowered:
    • The Detail dw should be registered to FIXEDBOTTOM
    • The Master dw should not be registered with the resize service
    • The Detail dw Resize event should post to the following function

//wf_resize()

integer li_dw_y_end

li_dw_y_end           = this.Height - 16
dw_master.Height      = li_dw_y_end - dw_detail.height
dw_master.Width       = this.Width - dw_output_list.Width - 30

Return SUCCESS

Okay, what are the possible control resize settings and what do they mean exactly?

  • “FixedToRight” or FIXEDRIGHT
  • “FixedToBottom” or FIXEDBOTTOM
  • “FixedToRight&Bottom” or FIXEDRIGHTBOTTOM
  • “Scale” or SCALE
  • “ScaleToRight” or SCALERIGHT
  • “ScaleToBottom” or SCALEBOTTOM
  • “ScaleToRight&Bottom” or SCALERIGHTBOTTOM
  • “FixedToRight&ScaleToBottom” or FIXEDRIGHT_SCALEBOTTOM
  • “FixedToBottom&ScaleToRight” or FIXEDBOTTOM_SCALERIGHT

Setting

Meaning

FixedToRight

moved keeping the original distance to the right edge

FixedToBottom

moved keeping the original distance to the bottom edge

FixedToRight&Bottom

moved keeping the original distance to the right and bottom edge

Scale

resized proportionally to the window

ScaleToRight

resized keeping the original distance to the right edge.

ScaleToBottom

resized keeping the original distance to the bottom edge.

ScaleToRight&Bottom

moved keeping the original distance to the right edge. Control is resized keeping the original distance to the bottom edge.

FixedToRight&ScaleToBottom

moved keeping the original distance to the right edge. Control is resized keeping the original distance to the bottom edge

FixedToBottom&ScaleToRight

moved keeping the original distance to the bottom edge. Control is resized keeping the original distance to the right edge.

Advertisements

June 12, 2008 - Posted by | 3. PFC, Window Services | , , , , , , , , , , , ,

3 Comments »

  1. I have a fairly simple powerbuilder application that has a main window and a datawindow control on it and various other controls. How can I resize when user clicks maximize and then returns to normal. I’ve not used the PFC and do not know how to activate it within the application. I have read your tech note but don’t know how to activate the pfc_open event. Thanks for your help.

    Comment by Darryl Cummings | November 30, 2008 | Reply

  2. Darryl, if you are not using the PFC, you will need to add script to the Window Resize event which fires every time the window resizes. In this event, adjust the particular controls you wish to move and resize by adjusting their, “X”, “Y”, “Height” and/or “Width” properties.

    Comment by rick130 | December 1, 2008 | Reply

  3. Am Resize the window and datawindow after that if am change the datawindow at run time , then all datawindow objects show in its original postion , how to resize the datawinodow object if its change at run time

    Comment by alavudeen | July 7, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: