![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
Subroutine ShowAbout presents the splash screen as an about dialog. It disables the timer because it is not needed when the form is presented as an about dialog. ShowAbout makes the OK button visible so the user can close the dialog. It then presents the form modally. Since the dialog is presented modally, other parts of the application will not interact with the user until the OK button is clicked. This guarantees that the dialog will be completely displayed so the program does not need to use the Refresh command explicitly.
Public Sub ShowAbout()
SplashTimer.Enabled = False
CmdOk.Visible = True
Me.Show vbModal
End Sub
Presenting HelpThe ExpenseReporter application described in Chapters 1 and 2 uses a standard help system. Chapter 2 explained how to use the help compiler that comes with the Visual Basic Professional Edition to create a help file. Compiled help has several drawbacks. It is difficult to program, requiring an arcane system of footnotes to indicate index topics, keywords, and browse sequences. Compiling large help systems can be slow so making incremental changes is time-consuming. Rather than using a compiled help file, AppointmentBook displays help using a collection of HTML (Hypertext Markup Language) documents similar to those displayed on the World Wide Web. HTML documents have several advantages over compiled help files. They are plain-text files with text control tags so they are easy to edit. They do not require any compilation because they are interpreted when they are displayed. That means a single document in the help system can be modified without requiring recompilation of the entire help system. This makes incremental changes quick and easy. HTML documents are also designed to be distributed across a network. That makes it simple to place the help system at a single network location where many application users can share it. This capability is particularly attractive when all of the users are on a common network. Keeping the help files centralized saves space on the users computers and allows easy updating of the centralized help documents. For instance, this would allow a company to give its customers access to a constantly updated help system available on the World Wide Web. At the same time, HTML help does have several disadvantages that do not affect compiled help systems. Displaying a compiled help file is usually faster than displaying HTML documents. This is particularly true if the help documents are served remotely across a heavily used network. Duplicating an HTML help system requires copying many files. This makes installing the help system on a customers computer a bit awkward. Instead of installing a single compiled help file in a format that the user already understands, a potentially large set of files must be installed. An HTML help system is also restricted to using commands that are part of the hypertext markup language. This language is still evolving, but it currently does not provide a wide variety of layout and design features. Different document viewers and Web browsers may display HTML commands differently or not at all. The Table statement, for example, is interpreted differently by different browsers. This problem is reduced slightly if an application builds its own help browser, but it is even greater if the help system is to be placed on the World Wide Web. Finally, while the help compiler may not provide strong support for debugging a help project, it does detect certain kinds of errors. If the help topic file references a topic that does not exist, the compiler will issue a warning. References to remote documents in an HTML file are plain text. The system cannot know that the reference is invalid until someone actually tries to use that link to visit the document. That means HTML help systems must be carefully debugged with every link tested by hand. Even with all of these disadvantages, an HTML help system is ideal for certain applications. An application used within a large company is a perfect candidate. The help system can reside on the companys private network. If the application provides its own help browser, or if the company has standardized on a particular commercial Web browser, compatibility issues are not a problem. While a heavily loaded network may still give reduced performance, this is balanced by the space savings allowed by having the users share the help files. The next section describes the help browser provided by AppointmentBook and describes some of the HTML documents used by AppointmentBook.This chapter is too short to describe the entire hypertext markup language, but it does explain the most important HTML tags used by AppointmentBooks help system. Building a Help BrowserAn application could use a commercial Web browser to display HTML help pages. Commercial browsers, however, do not all display HTML documents in the same way. They also include many features of limited use in a help system, and they do not provide easy methods for connecting to an application. For example, if a browser was already displaying help on one topic, it would be difficult for the application to make the browser display help for a different topic. It would be annoying if the application displayed a new browser every time the user clicked on a field and pressed F1. AppointmentBook avoids these problems by using the WebBrowser control to build its own help system. This controls help file is Tools\Unsupprt\Webbrwsr\Webbrows.HLP on the Visual Basic 5 compact disk. Presenting Basic Help The WebBrowser control is fairly primitive. It allows a program to load and display an HTML document, but it is missing many of the features provided by more powerful Web browsers. For example, it does not give a program access to the HTML content it displays. Some of these missing functions are provided by the Internet transfer control, also included with Visual Basic 5. This control is described further in Chapters 18 and 19. AppointmentBooks URLHelpForm contains a WebBrowser control. The forms public PresentTopic and PresentURL subroutines give the main application command over the WebBrowser. The PresentURL subroutine takes as a parameter the URL (Uniform Resource Locator) of an HTML document. The URL gives the location of a document on the network. PresentURL uses the WebBrowsers Navigate command to open and display the indicated document. It then invokes the URLHelpForms Show method in case the form is not yet visible, and it uses the forms ZOrder method to move the form to the top of the stacking order.
Public Sub PresentURL(the_url As String)
Display the URL.
On Error Resume Next
Browser.Navigate the_url
On Error GoTo 0
Show the form if its not already visible.
Me.Show
Move the form to the top.
Me.ZOrder
End Sub
Subroutine PresentURL takes as a parameter a topic name. It adds the directory path defined by the HELP_DIR constant to the front of the name, and the string .htm to the end to make a complete URL. It then uses PresentURL to display the file referenced by the URL. AppointmentBook defines the constant HELP_DIR to be http://Beauty/HelpHTML/. Before you can run the program, you will need to change this value so it indicates the location of the help files on your computer. This can be a network address such as http://Beauty/HelpHTML/, or it can be a file name like D:\Ch3\HelpHTML\.
The location of the help files.
Private Const HELP_DIR = http://Beauty/HelpHTML/
Public Sub PresentTopic(topic As String)
PresentURL HELP_DIR & topic & .htm
End Sub
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
|