This lesson shows how the Windows HELP 'engine' can be started with a call to the WinHelpA function in user32.dll, and also hopefully serves as an example of how a former include file can be 'inlined' into a program that you are writing.
Please note that once WinHelpA becomes a part of win32lib.ew, all this extra work will no longer be necessary, and this program example may not even run. ( redefine error! ..something to always watch out for. Multiple declarations of variables, constants, procedures, or functions will always cause a program crash.(unless they are 'internal' to a procedure or function))
The method used to call a Windows HELP file was actually developed by me and Irv Mullins through the EUPHORIA mailing list, a great group of people always willing to help each other with EUPHORIA programming problems and techniques.
--
callhelp.exw
-- callhelp.exw
-- (Wolf's second "abberation") Nov.5/98
-- This opens a blank window.
-- and adds an Exit and Help item to a menubar.
-- now adds a call to Windows HELP, with the assistance of Irv Mullins.
-- ( our old winhelp.e )
include win32lib.ew
without warning
integer winhlp_id
-- get an id for the WinHelpA routine in user32.dll.
winhlp_id =
registerw32Function( user32, "WinHelpA", {C_INT, C_INT, C_INT, C_INT}, C_INT )
-- where atom command is
-- = #0002 ..quits help ( HELP_QUIT ). in YOUR terminate procedure
-- = #0003 ..starts helpfile index ( HELP_INDEX )
-- = #0003 ..starts helpfile contents ( HELP_CONTENTS )
-- = #0004 ..starts help on help ( HELP_HELPONHELP )
-- these are the only ones I've tested ;- )
-- called like this.. LetsCallWinHelp( MYWINDOW, "myhelp.hlp", #0003, 0 )
procedure LetsCallWinHelp( atom hwnd, -- handle of owner window
sequence FileName, -- help file
atom command, -- type of help needed
atom data ) -- value related to type of command
atom file_ptr, start
-- how to pass messages to the help engine !!
file_ptr = acquire_mem( 0, FileName )
start = w32Func( winhlp_id, {NULL, file_ptr, command, data} )
release_mem( file_ptr )
end procedure
-------- our main program.
constant SimpleWin = create( Window, "HELP !", 0, Default, Default, 160, 80, 0 ),
ExitMenu = create( Menu, "E&xit", SimpleWin, 0, 0, 0, 0, 0 ),
ExitNow = create( MenuItem, "Now!", ExitMenu, 0, 0, 0, 0, 0 ),
HelpMenu = create( Menu, "&Help", SimpleWin, 0, 0, 0, 0, 0 ),
HelpMe = create( MenuItem, "Help", HelpMenu, 0, 0, 0, 0, 0 )
procedure onMenu_Exit( atom self, atom event, sequence params )
-- close the HELP window, IF it is still open.
LetsCallWinHelp( SimpleWin, "tiny!.hlp", #0002, 0 )
closeWindow( SimpleWin ) -- this kills the program.
end procedure
procedure onMenu_Help( atom self, atom event, sequence params )
-- just start Windows HELP, with the included example.
LetsCallWinHelp( SimpleWin, "tiny!.hlp", #0003, 0 )
end procedure
-- the two event handlers.
setHandler( ExitNow, w32HClick, routine_id( "onMenu_Exit" ) )
setHandler( HelpMe, w32HClick, routine_id( "onMenu_Help" ) )
-- 'run' the window.
WinMain( SimpleWin, Normal )
-- end of callhelp.exw..and here's the usual screen shot... of the help file that's called...
Note that the Windows 'help' engine can also be started with the ShellExecute() function in shell32.dll. This is the way that this tutorial program actually opens these HTML files, and starts external programs.
..end of lesson Extra_01.