Home>>Programming>>C++Builder>> » How to Register the Help Selectors and Help viewers in C Builder

How to Register the Help Selectors and Help viewers in C Builder

Last Updated on September 8, 2018 By hcyaobin

For the Help Manager to communicate with them, objects that implement ICustomHelpViewer, IExtendedHelpViewer, ISpecialWinHelpViewer, and IHelpSelector must register with the Help Manager.
To register Help system objects with the Help Manager, you need to:

  • Register the Help Selector.
  • Register the Help viewer.

Registering Help selectors

The unit that contains the object implementation must use either Forms in the VCL or QForms in CLX. An instance of the object must be declared in the .cpp file of the implementing unit.
The implementing unit must register the Help selector through the HelpSystem property of the global Application object:

Application->HelpSystem->AssignHelpSelector(myHelpSelectorInstance)

This procedure does not return a value.

Registering Help viewers

The unit that contains the object implementation must use HelpIntfs. An instance of the object must be declared in the header file of the implementing unit.
The implementing unit must include a pragma startup directive that calls a method that assigns the instance variable and passes it to the function RegisterViewer. RegisterViewer is a flat function exported by HelpIntfs.pas, which takes as an argument an ICustomHelpViewer and returns an IHelpManager. The IHelpManager should be stored for future use.

The corresponding .cpp file contains the code to register the interface. For the interface described above, this registration code looks like the following:

void InitServices()
{
THelpImplementor GlobalClass;
Global = dynamic_cast(GlobalClass);
Global->AddRef;
HelpIntfs::RegisterViewer(Global, GlobalClass->Manager);
}
#pragma startup InitServices

Note: The Help Manager object must be freed in the destructor for the GlobalClass object if it has not already been freed.

Add a Comment

Your email address will not be published. Required fields are marked *