Sign in Join
Wiki copytemporary

Add Help to Your Application/ru

Deutsch · English · Español · Français · Русский · 中文(中国)

LCL поставляется со справочной системой и позволяет создавать справку для ваших собственных приложений.

Быстрый старт

Откройте пример приложения из examples/helphtml/.

Этот проект показывает как использовать компоненты HTML-справки. Разместите их на форме Вашего проекта. Настройте пути и создайте несколько HTML-файлов. Затем задайте свойства HelpKeyword для элементов управления, описываемых в этих файлах.

Посмотрите раздел CHM если хотите использовать CHM-файлы вместо HTML-файлов.

Здесь есть очень хороший и простой пример использования CHM (chmdemo.zip): http://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.html#msg261731

Основы справочной системы в LCL

Справочная система, создаваемая с помощью LCL, состоит из двух частей: "базы данных справочной системы" (набора HTML/XML/CHM-файлов) и средства просмотра справочной системы. База данных справки содержит сопоставление ключевых слов (ID, node, message, pascal, ...) со страницей справки (или web-сайтом, или...). Средство просмотра справки вызывается базой данных справки для отображения справки пользователю.

When help is requested, the LCL queries each registered THelpDatabase and each database can return a list of entries. If several entries are returned, the LCL asks the user to choose an entry. Then the LCL asks the database to show the help for the entry. The database extracts the help content and asks the LCL for a viewer that supports the mime type of the content. Finally, the viewer shows the help content.

CHM

Context-sensitive CHM application help can be used from Lazarus 1.0 and later.

A demonstration program is included that shows how to include context-sensitive help using CHM and the lhelp CHM viewer (the same one that is used for IDE help by default). Please see ${lazarusdir}/components/chmhelp/democontrol/.

You can write your own CHM files, e.g. with the now ancient Microsoft HTML Workshop or with the new Lazarus chmmaker tools in $(lazarusdir)/tools/chmmaker You can use a TCHMHelpDatabase control like the THTMLHelpDatabase control described below.

The advantages of using the CHM system are a smaller, self contained help file instead of multiple files. On the other hand, not every system has a CHM viewer installed by default, so you might want to include lhelp, a CHM viewer written in Pascal and included with the Lazarus sources (components/chmhelp/lhelp/lhelp.lpi).

Using LHelp

pascal
// Example with both chm file and LHelp.exe in Application folder.
Procedure TForm1.FormCreate(Sender: TObject);
Begin
  If FileExists(ChangeFileExt(Application.ExeName, '.chm')) Then
  Begin
    CHMHelpDatabase1.Filename := ChangeFileExt(Application.ExeName, '.chm');
    CHMHelpDatabase1.KeywordPrefix := 'test';
    CHMHelpDatabase1.AutoRegister:=True;

    LHelpConnector1.LHelpPath := IncludeTrailingBackSlash(ExtractFileDir(Application.ExeName)) + 'lhelp.exe';
    LHelpConnector1.AutoRegister:=True;
  end
  Else
    mnuHelpMain.Enabled := False;
End; 

Procedure TForm1.Button1Click(Sender: TObject);
Begin
  If mnuHelpMain.Enabled Then  
    ShowHelpOrErrorForKeyword('','test/Main.html');
    //ShowTableOfContents;  (Not implemented for TCHMHelpDatabase)
End;

HTML

The LCL provides two components to use HTML files for help: THTMLHelpDatabase and THTMLBrowserHelpViewer. To see the HTML help, see the lazarus example examples/helphtml/htmlhelp1.lpi.

Setup HTML help for your application

Lazarus help items Adding HTML help to your application is easy:

Creating a help entry

When running the program you can focus the edit control and press F1 to invoke the help. Under macOS the help key sequence is Cmd-? (or Cmd+Shift+? depending on your keyboard layout).

Note: Some window managers, widget set combinations do not pass F1 to the LCL.

INF (using fpGUI's DocView help viewer)

See the message and example project included in the Lazarus Forums. 1

It shows a fully working example of an LCL application using fpGUI's DocView help viewer. It shows context sensitive help and general help.

For example:

See also


From the Free Pascal wiki, page "Add Help to Your Application/ru", as it stood on 2021-09-13 after a change by DmitrySokolov, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.