HOW TO IMPLEMENT PRACTICALLY WINHELP IN A VB6 APPLICATION By Joaquin Ximenez de Embun, Spain It can be done following these steps: 1. Linking Win Help with the Application 2. Linking Win Help pages with Application Controls 3. Making click options operative 4. Making the Menu Bar Help Menu operative 5. Hiding auxiliary controls STEP 1. Linking Win Help with the Application Once the Win Help is prepared using Shalom Help Maker it is necessary to link it to the VB6 application. First it is necessary to copy two Shalom generated files: the "*****.cnt" file and the help file (*****.hlp) to the same folder which contains the VB Application project. Then open the Applications "Properties" sheet and write down in the proper box the name of the help file (****.hlp). If you didn't copy both files (cnt and hlp) in the application folder you will need to specify the path altogether with help file name. Now the Win Help file is linked to the application and when it is running, if the F1 key is pressed, the help file opens at the initial Index page. You can achieve the same goal by assigning to the applications property HelpFile the name of the help file(App.HelpFile = ***.hlp) Hint: To open the application "Properties ".sheet: In the VB Editor, open the window "Project explorer". Select the first line, Project1(xxx-vbp) and right click with the mouse. A pop-up menu shows. Then select "Properties of Project1" STEP 2 Linking Win Help pages with Application Controls It is possible to link a given control to a specific page of the Win Help file. If you do so, when the focus of the application is set on that control and you press the F1 key, the Help file is open at the specific page chosen. All controls have a property whose name is HelpContexID. This property is an integer (of Long type) and if you make it equal to the number of the page crated in the Shalom Help Maker you have linked the control with that specific page. Now, when the F1 key is pressed, the applications seeks the control which has got ( or set) the focus at that moment and if it finds under the HelpContextID a figure which corresponds to a page of Win Help, it shows this page. Otherwise it shows the Index page. The property HelpContextID is available at the properties Window of the VB Editor. This also applies to the help items included as menus or submenus of the Menu Bar prepared using the Menu Editor of the VB Editor. If you have provided the appropriate HelpContextID property and you select (only select, with no clicking) the menu it is highlighted and then you are able of pressing F1 to show the Win Help file open at the chosen pages. (But it doesn't seem very practical to do so) STEP 3 Making click options operative Many times it should be interesting to have the Win help page available just clicking a control, a CommandButton, for example. To make available the help you need first that the focus is set at the control and then press F1. But Clicking doesn't mean automatically setting the focus. So you could do both things at design stage by writing in your BtnMenHelp button code: Private Sub BtnMenHelp_Click() BtnMenHelp.SetFocus SendKeys "{F1}" End Sub The sentence "Sendkeys" simulates the pressing of the specifed key (in this case F1), provided that the BtnMenHelp control is visible (Its Properety 2Visible" is set to True). This will make to appear then Win Help window open at the page indicated by the HelpContextID. But if we try to use this trick with the Menu Bar, we find that it is not possible because the only Property/Method/Event available for menu or submenu items as defined bu¡y the menu Editor is only the event "click" and we cannot set the focus. And if you click the chosen menu you shall be disappointed: it doesn't show the appropriate page of Win Help. We must do it indirectly as explained in next step. STEP 4 Making the Menu Bar Help Menu operative If you type for your Menu Bar help item named, for instance "MenBarHelpThis" the following: Private Sub MenBarHelpThis _Click() BtnMenHelp_Click End Sub and you implement the CommandButton "BtnMenHelp" as indicated in STEP 3, including the appropriate number of page in its HelpContextID property, you can, now click on your Menu Bar help item and have the expected answer. If have several Menu Bar items which must answer to its clicking, you must repeat this operation for all of them and create as many dummy CommanButtons as Menu Bar help items. But it could be simplifies by creating an array of dummy CommandButtons , say an array named BtnMenHelp() composed by 'n' CommandButtons going from 1 to 'n' (eliminate element '0' this time). It would be convenient that the Index and the HelContextID (and the caption too) have the same figure. Then every Menu Bar item is related to the individual CommandButton showing the appropriate Index for the page of the Win Help file to be chosen.: Private Sub MenBarHelpThis A_Click() BtnMenHelp_Click (1) End Sub Private Sub MenBarHelpThis B_Click() BtnMenHelp_Click (2) End Sub etc. Now, for whole array of CommandButtons, it is enough to write: Private Sub BtnMenHelp_Click(Index As Integer) BtnMenHelp(Index).SetFocus SendKeys "{F1}" End Sub It is convenient to place all dummy CommandButtons in a Frame control , say "FrameBtnHelp". In this way it will be easier to manage them, as it will be seen in next step. By the way, of course, if you don't like CommonButtons, you can use any other control available for clicking and setting the focus on it STEP 5 Hiding auxiliary controls But still it happens that we have some undesirable dummy controls we don't want to see. In order that everything works properly these dummy CommandButtons and the frame control "FrameBtnHelp" must have the property Visible set at true. To hide this dummy frame control there several possibilities. Lets see two of them which very easy. One possibility is to set the properties Top and Left of the Frame respectively higher than the Height and the Width properties of the form containing the dummy frame. It can be done using the Property windows of the controls and choosing the frame from the list displayed at the top of the window. (You can recover the visibility of the frame, changing again the >Top and Left properties) The other possibility is hiding the Frame behind another permanent control of the form. The dummy frame control can be reduced in size to assure that it is smaller than the control chosen to hide it. And if the frame is on top of the chosen control, you can send it behind just, selecting it and right clicking to open a pop-up menu with the corresponding option (you can also retrieve the visibility by sending back, in the same way , the control which covers the dummy frame control) To finish: This process is easier done than explained. Anyway, if somebody knows a better way to proceed, please tell us, so we will learn from more experienced programmers and we will be very grateful for it.