Displays a user-defined dialog box.
Dialog ( dialog-name [,ignore-flag] )
(s) dialog-name: name of the dialog box.
(i) ignore-flag: [optional] 1 to display dialog, or 0 to skip. Note: If not specified one (1) is assumed.
(i) pushbutton: value of the pushbutton used to close the dialog box.
Note: The WIL Dialog Editor has been included to create your dialogs. Most of the following information is for technical reference only. Please see the WinBatch.chm for more information on the WIL Dialog Editor.
Reference:
§ Defining the Dialog Controls
The following types of controls are available:
§ Calendar
§ Checkbox
§ DateTime
§ Editbox
§ Groupbox
§ Itembox
§ MenuBar
§ MenuItem
§ Picture
§ Spinner
§ VaryText
MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`Edit INI file` MyDialogX=069 MyDialogY=124 MyDialogWidth=176 MyDialogHeight=184 MyDialogNumControls=014 MyDialogProcedure = `DEFAULT` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT` MyDialogConfig=0 MyDialogDPI=`96,8,16` MyDialog001=`109,157,58,14,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"&Cancel",0,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`111,77,60,14,PUSHBUTTON,"PushButton_Notepad",DEFAULT,"&Notepad",1,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`111,95,60,14,PUSHBUTTON,"PushButton_WBS",DEFAULT,"&WinBatch Studio",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog004=`111,113,60,14,PUSHBUTTON,"PushButton_Write",DEFAULT,"Wri&te",3,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog005=`111,131,60,14,PUSHBUTTON,"PushButton_WinWord",DEFAULT,"WinW&ord",4,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog006=`111,35,58,14,RADIOBUTTON,"RadioButton_Normal",state,"No&rmal",1,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog007=`111,49,58,14,RADIOBUTTON,"RadioButton_Zoomed",state,"&Zoomed",2,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog008=`111,63,58,14,RADIOBUTTON,"RadioButton_Iconized",state,"&Iconized",3,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog009=`111,21,58,14,CHECKBOX,"CheckBox_BAK",backup,"Make &BAK",1,9,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog010=`5,3,34,14,STATICTEXT,"StaticText_Directory:",DEFAULT,"&Directory:",DEFAULT,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog011=`41,3,130,20,VARYTEXT,"VaryText_FileName",editfile,"*EMPTY*",DEFAULT,11,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog012=`5,15,18,12,STATICTEXT,"StaticText_File:",DEFAULT,"&File:",DEFAULT,12,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog013=`5,35,100,140,FILELISTBOX,"FileListBox_Files",editfile,DEFAULT,DEFAULT,13,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog014=`5,25,100,10,EDITBOX,"EditBox_File",editfile,"None Selected",DEFAULT,14,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
DirChange(DirWindows(0)) editfile = "*.INI" ; Set default mask For filelistbox backup = 1 ; Set the checkbox To be on By default state = 2 ; Set the 2nd radio button as the default
:DISPLAY_DLG ButtonPushed = Dialog("MyDialog",1)
; If the user didn't select a valid file, re-display the dialog If !FileExist(editfile) Then Goto DISPLAY_DLG ; Find out if the checkbox was checked, and proceed accordingly If backup == 1 bakfile = StrCat(FileRoot(editfile), ".BAK") FileCopy(editfile, bakfile, @true) EndIf
; Find out which radio button was pressed, and set the variable ; "runcmd" to the name of the appropriate member of the Run "family" Switch state Case 1 runcmd = "Run" Break Case 2 runcmd = "RunZoom" Break Case 3 runcmd = "RunIcon" Break EndSwitch
; Set the variable "editor", based on the pushbutton that was pressed Switch ButtonPushed Case 1 editor = FileLocate("notepad.exe") Break Case 2 editor = FileLocate("WinBatch Studio.exe") Break Case 3 editor = FileLocate("write.exe") Break Case 4 editor = FileLocate("winword.exe") Break EndSwitch
; Execute the appropriate command (using variable substitution) %runcmd%(editor, editfile) Exit
:cancel ; If we got here, it means the user pressed the Cancel pushbutton Message(MyDialogCaption, "Operation cancelled")
produces:
#DefineSubRoutine ExampleProc(DialogHandle, EventCode, ControlName, EventInfo, ChangeInfo) Switch( EventCode) Case @deinit DialogProcOptions(DialogHandle, @depbpush, 1) break; Case @depbpush If ControlName == "Pushbutton_Hello" Display(2,"","Hello World") Return @retnoexit ; Don't termnate the dialog EndIf If ControlName == "Pushbutton_Bye" Display(2,"","Goodbye World") Return @retdefault EndIf EndSwitch Return @retdefault #EndSubRoutine ExampleOneFormat=`WWWDLGED,6.2` ExampleOneCaption=`Simple Callback Example`
ExampleOneX=029 ExampleOneY=060 ExampleOneWidth=174 ExampleOneHeight=094 ExampleOneNumControls=002 ExampleOneProcedure=`ExampleProc` ExampleOneFont=`DEFAULT` ExampleOneTextColor=`DEFAULT` ExampleOneBackground=`DEFAULT,DEFAULT` ExampleOneConfig=0 ExampleOne001=`029,051,034,014,PUSHBUTTON,"Pushbutton_Hello",DEFAULT,"Hello",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ExampleOne002=`093,051,034,014,PUSHBUTTON,"Pushbutton_Bye",DEFAULT,"Good Bye",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("ExampleOne",1) Exit
#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd) Switch MyDialog_Message ; Switch based on Dialog Message type Case @deinit ; Standard Initialization message DialogProcOptions(MyDialog_Handle,@depbpush,@true) DialogProcOptions(MyDialog_Handle,@demiselect,@true) Return(@retdefault) Case @depbpush If MyDialog_Name == "PushButton_RightClickMe" ; Right Click Me! Pause('Notice','You left-clicked the button') Return(@retnoexit ) ElseIf MyDialog_Name == "PushButton_Cancel" ; Cancel Pause('Notice','You pressed Cancel') Return(@retcancel) EndIf ; MyDialog_Name Return(@retdefault) Case @demiselect If MyDialog_Name == "cmi1_PushButton_RightClickMe" ; PushButton_RightClickMe Context Menu One Pause('You Selected:','Context menu One') Return(@retnoexit ) ElseIf MyDialog_Name == "cmi3_PushButton_RightClickMe" ; cmi1_PushButton_RightClickMe Subcontext Menu One Pause('You Selected:','Subcontext menu One') Return(@retnoexit ) ElseIf MyDialog_Name == "cmi2_PushButton_RightClickMe" ; PushButton_RightClickMe Context menu Two Pause('You Selected:','Context menu Two') Return(@retnoexit ) ElseIf MyDialog_Name == "mbi1_MyDialog" ; Dialog_Bar Menu Item One ;NOTICE : The user-defined callback is not called in response to the mouse selection of menu ;item that have an associated dropdown menus or submenus. The associated dropdown or submenu ;is displayed instead. Hot-keys should not be used with menu items that display a dropdown ;or submenu. Return(@retnoexit ) ElseIf MyDialog_Name == "mbi2_MyDialog" ; mbi1_MyDialog SubMenu Item One Pause('You Selected:','SubMenu item One') Return(@retnoexit ) ElseIf MyDialog_Name == "mbi3_MyDialog" ; Dialog_Bar Menu Item Two Pause('You Selected:','Menu item Two') Return(@retnoexit ) EndIf ; MyDialog_Name Return(@retdefault) EndSwitch ; MyDialog_Message Return(@retdefault) #EndFunction ; End of Dialog Callback MyDialogCallbackProc
;MENUITEMs can be displayed on a menu bar or as a menu item associated with a drop-down, context menu or submenu. ; ;Dropdown menus are created by placing the name of a MENUITEM displayed in the menu bar in the parent attribute ;of the menu item's template entry. A submenu is started by placing the name of a MENUITEM other than a menu bar ;displayed menu item in the parent attribute. ; ;Context menus are usually activated by right-clicking the client area of a control or dialog. Create context ;menus by specifying the name of a control in the parent attribute. If you use the DEFAULT keyword as the ;MENUITEM parent, the context menu will by associated with the dialog and display when the user right clicks on ;an 'empty' area of the dialog or on any control that does not already have a system or template supplied context ;menu. MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`Menu Sample` MyDialogX=241 MyDialogY=080 MyDialogWidth=242 MyDialogHeight=116 MyDialogNumControls=009 MyDialogProcedure=`MyDialogCallbackProc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`073,047,078,012,PUSHBUTTON,"PushButton_RightClickMe",DEFAULT,"Right Click Me!",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`093,093,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`000,000,000,000,MENUITEM,"cmi1_PushButton_RightClickMe","PushButton_RightClickMe","Context Menu One",DEFAULT,10,DEFAULT` MyDialog004=`000,000,000,000,MENUITEM,"cmi3_PushButton_RightClickMe","cmi1_PushButton_RightClickMe","Subcontext Menu One",DEFAULT,10,DEFAULT` MyDialog005=`000,000,000,000,MENUITEM,"cmi2_PushButton_RightClickMe","PushButton_RightClickMe","Context menu Two",DEFAULT,20,DEFAULT` MyDialog006=`000,000,000,000,MENUBAR,"Dialog_Bar"` MyDialog007=`000,000,000,000,MENUITEM,"mbi1_MyDialog","Dialog_Bar","Menu Item One",DEFAULT,10,DEFAULT` MyDialog008=`000,000,000,000,MENUITEM,"mbi2_MyDialog","mbi1_MyDialog","SubMenu Item One",DEFAULT,10,DEFAULT` MyDialog009=`000,000,000,000,MENUITEM,"mbi3_MyDialog","Dialog_Bar","Menu Item Two",DEFAULT,20,DEFAULT` ButtonPushed=Dialog("MyDialog")
AskLine, AskPassword, AskYesNo, IntControl, AskItemList, DialogProcOptions, DialogControlState, DialogControlGet, DialogControlSet, DialogObject, IntControl 4, IntControl 28, IntControl 33, IntControl 49, IntControl 62, IntControl 75