The information in this article applies to:
SUMMARYMORE INFORMATIONThe following file is available for download from the Microsoft Software Library: WTHelp.exe
NOTE: Four of these files ship with Visual FoxPro.
To work with the sample files, extract them into a directory of your choice and set the Visual FoxPro default to the directory you choose. Help2.bmp is one of the sample graphics files found in the ...\Graphics\Bitmaps\TlBr_W95 folder in the VFP\Samples folder with Visual FoxPro 5.x or in the Common folder for Visual Studio or Visual FoxPro 6.0. The three files, Whatthis.hlp, Whatthis.hpj and Whatthis.rtf, are a sample Windows Help file, the Help project file, and the Help text source rich text file. These files ship with Visual FoxPro and are found in the ...\Solution\Forms folder, which is found in the VFP\Samples folder with Visual FoxPro 5.x or the Visual Studio\MSDN98\98vs\1033\Samples\VFP98 folder with Visual Studio 6.0. These files have not been modified and are included to provide a sample Help file with WhatsThisHelp ID numbers. The Help text in this Help file does not match the controls on the sample form included herein. This is just an illustration. The remaining files listed in the previous table were created for this sample. The WhatsThisHelp.vcx and .vct files are a visual class library that contains the toolbar class definition that is used with the sample form. The sample form files are WhatsThis.scx and .sct. Working with the Sample FormTo see the problem and the workaround, run the WhatsThis.scx form. Follow these steps when the form is running:
The Sample CodeThe key code in the sample that enables you to call the proper WhatsThisHelp topic for the toolbar buttons is in either the MouseDown or MouseMove events for the toolbar buttons. The ToolButton with the caption of 5 has the code in the MouseMove. The ToolButton with the caption of 4 and the buttons on the form have the code in the MouseDown event. Placing the code in the MouseMove event is easier to implement, but it does not have the same functionality as the real WhatsThisHelp button. The code is as follows:
You do not need the ELSE portion of the IF...ENDIF block if you are using
the MouseMove event.
When the user clicks the simulated WhatsThisHelp button on the toolbar, it is disabled. Then, when the user click the toolbar button, the MouseDown event fires, which checks to see if the simulated WhatsThisHelp button is disabled and if the user used the left mouse button. If so, the WhatsThisHelpID of the toolbar is set to the WhatsThisHelpID of the toolbar button that was clicked. Following this, the ShowWhatsThis method of the toolbar is called to display the WhatsThisHelpID that is assigned to the toolbar. The NODEFAULT keyword has been placed in the MouseUp event to prevent the ToolButton's click event from firing. Therefore, when you do not want the WhatThisHelp, the MouseDown has to call the click event. In the code above, this only happens if the user uses the left mouse button. This is not necessary when the WhatsThisHelp is called from the MouseMove event. Similar code is required in the MouseDown and MouseUp events of the objects on the form to allow them to work with the simulated WhatsThisHelp button on the toolbar. In addition, the WhatsThisHelp button on the form cancels if the user presses the ESC key. This has also been implemented in the simulated WhatsThisHelp button on the toolbar. To do this, the ESC key needs to be trapped on the form. In the click method of the simulated WhatsThisHelp button, the form's KeyPreview property is set to true(.T.). The following code is in the KeyPress event of the form:
This code checks to see if the user depressed the simulated WhatsThisHelp
button on the toolbar. If so, default KeyPress actions are disabled with
NODEFAULT. Note that you cannot press the SPACEBAR to fire the Quit
button's click event and quit the form. Next, the nKeyCode is checked to
see if the user pressed the ESC key. If so, the simulated WhatsThisHelp
button is re-enabled and the form's KeyPreview property is set back to
false(.F.).
The Click event of the form has been programmed to behave differently if the user uses the simulated WhatsThisHelp button on the toolbar instead of the WhatsThisHelp button on the form. The following code is in the MouseDown event of the form to reset the simulated WhatsThisHelp button:
You could place this code in the MouseDown event of any of the objects on
the form so that WhatsThisHelp would not be available to the objects if the
user presses the simulated WhatsThisHelp button on the toolbar.
The WhatsThisHelpIDs for the Help file topics are in the Whatthis.hpj file. You can open this file in Notepad or Visual FoxPro (MODIFY FILE whatthis.hpj). Look in the [MAP] section for the ID numbers. The following table lists all the objects in the formset and the settings for the WhatsThisHelpID:
SYMPTOMSThe WhatsThisHelpID property of the command buttons on a toolbar is ignored when you use the WhatsThisHelp button on a form to get "What's This Help" for objects on the form. RESOLUTION
To work around this, you can place a WhatsThisHelp button on the toolbar to
provide "What's This Help" for the buttons on the toolbar. WTHelp.exe
contains a sample form with a toolbar to illustrate this workaround.
Additional query words:
Keywords : kbfile kbsample kbOOP kbVFp500abug kbVFp600bug |
Last Reviewed: November 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |