ACC: How to Create Pop-up Context-Sensitive Help (95/97)

Last reviewed: August 28, 1997
Article ID: Q141621
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

One alternative to displaying your application's online Help system in a separate window is to display it in a small, shaded pop-up window within your application. To do this, you can use the Windows API WinHelp() function with its HELP_CONTEXTPOPUP argument. This article describes how to implement such a Help system.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

This article also assumes that you are familiar with creating Windows Help files using the Windows Help Workshop.

MORE INFORMATION

The Windows API WinHelp() function supports a large number of options. The HELP_CONTEXTPOPUP option opens a shaded pop-up window for you to display Help in. This window is similar to the window that opens when you click a glossary entry (green, underlined text) in the Microsoft Access Help system.

To implement this feature you need to do the following:

  • Create a working Help system by setting the HelpContextID and HelpFile properties for your forms to a valid Windows Help file.
  • Redirect the F1 key to call a user-defined function that opens the Help file using the HELP_CONTEXTPOPUP option.

Note that jumping or branching to other Help topics from the pop-up Help window is not supported using the methods discussed in this article.

The following steps describe how to create the user-defined function to open the pop-up Help window and how to redirect the F1 key:

  1. Create a module and type the following lines in the Declarations section:

          Declare Function WinHelp Lib "user32" Alias "WinHelpA" _
    
                           (ByVal hwnd As Long, _
                            ByVal lpHelpFile As String, _
                            ByVal wCommand As Long, _
                            ByVal dwData As Long) As Long
          Public Const HELP_CONTEXTPOPUP = &H8&
    
       NOTE: You may have some Microsoft Windows API functions defined in an
       existing Microsoft Access library; therefore, your declarations may be
       duplicates. If you receive a duplicate procedure name error message,
       remove or comment out the declarations statement in your code.
    
    

  2. Type the following procedure:

          Function Help32() As Boolean
    
             On Local Error GoTo Help32_Err
             Dim Cid As Long, Result As Long
             On Error Resume Next
             ' Get the HelpContextID of the active control.
             ' The error is 2474 if no control is active.
             Cid = Screen.ActiveControl.HelpContextId
    
             If Cid = 0 Then
                ' There is no control context ID, so check the form and get
                ' the HelpContextID of the active form.
                ' The error is 2475 if no form is active.
                Cid = Screen.ActiveForm.HelpContextId
             End If
    
             ' If there is a context ID, open the Help file with context.
             ' Specify your custom Help file for the second argument.
             If Cid > 0 And Cid < 32767 Then
                Result = WinHelp(Application.hWndAccessApp, "C:\Myhelp.Hlp", _
                HELP_CONTEXTPOPUP, Cid)
                Help32 = True
             End If
    
          Help32_End:
             Exit Function
    
          Help32_Err:
             MsgBox Err.Description
             Resume Help32_End
          End Function
    
    

  3. Create the following new macro named AutoKeys to redirect the F1 key:

          Macro Name   Condition   Action
          --------------------------------
          {F1}                     RunCode
    
          AutoKeys Action
          -------------------------
          RunCode
             Function Name: Help32()
    
    

REFERENCES

For more information about creating Help files, refer to the online Help supplied Windows Help Workshop and the Help Workshop's training Cards.

For more information about HelpContextID, search the Help Index for "HelpContextID" or ask the Microsoft Access 97 Office Assistant.

Keywords          : kbusage PgmApi PgmHowTo
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.