Creating Resizeable Dialogs

You can use the DlgAreaU Object to facilitate in creating dynamically resizable Dialog objects, but to do so you must carefully satisfy all the requirements below.

The Dialog must be created with the ThickFrame option. It may be created with the UserDialog Create method or CreateCenter method.

Your Dialog init method must include the line:

self~connectResize("OnResize")

Your DefineDialog method must start with these lines:

expose u
u = .dlgAreaU~new(self)          /* whole dlg   */

Your DefineDialog method must not reference variables within the Add Method parameters, although you can use references to DlgArea attributes, so

Self~AddButton(23,1,5,6,"MyButton","Pressed")
self~addButton(14,b~x,b~y("10%"),b~w,b~h("9%"),"Button" 1,"Button"||1)

Both are OK, whereas

/* Seven buttons evenly spaced at 10% intervals, 9% high                     */
do i = 0 to 6
   self~addButton(12+i,b~x,b~y((i * 10)||"%"),b~w,b~h("9%"),"Button" i,"Button"||i)
end /* DO */

would now fail as the variable i is referenced within the parameters.

To debug your DlgAreaU call/insert the following after the instantiation

if u~lastError \= .nil then call errormessage u~lastError

You must also include the following in your code.

/* ------------------------------------------------------------------------- */
::method OnResize
/* ------------------------------------------------------------------------- */
expose u
if u~lastError \= .nil then call errormessage u~lastError
use arg dummy,sizeinfo
                                 /* wait for last size event msg then resize */
if self~PeekDialogMessage~left(8) \= "OnResize" then u~resize(self,sizeinfo)

The DlgAreaU method will then automatically resize & place the following widgets in your dialog when the dialog frame is dragged or the minimize, maximise or restore buttons are pressed:

Table 11-1. DlgAreaU Automatic Resize Elements

BLACKFRAMEBLACKRECTBITMAPBUTTONBUTTON
CHECKBOXCOMBOBOXENTRYLINEGRAYFRAME
GRAYRECTGROUPBOXLISTBOXLISTCONTROL
PASSWORDLINEPROGRESSBARRADIOBUTTONSCROLLBAR
SLIDERCONTROLTABCONTROLTEXTTREECONTROL
WHITEFRAMEWHITERECT  

The following widgets can be defined in a UserDialog, but cannot be handled by the DlgAreaU resize method, so should not be used.

Table 11-2. DlgAreaU Non-Automatic Resize Elements

BUTTONGROUPCHECKBOXSTEMCHECKGROUPCOMBOINPUT
FULLSEQINPUTINPUTGROUPINPUTSTEM
OKCANCEL...RADIOGROUPRADIOSTEM 

All of these widgets can be achieved using combinations of the permitted methods.