Forum > General
Problem adding chm help to an application
msimeon:
I am developing a small application as a way to learn Lazarus, under Windows 10. I want a simple help in the form of a chm help file that gets open by clicking a button or a menu item. I have writen two html files, and produced a chm file using the Microsoft HTML Help Workshop.
The chm viewer triggered by double-clicking the chm file works fine. When I show the chm file from my application using the lhelp.exe viewer that comes with Lazarus, it does not work properly:
- the links to chapters are ok but the links to sections do not work
- the png images included in the html files do not show up
Any comment or pointer to documents or tutorials or exemples are welcome.
msimeon
JuhaManninen:
There are many reports about bugs in lhelp, including this one:
https://bugs.freepascal.org/view.php?id=14909
Unfortunately it is not perfect.
wp:
If your program will run only on Windows you can also apply the chm viewer of Windows:
* "use" unit htmlhelp in the main form of the project (htmlhelp is found in fpc/.../packages/winunits-base/src)
* in OnCreate of the main form add this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var chmfile: String;... chmfile := ChangeFileExt(Application.ExeName, '.chm'); if FileExists(chmfile) then begin Application.HelpFile := chmfile; Application.OnHelp := HelpHandler; end;
* Write a handler for the OnHelp event:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TMainForm.HelpHandler(Command:word; Data:Longint; var CallHelp:Boolean): Boolean;// Call online-helpbegin // Call HTML help (.chm file) htmlHelp.HtmlHelp(0, //Handle, // Application.Handle PChar(Application.HelpFile), HH_HELP_CONTEXT, Data); // Don't call regular help CallHelp := False;end;
* Assign the help context number defined in the chm file to each control for which you want to call help by pressing F1.I just re-checked this with an old project, it works.
msimeon:
Thanks for the quick feed back. I'll try it out and let you know.
MS
molly:
Do note that chm help is not available (by default) on all windows versions out there. MS tries to discourage its usage, e.g. would require a separate download/installation. chm is labeled unsafe (and it actually is).
Navigation
[0] Message Index
[#] Next page