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

Help feature for GetOpenFilename

dboggs
New Contributor I
670 Views
I'm using the API function GetOpenFilename, and I want to to add the built-in optional Help feature. The Help button can be made to appear in the dialog by setting the flag Ofn_ShowHelp, but that's as far as I've gotten. The feature documentation goes on to say that Ofn%HwndOwner "must specify the window to receive the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button", or, that the dialog box "sends a CDN_HELP notification message to your hook procedure when the user clicks the Help button."

Help! If I even understood what this means, I'd probably be programming a Win application instead of Quickwin.

Can anyone give me an example showing how to use this? The standard sample provided by Intel doesn't make use of the Help button.

p.s. I'd also like to control where the dialog appears in my Project Window. So far I've been led to believe that a hook procedure is needed for that, too. Maybe I can kill two birds with one hook procedure? But I don't even know what a hook procedure is.
0 Kudos
3 Replies
Paul_Curtis
Valued Contributor I
670 Views
I just checked my program's use of GetOpenFileName, and the Windows dialog for this function does indeed contain a help button, which summons the standard Windows-supplied help content. Here is a code sample (the calling argument rw_mode is a character, 'R' for read and 'W' for write; function MOR() does a Multiple IOR among its arguments):

[bash]LOGICAL FUNCTION DlgFileIO (rw_mode, hwndParent, filter, fullpath, ncfn, extn, ncextn, path)
    IMPLICIT NONE
    CHARACTER(LEN=1), INTENT(IN)		   :: rw_mode
    INTEGER(HANDLE),  INTENT(IN)		   :: hwndParent
    CHARACTER(LEN=*), INTENT(IN)		   :: filter
	CHARACTER(LEN=*), INTENT(IN)		   :: extn
	CHARACTER(LEN=*), INTENT(INOUT)		   :: fullpath
	INTEGER,		  INTENT(INOUT)		   :: ncfn, ncextn
	CHARACTER(LEN=*), INTENT(INOUT)		   :: path
	INTEGER								   :: rval

    TYPE(T_OPENFILENAME)				   :: ofn
    
    ofn%lStructSize		  = SIZEOF(ofn)
    ofn%hwndOwner		  = hwndParent
    ofn%hInstance         = ghInstance                  ! available globally
    ofn%lpstrFilter		  = LOC(filter)
    ofn%nFilterIndex	  = 0				! force use of 1st filter entry,
	ofn%lpstrCustomFilter = 0				! restricts to single file type

    ofn%lpstrFile		  = LOC(fullpath)
    ofn%nMaxFile		  = LEN(fullpath)
	ofn%lpstrInitialDir	  = LOC(path)
	ofn%lpstrDefExt		  = LOC(extn)
    ofn%nMaxCustFilter    = 0
    ofn%nMaxFileTitle     = 0
    ofn%lpstrTitle        = loc(""C)
    ofn%lpfnHook          = NULL
    ofn%lpTemplateName    = NULL

	IF (rw_mode == 'R') THEN
		ofn%Flags = MOR(OFN_HIDEREADONLY,  OFN_PATHMUSTEXIST,	&
				        OFN_FILEMUSTEXIST, OFN_SHAREAWARE		)
        DlgFileIO = GetOpenFileName (ofn)

	ELSE
		ofn%Flags = MOR(OFN_HIDEREADONLY,  OFN_CREATEPROMPT,		&
						OFN_PATHMUSTEXIST, OFN_OVERWRITEPROMPT)
        DlgFileIO = GetSaveFileName (ofn)
	END IF
	ncfn   = ofn%nFileOffset + 1
	ncextn = ofn%nFileExtension + 1
	
END FUNCTION DlgFileIO
[/bash]
0 Kudos
dboggs
New Contributor I
670 Views

Thanks Paul, but it looks like by "help" you are thinking of the "?" icon in the upper right corner of the dialog. That has nothing to do with the ofn.showhelp flag. This flag causes a common dialog button control to appear, labeled "Help", to which you can link your own custom help text. That's what I'm talking about.

0 Kudos
Paul_Curtis
Valued Contributor I
670 Views
In that case you need to link in htmlhelp.lib and use the htmlhelp() API function. This function would be called when the opsys sends your proc a WM_HELP message, and it opens the standard help dialog and fills it with the content of your own .chm file.

Since Quickwin precludes access to the window's proc function, responding to WM_HELP messages in that programming context may become a bit difficult.

Search this forum for "htmlhelp", there are a number of posts from some years ago, I think the library was uploaded by Jugoslav. The help system is easy to implement and works perfectly, if you have provided your own proc functions.
0 Kudos
Reply