For the purpose of this example we require four main objects on our form.
| Object | Name | Usage Description |
| Text Box | txtDescription | View and Set CustomTask Description Property |
| Text Box | txtMyProperty | View and Set custom CustomTask MyProperty Property (See Page 1) |
| Command Button | cmdOK | Close Form, saving Properties |
| Command Button | cmdCancel | Close Form, without saving Properties |
The code behind the form is fairly simple. In the Form_Load event you read the properties and
display them on the form. The cmdOK_Click event is used to save the properties back to the CustomTask.
|
Option Explicit
Private Sub Form_Load()
'Get Reference to our CustomTask
Dim oCustomTask As MyCustomTaskUI.CustomTask
Set oCustomTask = oTask.CustomTask
'Set the form object values from our Task/CustomTask properties
txtDescription.Text = oTask.Description
txtMyProperty.Text = oCustomTask.MyProperty
Set oCustomTask = Nothing
End Sub
Private Sub cmdOK_Click()
' Validate Properties
If txtMyProperty.Text = "" Then
MsgBox "Please enter a value for MyProperty", vbCritical, App.Title
Exit Sub
End If
'Get Reference to our CustomTask
Dim oCustomTask As MyCustomTaskUI.CustomTask
Set oCustomTask = oTask.CustomTask
'Save the form settings back to the Task/CustomTask
oTask.Description = txtDescription.Text
oCustomTask.MyProperty = txtMyProperty.Text
Set oCustomTask = Nothing
Unload Me
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
|
Now you can compile the DLL and Register it through Enterprise Manager.
- Open an existing or new package
- From the Task menu, select Register Custom Task...
- Complete the Register Custom Task dialog and click OK
- Your new CustomTask will now be available from the Tasks toolbar and menu
Whilst this CustomTask does nothing more than display a few message boxes, these in themselves
are useful in determining when the different events are raised. The code for this CustomTask
is available for download below, as a Visual Basic 5 project.
Please note that this program is provided without any warranty or assurances of any kind.
Use it at your own risk. Commercial distribution or distribution for profit in any form is strictly forbidden without prior permission from the author.
Download MyCustomTaskUI (~11K).