Software Archive
Read-only legacy content
17061 Discussions

Context help in dialog boxes

isn-removed200637
501 Views
After much trial and error, I have been able to add a context help (question mark) button to a dialog, next to the system menu minimise/maximise buttons in the tilte bar, which doesn't cause the program to crash when trying to initialise the dialog and which actually changes the cursor into a question mark when clicked on.

I have also used the Help Workshop compiler HCW.EXE with its dialog box editor to create context help topics and associated code.
However, I do not know where to go to in order to utilise this code and the context Help topic IDs that it generates for the dialog box controls. In particular I would appreciate any help/guidance on how this code can/must be combined with the data already generated in the RESOURCE.H, Resource.FD, script.rc and script.res files that the Resource compiler uses/generates for the dialog box when using Visual Fortran.

Is there a method in Visual Fortran for doing this so that I can then intercept the requested help messages from dialog box controls the way that callback routines do after being assigned using DlgSetSub?
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
501 Views
Disclaimer: I've never done it myself. I'd just try to give you few guidelines. (Hope they would be more sensible than on Icon Extraction :-)) First, the help on resource editor says, quote:


Context help
Includes a question mark in the title bar of the window. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.


Thus, you have to intercept WM_HELP message in DialogProc. With WM_HELP, lParam points to a HELPINFO structure (see docs), containing info on which control has been hit. So, you have to dereference lParam to
a HELPINFO and display the appropriate help topic:
 
LOGICAL FUNCTION MyDialogProc(hWnd,Msg,wParam,lParam) 
!DEC$ATTRIBUTES STDCALL::  MyDialogProc 
USE DFWIN 
TYPE(T_HELPINFO)::  HI; POINTER(lpHI, HI) 
 
INCLUDE "Resource.fd" 
INCLUDE "HelpID.fd" 
 
SELECT CASE(Msg) 
... 
CASE(WM_HELP) 
    lpHI=lParam 
    SELECT CASE(HI%iCtrlID) 
    CASE (ID_BUTTON1) 
       bSt=WinHelp(hWnd,szHelpFile,HELP_WM_HELP,IDH_HELP_ON_BUTTON1) 
    CASE (ID_BUTTON2) 
         ... 
    END SELECT 
    MyDialogProc=1     
CASE(... 
... 
END SELECT 
 
END FUNCTION MyDialogProc 


"HelpID.fd" should be a file containing help topic IDs, generated from Help Workshop and translated to Fortran (just replace C #defines with Fortran
INTEGER, PARAMETER::).
Apparently, it has to be a Win32-managed dialog (not necessarily Win32 application -- DialogBox Win32 function works from QuickWin projects). if you want to do it with DFLOGM, it would require some hacking... but then,
please contact me at jdujic@uns.ns.ac.yu.
Also, it's possible that DFWIN does not contain WM_HELP parameter
and declaration of HELPINFO structure (6.0a doesn't). If not (compiler will complain), make a module/header file yourself:
 
INTEGER, PARAMETER:: WM_HELP = #0053 
TYPE T_HELPINFO 
    INTEGER cbSize 
    INTEGER iContextType 
    INTEGER iCtrlID 
    INTEGER hItemHandle 
    INTEGER dwContextID 
    TYPE(T_POINT) MousePos 
END TYPE 


Regards

Jugoslav
0 Kudos
isn-removed200637
501 Views
Many thanks, Jugoslav for your help and suggestions. You have given me plenty to chew on.
It looks like I am going to have to bite the bullet and get involved with DefWindowProc, message handling, hook procedures etc., having managed to avoid them so far by using QuickWIn dialog box processing in all my applications ( I am a Dyed-in-the wool Fortran programmer with no C experience/Knowledge and what little Windows API experience I have has been gleaned from the VF examples and programmers manual).

As II understand it from examining the WinHelp info file regarding the WinHelp calls, it would appear that I could manage with a single call using HELP_CONTEXTMENU, so long as I can get the ID of the control issuing the message from the WM_HELP message. Also I will need
'an array of double word pairs' , each pair consisting of a control ID and a context help topic ID. I know that the HCW.EXE compiler produces this in what looks like C-language . How can I translate this into Fortran correctly?
(I assume double word pairs means pairs of INTEGER*4 values). Should it go into HELPID.FD?

Finally, correct me again if I am wrong, but I unserstand that Windows must be using its own default DefWindowProc to process all the messages that I do not directly process using call-backs hooked to Dialog box controls by DFLOGM routines. So, If I write my own message-handler to deal with just the Win Help messages that are referred to in the context Help help note, all these other Windows messages must be passed on to a default procedure to be processed.

Many thanks again for taking the trouble.
0 Kudos
Reply