1.8. Add an About Box


VB 2005 now comes with several new templates that make developing a Windows application easy. Among the new templates are:


Explorer Form

Allows you to build applications similar to Windows Explorer, with a tree-like display on the left pane and a detailed view on the right pane.


About Box

Displays an About window listing detailed information (such as version number, copyright, credits, etc.) about the current application.


Login Form

Creates a standard login window to simplify the task of user authentication.


Splash Screen

Displays a welcome screen when your application is launched.

In this section, you will add an About box to your application using the About Box template. The About box for an application is displayed when a user selects Help About… and contains useful information about the application, including its manufacturer and version number. Much of the information in the About box is available from the application and its configuration files.

  1. First, you need to create an About box form. Right-click on the project name (WindowsApplication1) in Solution Explorer and select Add New Item…. Select the About Box template and accept the default name of AboutBox1.vb provided by Visual Studio 2005. Click Add (see Figure 1-27).

    Figure 1-27. Adding an About box to the project


    The AboutBox1.vb form will be added to your project, and Visual Studio 2005 will display a designer for the feature as shown in Figure 1-28.

  2. Let's personalize the form by adding an image of the cover for this book to replace the default pretzel-like image. Click the LogoPictureBox control and then, in the Property window for the control, click the "…" button of its Image property. This will display the Select Resource dialog window. Click the Import… button of the dialog to select your own image for the About box (C:\vbjumpstartpg.gif). Click OK (see Figure 1-29).

    Figure 1-28. The controls on the AboutBox1 window


    Figure 1-29. Selecting an image resource


    You can download the vbjumpstartpg.gif image from: http://www.oreilly.com/catalog/vbjumpstart/.


  3. Set the SizeMode property of the LogoPictureBox control to CenterImage.

  4. To configure the information about your application so that it can be displayed by the About box, right-click on the project name in Solution Explorer and then select Properties. In the Application tab, click on the Assembly Information… button (see Figure 1-30).

  5. Set the information as shown in Figure 1-31.

    Figure 1-30. Configuring project information


    Figure 1-31. Setting project information


  6. The AboutBox1 window should now look like the one shown in Figure 1-32.

  7. To link Form1 with the AboutBox1 window, expand the Help menu and double-click on the About… menu item (see Figure 1-33) to open the code-behind page for Form1 and generate a code stub for the About box selection event handler.

  8. Now add the line of code shown in bold to the code stub generated by Visual Studio, as shown in Example 1-4). You use the ShowDialog method of the dialog window to get the object display itself.

    Figure 1-32. The AboutBox1 window


    Figure 1-33. Coding the Help About… menu item


    Example 1-4. Help About… menu selection event handler
     Private Sub aboutToolStripMenuItem_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles aboutToolStripMenuItem.Click  AboutBox1.ShowDialog() End Sub 

  9. Finally, it's time to take your work for a trial run. Press F5 to run the application. Click Help About… and you will see the About box shown in Figure 1-34.



Visual Basic 2005 Jumpstart 2005
Visual Basic 2005 Jumpstart
ISBN: 059610071X
EAN: 2147483647
Year: 2005
Pages: 86
Authors: Wei-Meng Lee

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net