Integrating Help *.chm files in FORTRAN applications

Integrating Help *.chm files in FORTRAN applications

I'm about to embark in creating a help system for my application. Most current help compilers create HTML Help files (*.chm) whereas previously WinHelp (*.hlp) files were the norm. Apparently the support for Winhelp(*.hlp) has been withdrawn by Microsoft with the advent of Vista. Although you can still download the WinHelp I prefer to use the current format. My question is how do you call up the HTML format help files from within a windows application. The Generic sample provided still utilises the WinHelp API function which does not recognise HTML files.

16 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Quoting - dannycat
I'm about to embark in creating a help system for my application. Most current help compilers create HTML Help files (*.chm) whereas previously WinHelp (*.hlp) files were the norm. Apparently the support for Winhelp(*.hlp) has been withdrawn by Microsoft with the advent of Vista. Although you can still download the WinHelp I prefer to use the current format. My question is how do you call up the HTML format help files from within a windows application. The Generic sample provided still utilises the WinHelp API function which does not recognise HTML files.

Add the attached .lib file to your project. Use this interface:

INTERFACE 
	FUNCTION HtmlHelp (hWndMain, lpszHelp, uCommand, dwData)
		USE ifwinTY
		integer(BOOL) :: HtmlHelp ! BOOL
		!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'HtmlHelpA' :: HtmlHelp
		integer(HANDLE) hWndMain ! HWND hWndMain
		!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpszHelp
		character*(*) lpszHelp ! LPCSTR lpszHelp
		integer(UINT) uCommand ! UINT uCommand
		integer(ULONG_PTR) dwData ! ULONG_PTR dwData
	END FUNCTION
END INTERFACE

and then your procs will need to process WM_HELP in the message loop handler:

CASE (WM_HELP)
	rval = HtmlHelp (ghwndmain, helppathname, HH_DISPLAY_TOPIC, NULL)

Attachments: 

AttachmentSize
Downloadapplication/octet-stream htmlhelp.lib34.09 KB

Quoting - Paul Curtis

Add the attached .lib file to your project. Use this interface:

INTERFACE 
	FUNCTION HtmlHelp (hWndMain, lpszHelp, uCommand, dwData)
		USE ifwinTY
		integer(BOOL) :: HtmlHelp ! BOOL
		!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'HtmlHelpA' :: HtmlHelp
		integer(HANDLE) hWndMain ! HWND hWndMain
		!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpszHelp
		character*(*) lpszHelp ! LPCSTR lpszHelp
		integer(UINT) uCommand ! UINT uCommand
		integer(ULONG_PTR) dwData ! ULONG_PTR dwData
	END FUNCTION
END INTERFACE

and then your procs will need to process WM_HELP in the message loop handler:

CASE (WM_HELP)
	rval = HtmlHelp (ghwndmain, helppathname, HH_DISPLAY_TOPIC, NULL)

Thanks Paul,

Where are HH_DISPLAY_TOPIC and other such constants defined?

Quoting - dannycat

Thanks Paul,

Where are HH_DISPLAY_TOPIC and other such constants defined?

! HTML help command flags
INTEGER, PARAMETER	:: HH_DISPLAY_TOPIC 	 = #0000
INTEGER, PARAMETER	:: HH_DISPLAY_TOC	         = #0001
INTEGER, PARAMETER	:: HH_DISPLAY_INDEX	         = #0002
INTEGER, PARAMETER	:: HH_DISPLAY_SEARCH	 = #0003
INTEGER, PARAMETER	:: HH_KEYWORD_LOOKUP	 = #000D
INTEGER, PARAMETER	:: HH_DISPLAY_TEXT_POPUP = #000E
INTEGER, PARAMETER	:: HH_CLOSE_ALL                 = #0012

Quoting - Paul Curtis

! HTML help command flags
INTEGER, PARAMETER	:: HH_DISPLAY_TOPIC 	 = #0000
INTEGER, PARAMETER	:: HH_DISPLAY_TOC	         = #0001
INTEGER, PARAMETER	:: HH_DISPLAY_INDEX	         = #0002
INTEGER, PARAMETER	:: HH_DISPLAY_SEARCH	 = #0003
INTEGER, PARAMETER	:: HH_KEYWORD_LOOKUP	 = #000D
INTEGER, PARAMETER	:: HH_DISPLAY_TEXT_POPUP = #000E
INTEGER, PARAMETER	:: HH_CLOSE_ALL                 = #0012

Thanks again! Everything works fine now.

Quoting - dannycat

Thanks again! Everything works fine now.

Uh Oh. I spoke too soon. I have got the 32-bit version to work but the 64-bit configuration will not link. "Unresolved external symbol HtmlHelpA". Does the interface need some tweaking for 64-bit applications?

To dannycat

function HtmlHelpA (_HtmlHelpA@16) is realized in file 'hhctrl.ocx'. Try to
search similar file.
I don't know why in Fortran the names of dlls is hidden from user.
In Delphi for example you can make so:

[delphi]function HtmlHelp(
                  HwndCaller: hwnd;
                  pszFile: string;
                  uCommand: integer;
                  dwData: integer): hwnd; stdcall;  external 'hhctrl.ocx' 

name 'HtmlHelpA';
[/delphi]

I don't work in 64bit, but I suspect that htmlhelp.lib may only contain 32-bit versions of the API functions, so that when your code has flexible defines such as INTEGER(HANDLE) which automatically track 32/64 bits, your calling code's Interface will then differ from the actual library routine. You will probably have to locate a 64-bit version of the library (which I am unable to supply).

function HtmlHelpA (_HtmlHelpA@16) is realized in file 'hhctrl.ocx'. Try to
search similar file.
I don't know why in Fortran the names of dlls is hidden from user.

Thanks everyone, I've found the library I need in the SDK area.

C:Program FilesMicrosoft SDKsWindowsv6.0ALibx64

Quoting - m.furqan.latif
function HtmlHelpA (_HtmlHelpA@16) is realized in file 'hhctrl.ocx'. Try to
search similar file.
I don't know why in Fortran the names of dlls is hidden from user.

I am using Windows 7 (64 bit version)and the latest Intel Fortran on top of Microrosft Visual Studio 2008.
I have thesame problem of not being able to link my project because of the HtmHelpA missing.

I need further information about how to link my project successfully.
Can you help ?

Best regards,
f8

Hi Paul,

I would like to reproduce the question and problem of "tvinni". The existing HtmlHelp.lib, as it is, cannot be linked to routines compiled using the x64 platform. Do you know about any 64 bit version of this library or about some other possibility how to solve this problem?

Regards

Tomas

As posted previously, I only work in 32 bits, so I have not had to evolve my library dependencies for 64 bits. (sorry).

Bumping and old thread.... I have just made some tests building an application that builds and runs ok in x32 to x64. A few problems have been fixed but I have still have:

"error LNK2019: unresolved external symbol HtmlHelpA referenced in function CADHLP".

I have the x64 htmlhelp.lib (it is in the sdk that comes with VS2010 shell) and for belt and braces I added htmlhelp.lib to the linker additional dependancies and also added the libary path to additional library directories. I don't think finding the libary is a problem it is an issue with the INTERFACE I think. The interface is like Pauls' which is the #2 in this thread.  Any ideas what I need to do?  I have tried with an without the 'decoration' but for what its worth I don't think the X64 lib has underscores and @bytecount pre and post name. I have attached the lib header dumpbin if anyone can interpret it.

Any help would be greatfully appreciated. Andrew 

Attachments: 

AttachmentSize
Downloadtext/plain htmlhelp-lib-dump.txt14.24 KB

You need to look closer at what you're doing to link - the routine by that exact name is in htmlhelp.lib for x64. Are you sure you're linking to the x64 library?

Retired 12/31/2016

I just added the libary as a file in my project and it links now so a guess my settings are wrong. I will look at my project setings again....

Infact I have looked I think the problem was there was previously a x32 htmlhelp.lib file sat in my source/project folder. Having remove the lib as a project file deleted this local library file it now links OK in x32 and x64. 

Thanks for pointing me in the right direction!

Leave a Comment

Please sign in to add a comment. Not a member? Join today