Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A UserDialog is described by a Begin Dialog...End Dialog block. To graphically add a UserDialog place the current selection in the code where you want the dialog and select Insert > UserForm  UserForm from the Scripting Development Environment.  

...

Use the controls on the left too to add items to design your form.  Hover your mouse over each item to understand what they are for.   When you are done, close the dialog and the code for the form will be inserted into your script. 

To graphically edit a UserDialog place the current selection in a UserDialog block and select Insert select Insert > UserForm  UserForm from the Scripting Development Environment.  The dialog will open to edit the previously created form.   

The following code is for an an OK and Cancel button.   

Code Block
languagevb
Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1
		OKButton 50,161,90,21
		CancelButton 210,161,90,21
	End Dialog
	Dim dlg As UserDialog
	Dialog dlg

...

Code Block
languagevb
' Code Module
Sub Main
	
	Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1
		OKButton 50,161,90,21
		CancelButton 210,161,90,21
	End Dialog
	Dim dlg As UserDialog
	rtn =Dialog(dlg)
	If rtn = 0 Then 'cancel pressed
		End
	End IIf

After adding a control, double-click to edit properties for each control.  The example below is for a text field in a dialog. 

...

The example below shows both fields entered. 

 

When closing the dialog with the Dialog Function field filled, you will get the prompt below.    You usually would click next and then the shell of the dialog function code will be added.   

 

 

With the form looking like below,

Image Added

the code in the editor will be.  

Code Block
languagevb
' Code Module
Sub Main
	
	Begin Dialog UserDialog 400,203, "NameMy ofExample Dialog",.examplefunction ' %GRID:10,7,1,1
		OKButtonText 5030,161,90,21
		CancelButton 210,161,90,21
	End Dialog
	Dim dlg As UserDialog
	rtn =Dialog(dlg)
	If rtn = 0 Then 'cancel pressed
		End
	End I

 

Image Removed

If you are going to use a dialog function, you need also reference that function on the Begin Dialog line as shown below.  The shell of the Dialog function is also shown in the code. 

Code Block
languagevb
' Code Module
Sub Main

	Begin Dialog UserDialog 400,203, "Name of Dialog", .dialogfunc ' %GRID:10,7,1,1
		OKButton 50,161,270,28,"AWR Example Text",.Text1
		OKButton 30,105,90,21
		CancelButton 210140,161105,90,21
	End Dialog
	Dim dlg As UserDialog
	rtnDialog =Dialog(dlg)
	If
rtnEnd =Sub
0
ThenRem 'cancelSee pressedDialogFunc 		End
	End If
End Sub
Function dialogfunchelp topic for more information.
Private Function examplefunction(DlgItem$, Action%, SuppValue%SuppValue&) _
 	As Boolean
 	Select Case Action%
 		Case 1 ' Dialog box initialization

 		Case 2 ' Value changing or button pressed
		Rem examplefunction 		= True ' Prevent button press from closing the dialog box
	Case 3 ' TextBox or ComboBox text changed

 		Case 4 ' Focus changed

 		Case 5 ' Idle
		Rem Wait 		.1 : examplefunction = True ' Continue getting idle actions
	Case 6 ' Function key

 	End Select
End Function