WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Expandable Dialog


Question:

I am just starting to explore the dialog callback options (at long last!). Is it possible to have an expandable dialog box? In other words, if I have an 'Advanced' button, could I 'grow' the dialog and have some extra options visible or do I have to call up a new dialog?

Answer:

Design the dialog in the full size, then in the init routine reduce the size of the window to hide the optional portion. Make a button that enlarges/reduces the window size.

;to expand/contract, just use winplaceset on the dialog caption (which is the 
;title of that window).  
;
;you want to contract the dialog right within the callback init routine so 
;that when it appears, it appears in the smaller form.  IIRC, this is possible 
;because although the window is not yet visible, you can reference it.
;
;you can use dialogcontrolset to change the title on the button
;
GoSub localfuncs

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`YammerFratz`
MyDialogX=140
MyDialogY=113
MyDialogWidth=164
MyDialogHeight=122
MyDialogNumControls=005
MyDialogProcedure=`callback`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=4513660

MyDialog001=`011,029,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`055,029,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`009,009,118,012,STATICTEXT,DEFAULT,"yatta yatta",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`099,029,036,012,PUSHBUTTON,DEFAULT,"More>>",2,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`009,067,044,012,STATICTEXT,DEFAULT,"Blah Blah",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Exit

:localfuncs
#DefineFunction callback(DH, EC, CN, un4, un5)
    winnam = "YammerFratz"
    smallersize = 150
    biggersize = 250

    Switch 1
      Case EC == 0
        DialogProcOptions(DH, 2, 1)
      Case EC == 2 && CN == 004
        GoSub change
        Return -2
    EndSwitch
    Return -1
    :change
        s = WinPlaceGet(@NORMAL,winnam)
        x0 = ItemExtract(1,s," ")
        y0 = ItemExtract(2,s," ")
        y1 = ItemExtract(4,s," ")
        If y1-y0 > smallersize
          s = ItemReplace(y0+smallersize, 4, s, " ")
          DialogControlSet(DH, 004, 4, "More")
        Else
          s = ItemReplace(y0+biggersize, 4, s, " ")
          DialogControlSet(DH, 004, 4, "Less")
        EndIf
        s = ItemReplace(y0+1, 2, s, " ") ; correct for bizarre creep behavior
        s = ItemReplace(x0+1, 1, s, " ") ; correct for bizarre creep behavior
        WinPlaceSet(@NORMAL,winnam,s)
        Return
#EndFunction
Return

Article ID:   W15915
File Created: 2004:03:30:15:41:42
Last Updated: 2004:03:30:15:41:42