NewForm |
Description
Creates a new form. You must first create a form before you can add any controls. |
Syntax
[Set oFrm =] oDlg. NewForm ( [ Name ] ) |
Parameters
Part |
Description |
Set oFrm = |
(optional) Store a reference to the new form in the variable oFrm. This variable can be used to access the form's properties and methods |
oDlg |
A reference to the WshDialog.Kit automation object (as returned by the |
Name |
(optional) The unique name of the form. Defaults to "", if omitted. |
Standard Properties, Methods and Events (also see Custom properties further on)
Property |
Description |
||
BackColor |
Background color of the form (use the RGB function to assign a color) |
||
BorderStyle |
(read-only) Returns 3 to indicate a Fixed Dialog (not resizable), which has no maximize/minimize buttons, but can include a controlbox and title bar |
||
Caption |
Determines the text to be displayed in the form's title bar. You should use the CaptionEx property instead if you plan to modify either of the custom CloseBox, MinBox or TaskBar properties |
||
Enabled |
(boolean) Determines if the form can respond to user-generated events |
||
Height |
The height of the form in twips |
||
Icon |
Returns or sets the icon that is displayed for the controlbox in the topleft corner of the form (if enabled, see the custom CloseBox property below). |
||
Left |
The distance from the left edge of the screen in twips |
||
Picture |
Returns or sets a graphic to be displayed on the form. This property can be set to any other object's DragIcon, Icon, Image, or Picture property, or you can assign it a graphic returned by the LoadPic function |
||
Tag |
Can be used to store extra (string) information for the form |
||
Top |
The distance from the top edge of the screen in twips |
||
Visible |
(boolean) Determines whether the form is visible or hidden |
||
Width |
The width of the form in twips |
||
WindowState |
Determines the visual state of the form |
||
0 |
Normal (default) |
||
1 |
Minimized |
||
2 |
Maximized |
||
Method |
Description |
||
Hide |
Removes a form from the screen and sets its Visible property to False. |
||
Move |
Parameters: left [, top [, width [, height ]]] |
||
Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged |
|||
PrintForm |
Sends a bit-by-bit image of the form to the printer |
||
Refresh |
Forces a complete repaint of the form |
||
Show |
Use this method to display the form. Required parameter: style |
||
0 |
Modeless (not supported) |
||
1 |
Modal (default). No input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or unload a modal form (usually in response to some user action) before input to another form can occur. Although other forms in your application are disabled when a modal form is displayed, other applications aren't |
||
Event |
Description |
Event raised |
|
Activate |
Occurs when the form becomes active by using the Show or SetFocus methods |
*ACTIVATE |
|
Unload |
Occurs when the user closes the form, either by clicking the closebox, choosing Close from the control menu or pressing the ALT+F4 keys |
*CLOSE |
|
F1 - F12 |
Occurs when the user releases one of the function keys F1 through F12 |
*F1 - *F12 |
|
To be able to handle events you need to operate a form in callback mode. |
Custom Properties and Methods
Property |
Description |
|
CallBack |
(boolean) Each WshDialog form can operate in one of two ways, with or without callback. The default is to operate without callback. In this simple mode, a form will be dismissed (hidden) immediately after you click on a button or the closebox. With callback enabled however, you can react to the events generated by the various controls(click events and timer events), and perform some actions, while the form remains visible. When callback is used, you are responsible for dismissing the form at the appropriate moment in your event handling procedure |
|
CaptionEx |
Determines the text to be displayed in the form's title bar. Use the CaptionEx property instead of the Caption property if you plan to modify either of the CloseBox, MinBox or TaskBar properties too. The standard Caption property resets these to their original states. |
|
CloseBox |
(boolean) Determines if the form has a closebox and control menu. |
|
MinBox |
(boolean) Determines if the form has a minimize box (default False) |
|
StayOnTop |
(boolean) Determines if the form will stay on top (in front of all other windows) or not. The default is False |
|
TaskBar |
(boolean) Determines if the form is shown in the shell's taskbar. |
|
Method |
Description |
|
AutoSize |
Parameters: [ width [, height]] |
|
width |
(optional) Determines if the width of the form is automatically sized to the controls placed on it (default) or not. |
|
height |
(optional) Determines if the height of the form is automatically sized to the controls placed on it (default) or not. |
|
CancelLabelEdit |
Call this method inside the handler of a ListView's AfterLabelEdit event to cancel the current editing operation of a listitem's label. |
|
Clear |
Remove all controls from the form and unload the form from memory. Until you clear the form, all the controls remain accessible and you can still read out their values |
|
Ctl |
Required parameter: Name |
|
Returns a reference to the control with the specified Name. |
||
GetOptionButton |
Required parameter: Container |
|
Returns the (user defined) name of the selected optionbutton in a container. Option buttons are grouped inside a container. This can be the form itself, but usually is a frame control. You must specify the name of the frame control in which the optionbuttons are grouped or an empty string if the form itself is the container. |
||
LoadIcon |
Required parameter: icon file |
|
Use this method to assign an alternate icon to the form. Icon file is a string specifying a filename and can include folder and drive |
||
NewButton |
Add a commandbutton to the form |
|
NewCalendar |
Add a calendar to the form |
|
NewCheckBox |
Add a checkbox to the form |
|
NewDirListBox |
Add a directory listbox to the form |
|
NewDriveListBox |
Add a drive listbox to the form |
|
NewDropdownCombo |
Add a combobox with a 'dropdown combo' style to the form |
|
NewDropDownList |
Add a combobox with a 'dropdown list' style to the form |
|
NewFileListBox |
Add a file listbox to the form |
|
NewFrame |
Add a frame to the form |
|
NewImage |
Add an image to the form |
|
NewImageList |
Add an imagelist to the form |
|
NewImageListPicture |
Add a picture to an imagelist |
|
NewLabel |
Add a label to the form |
|
NewListBox |
Add a listbox to the form |
|
NewListView |
Add a listview to the form |
|
NewListViewFileItem |
Add a file-item to a listview |
|
NewMaskedEditBox |
Add a masked editbox to the form |
|
NewMultiLineTextBox |
Add a multiline textbox to the form |
|
NewOptionButton |
Add an optionbutton to the form |
|
NewProgressBar |
Add a progressbar to the form |
|
NewSlider |
Add a slider to the form |
|
NewTabs |
Add a tab control to the form |
|
NewTextBox |
Add a textbox to the form |
|
NewTimer |
Add a timer to the form |
|
NewTimerInterval |
Change a timer's interval |
|
NewUpdown |
Add an updown control to the form |
Example
Option Explicit Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_") 'Add a new form and store a reference to it in the variable oFrm Set oFrm = oDlg.NewForm("Sample") 'Add a frame control and some optionbuttons to the form oFrm.NewFrame "FRM1", 150, 800, 3100, 1575, "Options" oFrm.NewOptionButton "OBN1", 120, 300, 1000, 255, "Option1", True, "FRM1" oFrm.NewOptionButton "OBN2", 120, 600, 1000, 255, "Option2", False, "FRM1" oFrm.NewOptionButton "OBN3", 120, 900, 1000, 255, "Option3", False, "FRM1" 'Modify some properties of the form oFrm.Caption = "This is a sample WshDialog form" oFrm.Taskbar = True oFrm.AutoSize 'Show the form (modal) oFrm.Show 1 'Use a messagebox to show which optionbutton was selected MsgBox oFrm.GetOptionButton("FRM1") & " was selected" |