Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28602 Discussions

Integrating Help *.chm files in FORTRAN applications

dannycat
New Contributor I
1,614 Views
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.
0 Kudos
15 Replies
Paul_Curtis
Valued Contributor I
1,614 Views
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:

[cpp]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
[/cpp]

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

[cpp]CASE (WM_HELP)
	rval = HtmlHelp (ghwndmain, helppathname, HH_DISPLAY_TOPIC, NULL)
[/cpp]

0 Kudos
dannycat
New Contributor I
1,614 Views
Quoting - Paul Curtis

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

[cpp]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
[/cpp]

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

[cpp]CASE (WM_HELP)
	rval = HtmlHelp (ghwndmain, helppathname, HH_DISPLAY_TOPIC, NULL)
[/cpp]


Thanks Paul,

Where are HH_DISPLAY_TOPIC and other such constants defined?
0 Kudos
Paul_Curtis
Valued Contributor I
1,614 Views
Quoting - dannycat

Thanks Paul,

Where are HH_DISPLAY_TOPIC and other such constants defined?

[cpp]! 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
[/cpp]

0 Kudos
dannycat
New Contributor I
1,614 Views
Quoting - Paul Curtis

[cpp]! 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
[/cpp]


Thanks again! Everything works fine now.
0 Kudos
dannycat
New Contributor I
1,614 Views
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?
0 Kudos
mavlik
Beginner
1,614 Views
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]


0 Kudos
Paul_Curtis
Valued Contributor I
1,614 Views

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).
0 Kudos
m_furqan_latif
Beginner
1,614 Views
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.

0 Kudos
dannycat
New Contributor I
1,614 Views
Thanks everyone, I've found the library I need in the SDK area.

C:Program FilesMicrosoft SDKsWindowsv6.0ALibx64


0 Kudos
tvinni
Beginner
1,614 Views
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
0 Kudos
Tomas750
Beginner
1,614 Views

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
0 Kudos
Paul_Curtis
Valued Contributor I
1,614 Views
As posted previously, I only work in 32 bits, so I have not had to evolve my library dependencies for 64 bits. (sorry).
0 Kudos
andrew_4619
Honored Contributor III
1,614 Views

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 

0 Kudos
Steven_L_Intel1
Employee
1,614 Views

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?

0 Kudos
andrew_4619
Honored Contributor III
1,614 Views

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!

0 Kudos
Reply