lhelp using HelpType set to htContext lazarus / 21-General ---------------------------------------------------------------------- Tdecnj · 2023-11-24 14:14 Hello, Is it possible to use a chm help file (made with Ms_Windows hhw) with lhelp (Lazarus 2.2.6 and FPC 3.2.2) with  HelpType set to htContext? I am trying for several days and the only thing i got it's an error windows with 2 messages : 'A help database was found for this topic, but this topic was not found...' and below 'Help context 4 not found.' (4 is the number of my Context help) The first one is rsHelpContextNotFound and the second is shrContextNotFound but looking at the code referencing this 2 messages (helpintfs.pas, lazhelpchm.pas, lazhelphtml.pas and lazhelpintf.pas )  I was not able to understand the problem. If I set HelpType  to htKeyword I got the help file on summary (it's better than the error message but it is not that I want). Alls my try were on Windows 10. I have read all the documents I have found on lhelp (chm, etc). It is possible that I missed something (english is not my mother tongue). Thanks. ---------------------------------------------------------------------- balazsszekely · 2023-11-24 14:27 Quote from: Tdecnj on November 24, 2023, 03:14:06 pmHello, Is it possible to use a chm help file (made with Ms_Windows hhw) with lhelp (Lazarus 2.2.6 and FPC 3.2.2) with  HelpType set to htContext? I am trying for several days and the only thing i got it's an error windows with 2 messages : 'A help database was found for this topic, but this topic was not found...' and below 'Help context 4 not found.' (4 is the number of my Context help) The first one is rsHelpContextNotFound and the second is shrContextNotFound but looking at the code referencing this 2 messages (helpintfs.pas, lazhelpchm.pas, lazhelphtml.pas and lazhelpintf.pas )  I was not able to understand the problem. If I set HelpType  to htKeyword I got the help file on summary (it's better than the error message but it is not that I want). Alls my try were on Windows 10. I have read all the documents I have found on lhelp (chm, etc). It is possible that I missed something (english is not my mother tongue). Thanks. Not exactly what you need, but very similar. https://wiki.lazarus.freepascal.org/Add_Help_to_Your_Application https://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.h tml#msg261731 ---------------------------------------------------------------------- Tdecnj · 2023-11-24 19:58 Thanks, I have readed these docs and they do not answer my initial question. ---------------------------------------------------------------------- wp · 2023-11-24 22:22 Created a little demo with a few controls (Edit HelpCtx = 2, Combobox HelpCtx = 3, Button HelpCtx = 4, ?-button calling HelpCtx 1) and wrote a chm file with HelpNDoc, to have something for testing. Never worked much with the internal help system, therefore, I started with what I have done before: Call help based on the htmlhelp unit which comes with FPC. I am attaching the project in this state demonstrating that help is working this way and the chm file is correct. Of course, this is a windows-only solution, and I'll try to look into the LCL Help database system in the next step. But cannot promise anything... ---------------------------------------------------------------------- Tdecnj · 2023-11-25 11:30 I knew this one and the code (in relation to help) in Lazstats : its works but only on Ms_Windows and I am looking for a solution for Linux that's why i wanted to use lhelp. Anyway, thanks for trying to help me. By the way i have an another question : who is responsible for closing lhelp? In my application (on Ms_Windows) when I quit with lhelp running, lhelp is not closed;  in Lazarus Ide when I quit with lhelp running, lhelp is closed. So the responsible is the application using lhelp. In my application, I am using LHelpConnector and CHMHelpDatabase, I suppose that is LHelpConnector the candidate to stop lhelp, but how? Or do I need to search lhelp in the running tasks and stop it running when I close the application? Thanks. ---------------------------------------------------------------------- wp · 2023-11-25 15:41 In the meantime, after some more experiments, I got the impression that TCHMHelpDatabase does not fully support the way of identifying help items by means of the HelpContext numbers. Switching to Help Keywords, on the other hand, works, also with LHelp. There is an issue, though, in my help files created by HelpNDoc: This authoring system puts the html files in the root of the chm file structure. Therefore the KeywordPrefix property needed by the CHMHelpdatabase must be empty - and this causes trouble in unit LazHelpCHM where the condition "(KeywordPrefix <> '')" inhibits further processing; after commenting this out I got my demo working correctly: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TCHMHelpDatabase.GetNodesForKeyword(const HelpKeyword: string;  var ListOfNodes: THelpNodeQueryList; var ErrMsg: string): TShowHelpResult;...  if not (csDesigning in ComponentState) and//    (KeywordPrefix<>'') and     // <---- MUST BE COMMENTED OUT    (LeftStr(HelpKeyword,length(KeywordPrefix))=KeywordPrefix) then  begin                    ... I found a way how to terminate LHelp with the main application: Add a handler to the form's OnDestroy and send an "mrClose" command to LHelp via IPC: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  LHelpControl;  // for "mrClose" procedure TForm1.FormDestroy(Sender: TObject);begin  if (LHelpConnector1.Connection <> nil) and LHelpConnector1.Connection.ServerRunning then    LHelpConnector1.Connection.RunMiscCommand(LHelpControl.mrClose);end; ---------------------------------------------------------------------- Tdecnj · 2023-11-25 18:39 Hello wp, I tried, on Ms_Windows 10, your code to close lhelp, it's work fine. Thank you very much for this help. (I will try it later on Linux- Ubuntu) I tried again to get a context help via htKeyword (I think that htContext is not implemented...) but i got only the summary of my help file not the page of the context help. I am probably doing something wrong. Thank you again for your help. ---------------------------------------------------------------------- wp · 2023-11-25 22:21 Quote from: Tdecnj on November 25, 2023, 07:39:45 pmI tried again to get a context help via htKeyword (I think that htContext is not implemented...) but i got only the summary of my help file not the page of the context help. I am probably doing something wrong. Strange... I assume that the controls have the correct help keywords for the pages that you want to see. Do you see the correct help pages when you replace LHelpConnector/CHMHelpDatabase by the htmlhelp unit that I mentioned in the other thread? I am attaching a modified version of one of the previous demos to show how to work with help keywords in the htmlhelp unit. I know this is for Windows only, but it is an easy check whether keywords are correct. ---------------------------------------------------------------------- wp · 2023-11-25 22:24 Another idea for Linux: There is a great chm viewer, kchmviewer, and of course, you can invoke it to display the help windows for you: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Process; procedure TForm1.FormCreate(Sender: TObject);var  chmfile: String;begin  chmFile := ChangeFileExt(Application.ExeName, '.chm');  if FileExists(chmfile) then begin    Application.HelpFile := chmfile;    Application.OnHelp := @HelpHandler;  end;end; // Call HTML help (.chm file)function TForm1.HelpHandler(Command:word; Data:PtrInt;  var CallHelp:Boolean): Boolean;var  topic: String;  process: TProcess;begin  topic := PChar(Data);  process := TProcess.Create(Self);  try    process.Executable := 'kchmviewer';    process.Parameters.Add('-showPage');    process.Parameters.Add(topic);    process.Parameters.Add(Application.HelpFile);    process.Execute;  finally    process.Free;  end;   // Don't call regular help  CallHelp := False;end; Unfortunately, this example displays a modal help window, but you certainly can fiddle with the TProcess options to make it non-modal, and it requires some book-keeping to make sure that the window is updated when F1 is pressed the next time. ---------------------------------------------------------------------- Tdecnj · 2023-11-26 15:46 Hello, I found why I could not obtain context help with htKeyword. The document wiki.lazarus.freepascal.org/Add_Help_to_Your_Application say in its example for chm, I quote : "Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  CHMHelpDatabase1.Filename := ChangeFileExt(Application.ExeName, '.chm');    CHMHelpDatabase1.KeywordPrefix := 'html/';    CHMHelpDatabase1.AutoRegister:=True;" I followed the example but there was an error : CHMHelpDatabase1.KeywordPrefix := 'html/'; should have been   CHMHelpDatabase1.KeywordPrefix := 'html'; without trailing slash. So if your help file is 'helpApplication.chm',  CHMHelpDatabase1.KeywordPrefix will be set to 'helpApplication' and in your control's HelpKeyword you will put 'helpApplication/topic1.htlm' : the context help with htKeyword will work. to wp : I knew kchmviewer (yes, it's great), I didn't think that i could use it in the same way we can use the MS_Windows help. Thanks. ---------------------------------------------------------------------- wp · 2023-11-26 16:23 Quote from: Tdecnj on November 26, 2023, 04:46:02 pmCHMHelpDatabase1.KeywordPrefix := 'html/'; should have been   CHMHelpDatabase1.KeywordPrefix := 'html'; without trailing slash.