TESTHELP: ActiveX Control with Tooltips and Help

Click to open or copy the TESTHELP project files.

The TESTHELP sample demonstrates how to use MFC to build an ActiveX control that has its own help file to display help for the user. Testhelp.ocx also shows how to add tooltips to an MFC ActiveX control. Specifically, this sample demonstrates how to:

  1. Display a tooltip for your ActiveX control.

  2. Toggle the tooltip on and off using the control's property page.

  3. Change the tooltip's text using the control’s property page.

  4. Enable the ActiveX control container's property frame Help button to display the control's help file when the Help button is clicked.

  5. Enable the "?" button in Developer Studio's Component Gallery so that the control's help file will be displayed when this control is chosen from Component Gallery and the "?" button is clicked.

  6. Display help at runtime when the control has the keyboard focus and F1 is pressed.

  7. Use the Font, BackColor, and ForeColor stock properties of an ActiveX control.

Running the Sample

The Help Project file and all of the Help Project's source files are also included in this sample. To build the help file, start Help Workshop, load the Testhelp.hpj file into Help Workshop, and click Compile on the File menu.

After you have built the TESTHELP sample, you will be able to use it in any ActiveX container application. Examples of ActiveX control containers are Visual C++, Visual Basic, and Test Container (Microsoft Developer Studio\VC98\bin\TSTCON32.EXE). Include the TESTHELP control in your container's project and run the project. The properties of the TESTHELP control can be set by bringing up the property dialog of your container. The properties you can set are described below.

General Property Page

  1. Type of Help to Use - This property determines how help will be used when the user presses F1 while the TESTHELP control has the keyboard focus. Help in a pop-up window means that when the user presses F1 while the TESTHELP control is running in a container and has the keyboard focus, a pop-up window with the "What is this thing?" topic from the Testhelp.hlp helpfile is displayed. Show the Whole Help File means that when the user presses F1 while the TESTHELP control is running in a container and has the keyboard focus, the entire Windows help program will come up displaying the contents topic of the Testhelp.hlp file.

  2. Use Control's Help File - When this box is checked, help will be displayed in the format determined by the Type of Help to Use property when the user presses F1 while the control is running in a container and has the keyboard focus.

  3. Use ToolTip for this Control - If this box is checked, a tooltip will be displayed over the control's window if the control is running in the container and the mouse cursor moves into and stops in the control's window. The text to be displayed is determined by the Tooltip Caption property.

  4. Tooltip Caption - This is the text to be displayed in a tooltip if the user chooses to show tooltips.

    Name1 - The name displayed at the top of the control.

    Name2 - The name displayed in the middle of the control.

    Name3 - The name displayed at the bottom of the control.

Color Property Page

Lets the user select colors to be used in painting this control.

Font Property Page

Lets the user specify the font used for the text on the control.