Creating IDE Help

From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) 日本語 (ja) русский (ru)


The IDE can search help for various things and there are various sources in various help formats. Here is a short list to understand the complexity:

  • FPC messages: compiler message like Error: Illegal enum minimum-size specifier. The IDE has a default built-in to search for the FPCSrcDir/compiler/msg/errore.msg file, search the message there and show the corresponding comment. The comments contain Latex tags which are stripped. At the moment a simple MessageDlg is shown. Some notorious messages need more explanation and are manually connected to URLs.
  • IDE windows, dialogs and controls:
  • Pascal sources:
  • FPC keywords:
  • FPC directives:
  • IDE directives:

Demos and explore

You can see the currently installed help under View / IDE Internals / About IDE / Help.

There is a test and demonstration package under examples/idehelp/demoidehelp.lpk. It contains example code how you can add help to the IDE.

To show your help in the user's browser see examples/helphtml/htmlhelp1.lpi.

To show HTML help in a LCL control see examples/htmlhelp_ipro/htmlhelpsample.lpi.

Help for LCL units

Whenever the user presses F1 for an Object Inspector property or on an identifier in the source editor the IDE searches the declaration and invokes the HTML viewer for the fpdoc item. The items can be edited easily via the FPDoc Editor tool.

You can see the state of the LCL documentation here: LCL Documentation Roadmap.

Help for IDE windows

This feature exists since 0.9.15.

The help for the IDE windows (i.e. 'Object Inspector' or the 'Compiler Options') are documented in this wiki. The IDE has a mapping file docs/IDEWindowHelpTree.xml, which contains the paths from the various IDE forms/controls to wiki pages. This mapping file is edited via an editor that is shown at any place in the IDE via Ctrl+ Shift+F1, except for controls that catch all keys, like synedit. You can set the shortcut in the editor options -> key mapping.

The root page of the IDE window docs is Lazarus IDE.


  • Open the project options: Project / Project Options
  • Open the help editor: Shift+Ctrl+F1


  • To the left, you can see all controls of the project options dialog. You can see there are also the compiler options.
  • Select the ProjectApplicationOptionsFrame
  • Click Create Help node. This will create a new item on the right.
  • Check Has Help
  • Check Is a root control. All controls on the frame should use the help on our new help page.
  • Change the path to Project_Options



The TreeView in the IDE options dialog redirects the help to the help of the selected frame:


procedure TIDEOptionsDialog.CategoryTreeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  Command: Word;
  Command := EditorOpts.KeyMap.TranslateKey(Key,Shift,nil);
  if (Command=ecContextHelp) and (PrevEditor <> nil) then begin

Help for FPC keywords

You can register a help for fpc keywords. Note: One database can handle multiple contexts, for example help for fpc keywords, help for sources and help for messages.

  IDEHelpIntfs, HelpIntfs, LazHelpIntf, LazHelpHTML...

  { TSimpleFPCKeywordHelpDatabase }

  TSimpleFPCKeywordHelpDatabase = class(THTMLHelpDatabase) // you can use any type of database you like
    FKeywordPrefixNode: THelpNode;
    function GetNodesForKeyword(const HelpKeyword: string;
                        var ListOfNodes: THelpNodeQueryList; var ErrMsg: string
                        ): TShowHelpResult; override;
    function ShowHelp(Query: THelpQuery; BaseNode, NewNode: THelpNode;
                      QueryItem: THelpQueryItem;
                      var ErrMsg: string): TShowHelpResult; override;

function TSimpleFPCKeywordHelpDatabase.GetNodesForKeyword(
  const HelpKeyword: string; var ListOfNodes: THelpNodeQueryList;
  var ErrMsg: string): TShowHelpResult;
  KeyWord: String;
  if (csDesigning in ComponentState) then exit;
  if (FPCKeyWordHelpPrefix<>'')
  and (LeftStr(HelpKeyword,length(FPCKeyWordHelpPrefix))=FPCKeyWordHelpPrefix) then begin
    // HelpKeyword starts with KeywordPrefix
    // test: testfcpkeyword
    if KeyWord='testfcpkeyword' then begin
      // this help database knows this keyword
      // => add a node, so that if there are several possibilities the IDE can
      //    show the user a dialog to choose
      // Note: In your own database you can create one dummy node or
      // one node per keyword or one node per group of keywords
      // or whatever you like.
      if FKeywordPrefixNode=nil then
      FKeywordPrefixNode.Title:='Pascal keyword '+KeyWord;

function TSimpleFPCKeywordHelpDatabase.ShowHelp(Query: THelpQuery; BaseNode,
  NewNode: THelpNode; QueryItem: THelpQueryItem; var ErrMsg: string
  ): TShowHelpResult;
  KeywordQuery: THelpQueryKeyword;
  KeyWord: String;
  if not (Query is THelpQueryKeyword) then exit;
  debugln(['TSimpleFPCKeywordHelpDatabase.ShowHelp Keyword=',Keyword]);
  // ShowURL ...

procedure Register;

Help for Messages

This feature exists since 0.9.15 and requires the FPC sources installed locally.

This is invoked when the user presses F1 or uses the Help menu item of the message window.

Normally the IDE will search the errore.msg file in the FPC sources and show the comment for the message. But some messages like unit not found need extra help. The following describes how to do that:

To add a wiki help page for a message, do the following:

  • Create a wiki page under Build messages
  • Right click on messages window / Edit help
  • This shows the editor for message additions.


The items are stored in <lazarusdir>/docs/additionalmsghelp.xml.

Adding Kylix help

For wow to use the Borland Help files within the IDE editor, see Adding Kylix Help.