Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Resize Dialog Controls Dynamically Global Pointer Variables PtrGlobalDefine PtrGlobal PtrPersistent Threshold
#DefineSubRoutine InitDialogConstants() ;DialogprocOptions Constants MSG_INIT=0 ; The one-time initialization MSG_TIMER=1 ; Timer event MSG_BUTTONPUSHED=2 ; Pushbutton or Picturebutton MSG_RADIOPUSHED=3 ; Radiobutton clicked MSG_CHECKBOX=4 ; Checkbox clicked MSG_EDITBOX=5 ; Editbox or Multilinebox MSG_FILESELECT=6 ; Filelistbox MSG_ITEMSELECT=7 ; Itembox MSG_COMBOCHANGE=8 ; Combobox/Droplistbox MSG_CALENDAR=9 ; Calendar date change MSG_SPINNER=10 ; Spinner number change MSG_CLOSEVIA49=11 ; Close clicked (Enabled via DialogProcOptions 1002 MSG_FILEBOXDOUBLECLICK=12 ; Get double-click message on a FileListBox MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox MSG_COMEVENT=14 ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions) MSG_MENUITEM=15 ; MenuItem selected MSG_MENUITEMINIT=16 ; MenuItem initialized MSG_RESIZE=17 ; Dialog resized DPO_DISABLESTATE=1000 ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog DPO_CHANGEBACKGROUND=1001 ; -1=Get Current otherise bitmap or color string DPO_CHANGESYSMENU=1002 ; -1=Get Current 0=none 1=close 2=close/min 3=close/max 4=close/min/max DPO_CHANGETITLE=1003 ; Set/Get Dialog Title - (-1 to get) DPO_GETNAME=1004 ; Returns the name associated with a control's number. DPO_GETNUMBER=1005 ; Returns the number associated with a control's name. ;DialogControlState Constants DCSTATE_SETFOCUS=1 ; Give Control Focus DCSTATE_QUERYSTYLE=2 ; Query control's style DCSTATE_ADDSTYLE=3 ; Add control style DCSTATE_REMOVESTYLE=4 ; Remove control style DCSTATE_GETFOCUS=5 ; Get control that has focus DCSTATE_MOVEMOUSEOVER=6 ; Move the mouse over the control DCSTYLE_DEFAULT=0 ; Set Default Style DCSTYLE_INVISIBLE=1 ; Set Control Invisible DCSTYLE_DISABLED=2 ; Set Control Disabled DCSTYLE_NOUSERDATA=4 ; Note: Setable via DialogControlState function ONLY SPINNER control only DCSTYLE_READONLY=8 ; Sets control to read-only (user cannot type in data) EDITBOX MULTILINEBOX SPINNER DCSTYLE_PASSWORD=16 ; Sets 'password mode' where only *'s are displayed EDITBOX DCSTYLE_DEFAULTBUTTON=32 ; Sets a button as the default button PUSHBUTTON PICTUREBUTTON DCSTYLE_DIGITSONLY=64 ; Set edit box to accept digits only EDITMOX MULTILINEBOX DCSTYLE_FLAT=128 ; Makes a 'flat' hyperlink-looking button PUSHBUTTON PICTUREBUTTON DCSTYLE_NOADJUST=256 ; Turns off auto-height adjustment ITEMBOX FILELISTBOX DCSTYLE_TEXTCENTER=512 ; Center text in control VARYTEXT STATICTEXT DCSTYLE_TEXTRIGHT=1024 ; Flush-Right text in control VARYTEXT STATICTEXT DCSTYLE_NOSELCURLEFT=2048 ; No selection, cursor left EDITBOX MULTILINEBOX DCSTYLE_NOSELCURRIGHT=4096; No selection, cursor right EDITBOX MULTILINEBOX DCSTYLE_SHIELD=8192 ; Display Security Shield icon on button (Vista only) PUSHBUTTON PICTUREBUTTON DCSTYLE_MENUCHECK=32768 ; Adds a check mark to the left of a menu item MENUITEM DCSTYLE_MENURADIO=65536 ; Adds a radio button like dot graphic to the left of a menu item MENUITEM DCSTYLE_MENUSEP=131072 ; Separator bar graphic MENUITEM DCSTYLE_MENUBREAK=262144 ; column break MENUBAR ;DialogControlSet / DialogControlGet Constants DC_CHECKBOX=1 ; CHECKBOX DC_RADIOBUTTON=2 ; RADIOBUTTON DC_EDITBOX=3 ; EDITBOX MULTILINEBOX DC_TITLE=4 ; PICTURE RADIOBUTTON CHECKBOX PICTUREBUTTON VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON MENUITEM DC_ITEMBOXCONTENTS=5 ; ITEMBOX FILELISTBOX DROPLISTBOX DC_ITEMBOXSELECT=6 ; ITEMBOX FILELISTBOX DROPLISTBOX DC_CALENDAR=7 ; CALENDAR DC_SPINNER=8 ; SPINNER DC_MULTITABSTOPS=9 ; MULTILINEBOX DC_ITEMSCROLLPOS=10 ; ITEMBOX FILELISTBOX DC_BACKGROUNDCOLOR=11 ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FILELISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX DC_PICTUREBITMAP=12 ; PICTURE PICTUREBUTTON DC_TEXTCOLOR=13 ; RADIOBUTTON CHECKBOX VARYTEXT STATICTEXT GROUPBOX PUSHBUTTON ITEMBOX FIELLISTBOX DROPLISTBOX SPINNER EDITBOX MULTILINEBOX DC_ITEMBOXADD=14 ; ITEMBOX FILELISTBOX DROPLISTBOX DC_ITEMBOXREMOVE=15 ; ITEMBOX FILELISTBOX DROPLISTBOX DC_RADIOVALUE=16 ; RADIOBUTTON DC_POSITION=17 ; ALL CONTROLS (Except MENUBAR and MENUITEM) DC_MENUNAMES=18 ; ALL CONTROLS DC_HANDLE=19 ; ALL CONTROLS (Except MENUBAR and MENUITEM) ;DialogObject constants DLGOBJECT_ADDEVENT=1 ; Call dialog callback when the specified event occurs DLGOBJECT_STOPEVENT=2 ; Stop calling dialog callback when an event previously requested with DLGOBJECT_GETOBJECT=3 ; Return an object references to the specified control DLGOBJECT_GETPICTURE=4 ; Create and return an object reference to a picture object ;Return code constants RET_DO_CANCEL=0 ; Cancels dialog RET_DO_DEFAULT= -1 ; Continue with default processing for control RET_DO_NOT_EXIT= -2 ; Do not exit the dialog Return #EndSubRoutine InitDialogConstants() ; Initialize Dialog Constants (need only be done once usually) #DefineFunction ResizeExample(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo) MSG_INIT = 0 MSG_BUTTONPUSHED=2 ; Pushbutton or Picturebutton MSG_RESIZE=17 ; Dialog resized RET_DO_CANCEL=0 ; Cancels dialog RET_DO_DEFAULT= -1 ; Continue with default processing for control RET_DO_NOT_EXIT= -2 ; Do not exit the dialog ON_EQUAL = @TRUE ; Initialize variable ON_EQUAL Switch MyDialog_Message ; Switch based on Dialog Message type Case MSG_INIT ; Get globals and initialize statics with the global values. pnDialogWidth = PtrGlobal(nDialogWidth) pnDialogHeight = PtrGlobal(nDialogHeight) pnDlgWidth = PtrPersistent(nDlgWidth, *pnDialogWidth) pnDlgHeight = PtrPersistent(nDlgHeight, *pnDialogHeight) pnTreshHold = PtrPersistent(nTreshHold, 0) DialogProcOptions(MyDialog_Handle,MSG_RESIZE,@TRUE) DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE) ; Save values for use when calculating button positions. strRect = DialogControlGet(MyDialog_Handle, "PushButton_OK", 17 ) pnOkMidOff = PtrPersistent(nOkMidOff, ItemExtract(1, strRect, " ") - (*pnDlgWidth/2)) strRect = DialogControlGet(MyDialog_Handle, "PushButton_Cancel", 17 ) pnCanMidOff = PtrPersistent(nCanMidOff, ItemExtract(1, strRect, " ") - (*pnDlgWidth/2)) strRect = DialogControlGet(MyDialog_Handle, "RadioButton_11", 17 ) pnMidOff = PtrPersistent(nMidOff, ItemExtract(1, strRect, " ") - (*pnDlgWidth/2)) strRect = DialogControlGet(MyDialog_Handle, "RadioButton_21", 17 ) pnRightOff = PtrPersistent(nRightOff, *pnDlgWidth - ItemExtract(1, strRect, " ") ) Return(RET_DO_DEFAULT) Case MSG_BUTTONPUSHED If MyDialog_Name == "PushButton_OK" ; OK Return(RET_DO_DEFAULT) ElseIf MyDialog_Name == "PushButton_Cancel" ; Cancel Return(RET_DO_DEFAULT) EndIf ; MyDialog_Name Return(RET_DO_DEFAULT) Case MSG_RESIZE nDeltaX = ItemExtract(1,MyDialog_ChangeInfo, " ") nDeltaY = ItemExtract(2,MyDialog_ChangeInfo, " ") pnDlgWidth = PtrPersistent(nDlgWidth, 0) pnDlgHeight = PtrPersistent(nDlgHeight, 0) pnOkMidOff = PtrPersistent(nOkMidOff, 0) pnCanMidOff = PtrPersistent(nCanMidOff, 0) pnLeftOff = PtrPersistent(nLeftOff, 0) pnMidOff = PtrPersistent(nMidOff, 0) pnRightOff = PtrPersistent(nRightOff, 0) pnTreshHold = PtrPersistent(nTreshHold , 0) *pnDlgWidth = *pnDlgWidth + nDeltaX *pnDlgHeight = *pnDlgHeight + nDeltaY *pnTreshHold = *pnTreshHold + nDeltaY bDoY = Abs(*pnTreshHold) >= 9 For x = 1 To 30 strRect = DialogControlGet(MyDialog_Handle, "RadioButton_":x, 17 ) If x > 10 && x < 21 strRect = ItemReplace(*pnDlgWidth/2+*pnMidOff , 1, strRect, " ") ElseIf x > 20 strRect = ItemReplace(*pnDlgWidth - *pnRightOff, 1, strRect, " ") EndIf If bDoY nY = ItemExtract(2, strRect, " ") + ((*pnTreshHold/9) * ((x - 1) mod 10)) strRect = ItemReplace(nY , 2, strRect, " ") EndIf DialogControlSet(MyDialog_Handle,"RadioButton_":x, 17, strRect ) Next If bDoY Then *pnTreshHold = *pnTreshHold mod 9 ; Buttons stay more or less centered at the bottom of the dialog. strRect = DialogControlGet(MyDialog_Handle, "PushButton_OK", 17 ) nY = ItemExtract(2, strRect, " ") strRect = ItemReplace(*pnDlgWidth/2+*pnOkMidOff , 1, strRect, " ") strRect = ItemReplace(nY+nDeltaY, 2, strRect, " ") DialogControlSet(MyDialog_Handle, "PushButton_OK", 17, strRect ) strRect = DialogControlGet(MyDialog_Handle, "PushButton_Cancel", 17 ) nY = ItemExtract(2, strRect, " ") strRect = ItemReplace(*pnDlgWidth/2+*pnCanMidOff, 1, strRect, " ") strRect = ItemReplace(nY+nDeltaY, 2, strRect, " ") DialogControlSet(MyDialog_Handle, "PushButton_Cancel", 17, strRect ) Return(RET_DO_DEFAULT) EndSwitch ; MyDialog_Message Return(RET_DO_DEFAULT) #EndSubRoutine ; End of Dialog Callback MyDialogCallbackProc MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`Resize Example` MyDialogX=587 MyDialogY=084 MyDialogWidth=278 MyDialogHeight=202 MyDialogMinWidth=200 MyDialogMinHeight=200 MyDialogNumControls=032 MyDialogProcedure=`ResizeExample` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`071,183,032,010,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`153,183,034,010,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`003,007,040,010,RADIOBUTTON,"RadioButton_1",rbVariable,"Radio 1",1,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog004=`003,023,040,010,RADIOBUTTON,"RadioButton_2",rbVariable,"Radio 2",2,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog005=`003,039,038,010,RADIOBUTTON,"RadioButton_3",rbVariable,"Radio 3",3,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog006=`003,055,040,010,RADIOBUTTON,"RadioButton_4",rbVariable,"Radio 4",4,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog007=`003,071,040,010,RADIOBUTTON,"RadioButton_5",rbVariable,"Radio 5",5,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog008=`003,087,042,010,RADIOBUTTON,"RadioButton_6",rbVariable,"Radio 6",6,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog009=`003,103,040,010,RADIOBUTTON,"RadioButton_7",rbVariable,"Radio 7",7,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog010=`003,119,040,010,RADIOBUTTON,"RadioButton_8",rbVariable,"Radio 8",8,100,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog011=`003,135,040,010,RADIOBUTTON,"RadioButton_9",rbVariable,"Radio 9",9,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog012=`003,151,040,010,RADIOBUTTON,"RadioButton_10",rbVariable,"Radio 10",10,120,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog013=`121,007,040,010,RADIOBUTTON,"RadioButton_11",rbVariable,"Radio 11",11,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog014=`121,023,040,010,RADIOBUTTON,"RadioButton_12",rbVariable,"Radio 12",11,140,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog015=`121,039,040,010,RADIOBUTTON,"RadioButton_13",rbVariable,"Radio 13",11,150,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog016=`121,055,040,010,RADIOBUTTON,"RadioButton_14",rbVariable,"Radio 14",11,160,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog017=`121,071,040,010,RADIOBUTTON,"RadioButton_15",rbVariable,"Radio 15",11,170,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog018=`121,087,040,010,RADIOBUTTON,"RadioButton_16",rbVariable,"Radio 16",11,180,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog019=`121,103,040,010,RADIOBUTTON,"RadioButton_17",rbVariable,"Radio 17",11,190,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog020=`121,119,040,010,RADIOBUTTON,"RadioButton_18",rbVariable,"Radio 18",11,200,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog021=`121,133,040,010,RADIOBUTTON,"RadioButton_19",rbVariable,"Radio 19",11,210,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog022=`121,149,040,010,RADIOBUTTON,"RadioButton_20",rbVariable,"Radio 20",11,220,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog023=`237,007,040,010,RADIOBUTTON,"RadioButton_21",rbVariable,"Radio 21",11,230,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog024=`237,023,040,010,RADIOBUTTON,"RadioButton_22",rbVariable,"Radio 22",11,240,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog025=`237,039,040,010,RADIOBUTTON,"RadioButton_23",rbVariable,"Radio 23",11,250,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog026=`237,055,040,010,RADIOBUTTON,"RadioButton_24",rbVariable,"Radio 24",11,260,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog027=`237,071,040,010,RADIOBUTTON,"RadioButton_25",rbVariable,"Radio 25",11,270,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog028=`237,087,040,010,RADIOBUTTON,"RadioButton_26",rbVariable,"Radio 26",11,280,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog029=`237,103,040,010,RADIOBUTTON,"RadioButton_27",rbVariable,"Radio 27",11,290,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog030=`237,119,040,010,RADIOBUTTON,"RadioButton_28",rbVariable,"Radio 28",11,300,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog031=`237,135,040,010,RADIOBUTTON,"RadioButton_29",rbVariable,"Radio 29",11,310,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog032=`237,151,040,010,RADIOBUTTON,"RadioButton_30",rbVariable,"Radio 30",11,320,DEFAULT,DEFAULT,DEFAULT,DEFAULT` PtrGlobalDefine(nDialogWidth) nDialogWidth = MyDialogWidth PtrGlobalDefine(nDialogHeight) nDialogHeight = MyDialogHeight ButtonPushed=Dialog("MyDialog")
Article ID: W17760
Filename: Resize Dialog and Controls Dynamically- Global Variables.txt
File Created: 2010:07:21:14:20:46
Last Updated: 2010:07:21:14:20:46