News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Context Help using a text file

Started by dougiem, February 28, 2006, 02:17:06 AM

Previous topic - Next topic

dougiem

I have always found it troublesome creating help files, so I've came up with this method of context help using only a text file. I hope its of some use.

dougiem

[attachment deleted by admin]

hutch--

Doug,

It looks like you have done something smart here but I have not connected enough to know how it works or how to use it. maybe you could expand on this a bit more ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dougiem

Hi Hutch,

the concept: to be able to quickly put context help on dialogs and windows without worrying about duplicate control numbers and the need for a .chm or .hlp file.

the use: There are three ways the context help is displayed. 1) using the '?' button and then clicking a control, 2) the Tab / F1 keys, and 3) Right clicking on a control.

in 1) and 2) the control id is passed in HELPINFO.iCtrlId (pointed by lParam) using the WM_HELP message and in 3) the control handle is passed in wParam with the WM_CONTEXTMENU (the id number from using GetDlgCtrlID).

how it works: htmlhelp api 'HH_DISPLAY_TEXT_POPUP' uses a structure HH_POPUP. This structure controls the look, the text, and position. In normal circumstances, the popup position is taken from the cursor position, however when using 1) and 2) above, the position has to be the control window (one can't distinguish between a click causing WM_HELP or F1). In my prog I have used flags to alter the HH_POPUP structure when calling the api.

InitPopHelp allocates memory for the text file (format: ' 123 My_text_info 0Dh 0Ah ' ) and memory for a table pertaining to that file. The text memory is counted and each 0Dh is zeroed making zero terminated strings. A table is created with the first dword being the text allocated memory address. Subsequent quad words are control number integers - text address. The final dword is zero.

GetPopHelp searches the table for a matching control number and retreives the text address for that control from the next dword. The flags passed, are used to set the HH_POPUP structure.

KillPopHelp takes the table address (created by InitPopHelp), frees the memory pointed to by the first dword and then frees the table itself. Finally it zeros the pointer to the table, allowing the table to be re-initialised knowing it has been freed.  This allows multiple instances to be created/destroyed with some comfort that all memory is being freed.

I hope this is of help.

dougiem.

gfalen

A much easier approach (excuse the HLL code)


_pophelp PROC uses ebx, hwnd, id, ptable, pszFont

    local hp :HH_POPUP

    for <ebx=ptable, eax=id>, eax ne .d[ebx], ebx+=8
        .iff .d[ebx], ret
    next

    set hp=-1, cbStruct=sizeof hp, pszText=.d 4[ebx], \
        hinst=0, idString=0, pszFont=pszFont
    invok GetCursorPos, &hp.pt
    invok HtmlHelp, hwnd, 0, HH_DISPLAY_TEXT_POPUP, &hp
    ret
_pophelp endp


.data
tblID   dd 002, @$("Close this Dialog")
        dd 102, @$("Set the size of the displayed text")
        dd 104, @$("Set Colors and border size")
        dd 0
.code
...
        case WM_HELP
            mov eax, lParam
            invok _pophelp , [eax].HELPINFO.iCtrlId, &tblID, &szFont
        case WM_CONTEXTMENU
            invok GetDlgCtrlID, wParam
            invok _pophelp, eax, &tblID, &szFont


dougiem

Indeed gfalen,

this is the basis of my prog, all I've done is replaced the data section with a text file and introduced flags to control the HH_POPUP structure.
I can now easily change the text 'till I'm happy, then change the attribute from a 'file name' to a resource number to include it in the final program.

dougiem