|
Application Online Help |
|
|
Providing help is one of the most neglected areas of
application development. There are various reasons to Some programmers
tend to think that help is such a small job that it should be left to
non-programmers. This is not a valid argument since the person who creates
an application knows it better than anybody.
|
Asking someone else to create help for your
application would only slow the process because the other person would
need to have new and more information about the application. Another
reason is that, most programmers who want to take care of programming when
creating an application think that they are working double to create a
single program. This drives them to set this aspect aside and continue
only with the application, thinking that they can come back to take care
of help when the application is complete. What makes this unrealistic is
that, sometimes when they finish the application, they are "tired".
There are various small but effective techniques you
can use to provide help in your application: never neglect help.
|
At the time of this writing, you cannot create HTML Help in
Microsoft Windows 7. You may have to use Microsoft Windows XP. |
Practical
Learning: Introducing Help
|
|
- Start Microsoft Visual Basic
- Create a Windows Application named ClarksvilleIceCream1
- In the Solution Explorer, right-click Form1.vb and click Rename
- Type ClarksvilleIceCream.vb and press Enter
- In the Properties window, change the form's Text to
Clarksville Ice Cream
- Design the form as follows:
|
Control |
Name |
Text |
Additional Properties |
GroupBox |
grpIceCream |
|
|
Label |
|
Order Date: |
|
DateTimePicker |
DtpOrderDate |
|
Format: Short |
Label |
|
Order Time: |
|
DateTimePicker |
DtpOrderTime |
|
Format: Time ShowUpDown: True |
Label |
|
Flavor: |
|
ComboBox |
CboFlavors |
|
|
Label |
|
Container: |
|
ComboBox |
CboContainers |
|
|
Label |
|
Ingredient: |
|
ComboBox |
CboIngredients |
|
|
Label |
|
Scoops: |
|
TextBox |
TxtScoops |
1 |
TextAlign: Right |
Label |
|
Order Total: |
|
TextBox |
TxtOrderTotal |
0.00 |
TextAlign: Right |
Button |
BtnNewOrder |
New Order |
|
Button |
BtnCalculateTotal |
Calculate Total |
|
Button |
BtnClose |
Close |
|
|
- Click the combo box to the right of the Flavor label. Then, in the
Properties, click the ellipsis button
of Items property and create the list with:
Vanilla Cream of Cocoa Chocolate Chip
Cherry Coke Butter Pecan Chocolate Cookie Chunky
Butter Organic Strawberry Chocolate Brownies Caramel
Au Lait |
- Click OK
- Click the combo box to the right of the Container label. Then, in
the Properties, click the ellipsis button
of Items property and create the list with:
- Click OK
- Click the combo box to the right of the Ingredient label. Then, in
the Properties, click the ellipsis button
of Items property and create the list with:
None Peanuts Mixed Nuts M & M
Cookies |
- Click OK
- Double-click the New Order button to access its Click event and
implement it as follows:
Private Sub BtnNewOrderClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles BtnNewOrder.Click
' If the user clicks New Order, we reset the form with the default values
DtpOrderDate.Value = DateTime.Today
DtpOrderTime.Value = DateTime.Now
CboFlavors.Text = "Vanilla"
CboContainers.Text = "Cone"
CboIngredients.Text = "None"
TxtScoops.Text = "1"
TxtOrderTotal.Text = "0.00"
End Sub
- In the Class Name combo box, select BtnCalculateTotal
- In the Method Name combo box, select Click and implement the event
as follows:
Private Sub BtnCalculateTotalClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles BtnCalculateTotal.Click
Dim PriceContainer As Double
Dim PriceIngredient As Double
Dim PriceScoops As Double
Dim OrderTotal As Double
Dim NumberOfScoops As Integer = 1
' Find out what container the customer requested
' The price of a container depends on which one the customer selected
If CboContainers.Text = "Cone" Then
PriceContainer = 0.55
ElseIf CboContainers.Text = "Cup" Then
PriceContainer = 0.75
Else
PriceContainer = 1.15
End If
' If the customer selected an ingredient, which is not "None", add $.95
If CboIngredients.Text <> "None" Then
PriceIngredient = 0.95
End If
Try
' Get the number of scoops
NumberOfScoops = CInt(TxtScoops.Text)
If NumberOfScoops = 2 Then
PriceScoops = 2.55
ElseIf NumberOfScoops = 3 Then
PriceScoops = 3.25
Else
PriceScoops = 1.85
End If
Catch ex As Exception
MsgBox("The value you entered for the scoops is not valid" &
vbCrLf & "Only natural numbers such as 1, 2, or 3 are allowed" &
vbCrLf & "Please try again")
End Try
' Make sure the user selected a flavor,
' otherwise, there is no reason to process an order
If CboFlavors.Text <> "" Then
OrderTotal = PriceScoops + PriceContainer + PriceIngredient
TxtOrderTotal.Text = CStr(OrderTotal)
End If
End Sub
- In the Class Name combo box, select BtnClose
- In the Method Name combo box, select Click and implement the event
as follows:
Private Sub BtnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles BtnClose.Click
End
End Sub
- Test the application. Here is an example:
- Close the form and return to Visual Studio
One way you can provide simple help consists of
displaying short indicative messages on a status bar. To do this, you can
first create sections, called panels, on a status bar and then display the
necessary messages in the section of your choice. The message can be
anything but it should consist of just a few words to fit in its section
without going over board.
Practical
Learning: Helping Through a Status Bar
|
|
- Display the from and expand its bottom border a little bit
- On the Toolbox, click StatusStrip and click the bottom section of
the form
- In the Properties window, click Items and click its ellipsis
button
- In the Select Item and Add to List Below combo box, select
StatusLabel if necessary and click Add
On the right side, set the
Text to Ready
- Click OK
- Right-click the form and click View Code
- In the Class Name combo box, select DtpOrderDate
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub DtpOrderDateMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles DtpOrderDate.MouseMove
StatusStrip1.Items(0).Text = "Specify the date this order was processed"
End Sub
- In the Class Name combo box, select DtpOrderTime
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub DtpOrderTimeMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles DtpOrderTime.MouseMove
StatusStrip1.Items(0).Text = "Specify the time this order was processed"
End Sub
- In the Class Name combo box, select CboFlavors
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub CboFlavorsMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles CboFlavors.MouseMove
StatusStrip1.Items(0).Text = "Select the customer's desired flavor"
End Sub
- In the Class Name combo box, select CboContainers
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub CboContainersMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles CboContainers.MouseMove
StatusStrip1.Items(0).Text =
"Select the type of object that will contain the ice cream"
End Sub
- In the Class Name combo box, select CboIngredients
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub CboIngredientsMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles CboIngredients.MouseMove
StatusStrip1.Items(0).Text = "Select an ingredient to spice the ice cream"
End Sub
- In the Class Name combo box, select TxtScoops
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub TxtScoopsMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles TxtScoops.MouseMove
StatusStrip1.Items(0).Text =
"Select the number of scoops to fill the container"
End Sub
- In the Class Name combo box, select TxtOrderTotal
- In the Method Name combo box, select MouseMove and implement the
event as follows:
Private Sub TxtOrderTotalMouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs)
Handles TxtOrderTotal.MouseMove
StatusStrip1.Items(0).Text = "This displays the total of the order"
End Sub
- In the Class Name combo box, select grpIceCream
- In the Method Name combo box, select MouseHover and implement the
as follows:
Private Sub grpIceCreamMouseHover(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles grpIceCream.MouseHover
StatusStrip1.Items(0).Text = "Ready"
End Sub
- In the Class Name combo box, select (ClarksvilleIceCream Events)
- In the Method Name combo box, select MouseHover and implement the
as follows:
Private Sub ClarksvilleIceCreamMouseHover(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles Me.MouseHover
StatusStrip1.Items(0).Text = "Ready"
End Sub
- Test the application
- After using it, close the form and return to Visual Studio
A tool tip is a small yellow box that displays a word
or a group of words when the user positions the mouse on top of a control:
To create a tool tip system in a Visual Studio 2005
application, first add a ToolTip control to a form. After adding a ToolTip
control, the form and all controls on it receive a new field in the
Properties window. If the new ToolTip control is called ToolTip1, the new
field in the Properties window for each control is ToolTip on ToolTip1.
To display a tool tip for a control, first click it on the form. Then, in
the Properties window, click ToolTip on ToolTip1, and type the
desired tool tip.
Practical
Learning: Adding Tool Tips
|
|
- To prepare for tool tips, on the Toolbox, click ToolTip
and click the form
- On the form, click each control and, in the Properties window, set
its ToolTip On ToolTip property as follows:
Control |
ToolTip On ToolTip1 |
DtpOrderDate |
Click the arrow to select a date |
DtpOrderTime |
Click each section, then click one of the
arrows to change its value |
CboFlavors |
Click the arrow to display a list, then select
a flavor from the list |
CboContainers |
Click to display the list of containers and
select one |
CboIngedients |
Display the list of ingredients and make the
customer's choice |
TxtScoops |
Enter the number of scoops (1, 2, or 3) to
fill the container |
TxtOrderTotal |
This displays the total amount of this order |
BtnNewOrder |
Click here to reset the form |
BtnCalculateTotal |
Click here to calculate the total of the order |
BtnClose |
Click here to Close the form |
- Test the application
- Close it and return to Visual Studio
Online help is the system of providing help files with
an application. Online help is usually available from the main menu
through a menu group created under a Help category.
In the past, the techniques to provide or program
online help were not always easy. The early implementations of help were
created in a system called WinHelp. This required using a Rich Text Format
(rtf) file and appropriately formatting it. It is possible that, when
folks at Microsoft developed WinHelp, they had only Microsoft Word in
mind. It was difficult to get the required file ready if you were using
another application such as WordPad or WordPerfect... Creating the help
file was not enough. Once the file was ready, it had to be added to the
application, and appropriately. This back and forth gymnastic was a great
motivation for neglect. As if these difficulties were not enough, or
because of these difficulties, Microsoft created another system called
HTML Help. This neither solved most problems nor created an easier
solution. At this time, this HTML Help is widely used and many companies,
such as AutoDesk (AutoCAD) and Macromedia to name just two, have adopted
it . Many companies such as Borland, Jasc, just to name two, are still
using WinHelp. This indicates that HTML Help didn't solve all problems and
was not anonymously adopted.
Because HTML Help is the most supported help system by
Microsoft, we will use it. Also, it is easier to use HTML Help in a
Microsoft Visual Studio 2005 application than to use WinHelp.
Practical
Learning: Introducing Online Help
|
|
- To create a new form, on the main menu, click Project -> Add
Windows Form...
- In the Add New Item dialog box, set the name of the form to
Calculation, and click Add
- Design the new form as follows:
|
Control |
Name |
Text |
Additional Properties |
Label |
|
Order Total: |
|
TextBox |
TxtOrderTotal |
0.00 |
TextAlign: Right Modifier: Public |
Label |
|
Amount Tended: |
|
TextBox |
TxtAmountTended |
0.00 |
TextAlign: Right |
Button |
BtnCalculate |
Calculate |
|
Label |
|
Difference: |
|
TextBox |
TxtDifference |
0.00 |
TextAlign: Right |
Button |
BtnClose |
Close |
|
|
- Double-click the Calculate button and implement its Click event as
follows:
Private Sub BtnCalculateClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles BtnCalculate.Click
Dim TotalOrder As Double
Dim AmountTended As Double
Dim Difference As Double
' Get the value of the total order. Actually, this value
' will be provided by the main form
TotalOrder = CDbl(TxtOrderTotal.Text)
Try
' The amount tended will be entered by the user
AmountTended = CDbl(TxtAmountTended.Text)
Catch ex As Exception
MsgBox("The amount you entered is not " &
"valid - Please try again!")
End Try
' Calculate the difference of both values, assuming
' that the amount tended is higher
Difference = AmountTended - TotalOrder
' Display the result in the Difference text box
TxtDifference.Text = CStr(Difference)
End Sub
- In the Class Name combo box, select BtnClose
- In the Method Name combo box, select Click and implement its event
as follows:
Private Sub BtnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles BtnClose.Click
Close()
End Sub
- Display the first form (ClarksvilleIceCream.vb (Design))
- Add a new button to the bottom side of the form between the other
buttons
- Change its values in the Properties window as follows:
Name:
BtnDifference Text: Difference Enabled: False
ToolTip on ToolTip1: Click to calculate the amount owed to the
customer
- Double-click the Difference button and implement its Click event
as follows:
Private Sub BtnDifferenceClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles BtnDifference.Click
' Declare a variable for the Calculation form
Dim dlgCalculation As Calculation = New Calculation
' Transfer the current value of the Order Total text
' box from the main form to the other form
dlgCalculation.TxtOrderTotal.Text = TxtOrderTotal.Text
' Display the other form
dlgCalculation.ShowDialog()
End Sub
- Change the Click events of the Calculate Total and the New Order
buttons as follows:
Private Sub BtnNewOrderClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles BtnNewOrder.Click
' If the user clicks New Order, we reset the form with the default values
DtpOrderDate.Value = DateTime.Today
DtpOrderTime.Value = DateTime.Now
CboFlavors.Text = "Vanilla"
CboContainers.Text = "Cone"
CboIngredients.Text = "None"
TxtScoops.Text = "1"
TxtOrderTotal.Text = "0.00"
BtnDifference.Enabled = False
End Sub
Private Sub BtnCalculateTotalClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles BtnCalculateTotal.Click
. . . No Change
' Make sure the user selected a flavor,
' otherwise, there is no reason to process an order
If CboFlavors.Text <> "" Then
OrderTotal = PriceScoops + PriceContainer + PriceIngredient
End If
TxtOrderTotal.Text = CStr(OrderTotal)
BtnDifference.Enabled = True
End Sub
- Test the application. Here is an example:
- After using it, close it and return to Visual Studio
Context-sensitive help allows the user to get local
help on a particular control. This works by the user who can first click a
control and then press Shift+F1. This displays a yellow box with a word or
a group of words:
This help is easier to provide in a dialog box because
a dialog has a feature not available on a form. It consists of adding a
button with a question mark and then creating the words that would display
eventually. When you create this type of dialog box, the user can click
the question marked button and click a control. The user can also press
Shift+F1. This causes the mouse pointer to be equipped with a question
mark. The user can then click a control and a yellow box would appear for
that control, providing help.
To make it easy to provide online help in a Visual
Studio 2005application, the .NET Framework provides the HelpProvider
control. After adding this control to the application, the form and all
controls on it receive a new property labeled HelpString On
HelpProvider1. You can then type the desired string in the field of
the Properties window for each control that would display
context-sensitive help.
Practical
Learning: Using Context-Sensitive Help
|
|
- Display the Calculation form and click an area to select the form
- Change the following values of the form in the Properties window:
FormBorderStyle: FixedDialog HelpButton: True MaximizeBox:
False MinimizeBox: False ShowInTaskbar: False
- In the Components section of the Toolbox, click HelpProvider and
click the form
- Using the Properties window, change the following values for the
indicated controls:
Control |
HelpString On HelpProvider1 |
TxtOrderTotal |
This is the total amount of the
current order |
TxtAmountTended |
This is the amount the customer
tended |
BtnCalculate |
Click here to calculate the
difference between the amount tended and the total price of
the order |
TxtDifference |
This displays the difference
between the amount tended and the total of the order |
BtnClose |
Click here to close the dialog box |
- Execute the application
- When it displays, process an order and click the Calculate
Difference button
- In the Calculation dialog box, click the question mark button in
the title bar and click on the text boxes or buttons
- After using the application, close the forms and return to Visual
Studio
- Display the main form (ClarksvilleIceCream.vb (Design))
- To add a menu to the application, on the Toolbox, click MenuStrip
and click the form
- On the form, click Type Here. Type &File and press
the down arrow key
- Type E&xit and press Enter
- On the right side of File (on the form), click Type Here
- Type &Help and press the down arrow key
- Type &Contents... and press the down arrow key
- Type &Index... and press the down arrow key
- Type &Search... and press Enter
- On the form, click File and double-click Exit
- Implement the event as follows:
Private Sub ExitToolStripMenuItemClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles ExitToolStripMenuItem.Click
Close()
End Sub
- Test the application then close it and return to Visual Studio
|
|