You can make an ActiveX Control provide context-sensitive help on the currently selected control, property, or event by modifying the .ODL file. This article gives an example of modifying the help file for GENERIC. You can also examine the sample TESTHELP, which demonstrates how to create an ActiveX control with tooltips and Help.
The help file for a control is given by the help-file attribute in the library declaration in the .ODL file. In the following code, GENERIC.HLP is the help file for the control.
[uuid(5CE3E2E3-8D26-101B-B883-444553540000), version(1.0),
helpstring("GENERIC ActiveX Control module"),
helpfile("GENERIC.HLP")]
library GENERICLib
The associated GENERIC.HPJ file lists help-context attributes for each of the help topics:
[MAP]
GENERIC 10
GenericShape 50
FlashColor 60
ClickIn 70
ClickOut 80
To specify the help topic ID for help on the control, add the help-context attribute 10
to the coclass declaration in GENERIC.ODL, as follows:
[ uuid(5CE3E2E0-8D26-101B-B883-444553540000),
helpstring("GENERIC Control"), helpcontext(10)]
coclass CGENERIC
To specify the help topic ID for a control property, add the help-context attribute to the property declaration in the property list. The following code adds a help-context ID of 50
and 60
for the GenericShape
and FlashColor
properties, respectively:
[ uuid(5CE3E2E1-8D26-101B-B883-444553540000),
helpstring("Dispatch interface for GENERIC Control") ]
dispinterface _DGENERIC
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CGENERICCtrl)
[id(3), helpcontext(50)] GenericShapeConstants
GenericShape;
[id(1), helpcontext(60)] OLE_COLOR FlashColor;
[id(4)] BSTR FontName;
[id(5)] boolean FontBold;
[id(6)] boolean FontItalic;
[id(7)] boolean FontStrikethru;
[id(8)] boolean FontUnderline;
[id(9)] float FontSize;
[id(DISPID_BACKCOLOR), bindable, requestedit]
OLE_COLOR
BackColor
;
[id(DISPID_CAPTION), bindable, requestedit] BSTR
Caption;
[id(DISPID_FONT), bindable] IFontDisp* Font;
[id(DISPID_BORDERSTYLE), bindable, requestedit]
BorderStyleConstants BorderStyle;
[id(DISPID_ENABLED), bindable, requestedit] boolean
Enabled;
[id(2)] MousePointerConstants MousePointer;
[id(10)] IPictureDisp* MouseIcon;
//}}AFX_ODL_PROP
To specify the help topic ID for a control event, add the helpcontext-attribute to the event declaration in the event list. The following code adds a help-context ID of 70
and 80
for the ClickIn
and ClickOut
events, respectively:
[ uuid(5CE3E2E2-8D26-101B-B883-444553540000),
helpstring("Event interface for GENERIC Control") ]
dispinterface _DGENERICEvents
{
properties:
// Event interface has no properties
methods:
// NOTE - ClassWizard will maintain event information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_EVENT(CGENERICCtrl)
[id(1), helpcontext(70)] void ClickIn(float* X, float* Y,
BSTR* Caption);
[id(2), helpcontext(80)] void ClickOut();
//}}AFX_ODL_EVENT
};