I would not use that code anymore, especially since MS deprecated its use (IONS AGO!!!).
It is not even provided in a standard Windows since Vista. It is a separate install/download.
For windows 10+ it is not even provided AT ALL....
I would not use that code anymore, especially since MS deprecated its use (IONS AGO!!!).Yes, chm was deprecated in Vista, but the successor is limited and not open (requires fee/developer subscription the last time I checked), and I doubt you could name it.
It is not even provided in a standard Windows since Vista. It is a separate install/download.
For windows 10+ it is not even provided AT ALL....
The chm file loads and runs as expected. If the above call is preceded by Application.Initialize then the chm file still loads. However, attempting a search in the chm Search tab then causes the chm window to hang (hourglass - "not responding"). The test program below shows this problem (see comments there). (The test program should be run with the attached Small_demo_1a.chm file.)
For windows 10+ it is not even provided AT ALL....This is not correct. I have Win10 and can open chm files by doubleclicking (I can't remember whether I had to install something additionally to the system, probably I had to...). I also have some projects in which the chm files are opened correctly in a similar way as shown by the OP. And don't advertise the CHM package too much: although it has improved there are still lots of annoyances.
You are also mixing GUI elements with a command line appilcation.
But there is a really good CHM package in the standard distribution of FPC.
You will find it in packages/chm and it is also cross-platform.
The chm file loads and runs as expected. If the above call is preceded by Application.Initialize then the chm file still loads. However, attempting a search in the chm Search tab then causes the chm window to hang (hourglass - "not responding"). The test program below shows this problem (see comments there). (The test program should be run with the attached Small_demo_1a.chm file.)
I can reproduce, but can't really say what causes it. It could be a bug in the MS helpviewer (due to an enormously spartan CHM), but also in lazarus. I would at the very least expand the chm to a more wellformed, or use one from an existing program, to test if it is lazarus/LCL or the chm
Instead of calling HtmlHelp function from a console program I'd prefer to open the file in hh.exe by means of a separate process. The next code works fine ..
If you want to go cross-platform then you should use the Lazarus CHM viewer, it is called lhelp and is in folder comonents/chmhelp/lhelp. Load the project into Lazarus and compile it (it requires that you have installed the packages lhelpcontrolpkg.lpk and TurboPowerIpro.lpk). ATM I don't know the calling convention how to open a specific topic. But adding the chm file name as a parameter opens the specific chm file at least.
P.S.
HelpNDoc is great!
Yes, this will open the chm file. However, is there any way to link a topic in my application to a particular topic in the chm?Have you tried to change constant TOPIC = 'index' to something else?
Yes, this will open the chm file. However, is there any way to link a topic in my application to a particular topic in the chm?Have you tried to change constant TOPIC = 'index' to something else?
I did run a few tests and apparently you need a dummy window. So create one, pass the handle to HtmlHelpA and you're good to go. More over you can hide or AlphaBlend it, so visually the result is the same as in your original project.
In all cases when the chm loaded it reported "This page can't be displayed". This happens whether the chm initially opens to the Contents tab or the Search tab.I don't know, but did you enter the topic correctly? Sometimes the extension is .html, sometimes only .htm. And in my sample there is a path "/system/" in front of the topic name. Please compile the program chmls (in fpc/packages/chm). Run it with the chm file as a parameter and it will list you all contained topics along with extension and path.
Note that my application is non-GUI if this makes any difference.First I converted your application to a GUI and it worked flawlessly, then I created a form in your console application to check if it makes a difference, apparently it does. See attachment.
Yes, I tried both .html, .htm, and no extension.In all cases when the chm loaded it reported "This page can't be displayed". This happens whether the chm initially opens to the Contents tab or the Search tab.I don't know, but did you enter the topic correctly? Sometimes the extension is .html, sometimes only .htm.
Please compile the program chmls (in fpc/packages/chm). Run it with the chm file as a parameter and it will list you all contained topics along with extension and path.
Unfortunately, when I try to open any HelpNDoc chm (including HelpNDoc's own chm help file) I get a Lhelp error "Resource unavailable:ms-its:". This seems to be a known problem. Search "unavailable" here --
Since I was generating CHM files myself with HelpNDoc, I was able to investigate...Could you generate a simple CHM file (one topic only) with HelpNDoc with causes the trouble and upload it her (packed into a zip)? I don't see a reason why LHelp cannot be fixed to accept such a file.