FP2000: How to Use Microsoft Forms 2.0 ActiveX Controls
ID: Q208272
|
The information in this article applies to:
WARNING:
The Microsoft Forms 2.0 package was not designed to work outside of the Visual Basic for Applications environment. While individual developers might be successful in deploying it to containers such as Microsoft Internet Explorer, using Forms in this manner is neither recommended nor supported. For more information, see the following Knowledge Base article:
Q236458 Using Microsoft Forms 2.0 in Internet Explorer
SUMMARY
This article describes how to insert Microsoft Forms 2.0 ActiveX
controls in Microsoft FrontPage. In addition, the examples use Microsoft Visual Basic Scripting Edition (VBScript) code to set properties and respond to control events.
MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR
OWN RISK. Microsoft provides this code "as is" without warranty of any
kind, either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
ActiveX Controls are a suite of products and technologies that support Web
development, and enable software components to interact with one another.
ActiveX Controls are based on the Component Object Model (COM).
For more information about ActiveX Controls, please see the following
Microsoft World Wide Web site:
http://www.microsoft.com/com/tech/activex.asp
The Microsoft Forms 2.0 ActiveX Controls described in this article are
included with Microsoft FrontPage.
NOTE: Microsoft Forms 2.0 Controls are not placed automatically in the Insert ActiveX Control list. To do this, click Customize in the Insert ActiveX Control dialog box, select the appropriate control, and then click OK.
Message Box Example
- On the Insert menu, point to Advanced and click ActiveX Control.
- In the Select A Control list, select "Microsoft Forms 2.0
CommandButton."
- Click OK.
- Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
- In the Name box, type "CommandButton1" (without the quotation
marks). Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
Sub CommandButton1_Click()
' Displays a message box with text when the command
' button is clicked.
Msgbox "Hello World"
End sub
Label Example
- To insert a Microsoft Forms 2.0 Label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms
2.0 Label."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "Label1" (without the quotation marks).
Click OK.
- To insert a Microsoft Forms 2.0 command button, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton2" (without the quotation
marks). Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
Sub CommandButton2_Click()
' The following example fills a Label control with text
' when you click the command button.
Label1.Caption="Hello World"
End sub
Text Box Example
- To insert a Text Box, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0
TextBox." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
d. In the Name box, type "TextBox2" (without the quotation
marks). Click OK.
- Insert a Microsoft Forms 2.0 CommandButton by doing the following:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton3" (without the quotation
marks). Click OK.
- On the Tools menu, point to Macro and select Microsoft Script Editor.
- On the HTML menu, point to Script Block and select Server.
- Type the following between the Script tags:
Sub CommandButton3_Click()
' Text box will be filled in when you click the command
' button.
TextBox2.Text="Hello World"
End sub
Check Box Example
- Insert a Microsoft Forms 2.0 CheckBox Control by doing the following:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CheckBox." Click OK.
c. Right-click the ActiveX Control and select ActiveX Control
Properties from the Shortcut menu.
d. In the Name box, type "CheckBox1" (without the quotation marks).
e. Click OK.
- To insert a Microsoft Forms 2.0 command button, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0
CommandButton."
c. Click OK.
d. Right-click the ActiveX Control, and select ActiveX Control
Properties from the Shortcut menu.
e. In the Name box, type "CommandButton4" (without the quotation
marks). Click OK
- To insert a Microsoft Forms 2.0 Label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
Label." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label2" (without the quotation marks).
e. In the Width box, enter 300.
f. Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
sub CommandButton4_Click()
' Evaluates the value of the check box and inserts text
' in the label when you click the command button.
if CheckBox1.Value=TRUE then Label2.Caption="The checkbox _
is checked"
if CheckBox1.Value=FALSE then Label2.Caption="The checkbox _
is not checked"
end sub
Option Button Example
- To insert a Microsoft Forms 2.0 option button, follow these steps:
a. In the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
OptionButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "OptionButton1" (without the quotation marks).
e. Click OK.
- To insert a Microsoft Forms 2.0 command button, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
CommandButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "CommandButton5" (without the quotation
marks).
e. Click OK.
- To insert a Microsoft Forms 2.0 label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, click to select "Microsoft Forms 2.0 Label."
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label3" (without the quotation marks).
e. In the Width box, enter 300.
f. Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
Sub CommandButton5_Click()
' Evaluates the value of the option button and inserts
' text in the label when you click the command button.
If OptionButton1.Value=True Then
Label3.Caption = "This option is selected"
Else
Label3.Caption = "The other option is selected"
End If
End sub
Toggle Button Example
- To insert a Microsoft Forms 2.0 toggle button, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
ToggleButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ToggleButton1" (without the quotation
marks).
e. In the Width box, enter 100.
f. In the Height box, enter 30.
g. Click OK.
- On the Tools menu, point to Macro and select Microsoft Script Editor.
- On the HTML menu, point to Script Block and select Server.
- Type the following code between the Script tags:
sub ToggleButton1_Click()
' Evaluates the value of the toggle button and inserts text
' in the label when you click the command button.
If ToggleButton1.Value = True Then
ToggleButton1.Caption = "DEPRESSED"
Else
ToggleButton1.Caption = ""
End If
End Sub
Spin Button Example
- To insert a Microsoft Forms 2.0 spin button, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
SpinButton." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "SpinButton1" (without the quotation
marks).
e. Click the Parameter tab and do the following:
1) In the Attribute name list, select Min and then click Modify.
2) In the Data box, type "-100" (without the quotation marks).
3) Click OK.
f. In the ActiveX Control Properties click Apply, and then click OK.
- To insert a Microsoft Forms 2.0 label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label4" (without the quotation marks).
e. Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
sub SpinButton1_SpinDown()
' Evaluates if the spin button has been clicked and
' inserts text in the label when you click the
' command button.
Label4.Caption = SpinButton1.Value
end sub
sub SpinButton1_SpinUp()
' Evaluates if the spin button has not been clicked
' and inserts text in the label when you click the
' command button.
Label4.Caption = SpinButton1.Value
end sub
Scroll Bar Example
- To insert a Microsoft Forms 2.0 scroll bar, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0
ScrollBar." Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ScrollBar1" (without the quotation
marks).
e. Click the Parameters tab. In the Attribute window, follow these
steps:
1) Select Min and then click Modify
2) In the Value box, type "-32766" (without the quotation marks).
3) Click OK.
f. Click Apply and then click OK.
- To insert a Microsoft Forms 2.0 label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label5" (without the quotation marks).
f. Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
Sub ScrollBar_Change()
' Evaluates the position of the marker on the scroll bar and
' inserts text in the label when the command button is
' clicked.
Label5.Caption = -(ScrollBar1.Value)
End sub
Combo Box Example
-
On the Insert menu, point to Advanced, and click ActiveX Control.
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 ComboBox."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "ComboBox1" (without the quotation
marks).
e. Click OK.
- To insert a Microsoft Forms 2.0 label, follow these steps:
a. On the Insert menu, point to Advanced, and click ActiveX Control.
b. In the Select A Control list, select "Microsoft Forms 2.0 Label."
Click OK.
c. Right-click the ActiveX Control, and select ActiveX Control
Properties.
d. In the Name box, type "Label7" (without the quotation marks).
e. In the Width box, enter 400.
f. Click OK.
- On the Tools menu, point to Macro, and select Microsoft Script Editor.
- On the HTML menu, point to Script Block, and select Server.
- Type the following code between the Script tags:
sub ComboBox1_Click()
' Evaluates which option in a combo box has been
' selected and fills in the resulting text in the label
' when the command button is clicked
Label7.Caption= "You have selected " & _
ComboBox1.List(ComboBox1.ListIndex)
end sub NOTE: A ComboBox requires you to write script that populates the
list with values in an array. The script should be inserted at the
top of the page so that it runs when your page is opened in a
Web browser.
- To insert the script to populate the Microsoft Forms 2.0 combo box, follow these steps:
a. On the Tools menu, point to Macro, and select Microsoft Script Editor.
b. On the HTML menu, point to Script Block, and select Server.
c. Type the following code between the Script tags:
NOTE: Place this code at the bottom of the Script box, after the
existing script, but before the last line that reads "end sub."
' Creates and populates the array used in the
' preceding list box example.
'
' Dimension array to populate the list box.
Dim ListBoxArray(2)
ListBoxArray(0)="RED"
ListBoxArray(1)="WHITE"
ListBoxArray(2)="BLUE"
ListBox1.List=ListBoxArray
Additional query words:
FP2K activex ie fpscript front page
Keywords : kbole kbdta fpedit fpactive fpscript kbInternet
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbinfo
|