Use Windows.pkg
Use LanguageText.pkg
Use cHtmlHelp.inc // API Functions and Constants, etc.
Use GlobalFunctionsProcedures.pkg
Use HelpSystemConstants.pkg
Register_Function phoMainPanel Returns Integer
Class cHtmlHelpNew Is A cObject
Procedure Construct_Object
Forward Send Construct_Object
Move Self To ghoHtmlHelp // registers the object-handle globally
Property String psHelpFile "" // main HTML Help project file
Property String psSubHelpFile "" // sub HTML Help file, included in main project file
Property String psGlobalHelpWindow "$global_main" // global window name, as defined in .CHM files
Property String psDefaultPage "VDF90.htm" // default page to show
Property String psDefaultPageBook "VDF9.chm" // book that contains default page
Property Handle phoOwner // object that is the owner of the HTML help window
Property Boolean pbOwnerIsDesktop True // setting this true, stops the on-top behavior
//DOC/ Interface=Private
Property Integer private_piCookie
Send DoInitialize
End_Procedure // Construct_Object
//DOC/ Interface=Public Type=Event NoDoc=True
Procedure Destroy_Object
Send DoDeInitialize
Forward Send Destroy_Object
End_Procedure // Destroy_Object
// get owner's window handle. if phoOwner not defined use
// handle of application objects phoMainPanel. If no owner return 0
//DOC/ Interface=Private
Function GetOwnerWindowHandle Returns Integer
Handle hoOwner
// if owner is desktop we use the desktop window handle. When the desktop is the owner
// you don't get on-top behavior and the help windows does not minimize when you minimize
// main program. When the Main panel has the focus, you get the on-top behavior.
If (Not(pbOwnerIsDesktop(self))) begin
Get phoOwner To hoOwner
If (hoOwner=0 And ghoApplication) ;
Get phoMainPanel Of ghoApplication To hoOwner
If hoOwner ;
Get window_handle Of hoOwner To hoOwner // the DF objects window handle
end
// owner will be 0, if we could not find a main active handle or, the more likely
// case, pbOwnerIsDesktop is set true
If (hoOwner=0) Begin
Move (GetDesktopWindow()) To hoOwner
End
Function_Return hoOwner
End_Function // GetOwnerWindowHandle
// Function GetOwnerWindowHandle Returns Integer
// Handle hoOwner
// Get phoOwner To hoOwner
// If (hoOwner=0 And ghoApplication) ;
// Get phoMainPanel Of ghoApplication To hoOwner
// If hoOwner ;
// Get window_handle Of hoOwner To hoOwner // the DF objects window handle
// Function_Return hoOwner
// End_Function // GetOwnerWindowHandle
//DOC/ Interface=Private
Function GetHelpFile Returns String
String sHelpFile
Get psHelpFile To sHelpFile
// if name is not directly set object, see if we can get it from the application object
If (sHelpFile="" And ghoApplication And peHelpType(ghoApplication)=htHtmlHelp);
Get psHelpFile Of ghoApplication To sHelpFile
If (sHelpFile<>"") Get_File_Path sHelpFile To sHelpFile
Function_Return sHelpFile
End_Function // GetHelpFile
// 5.19.2004 - It appears that using hh_initialize/hh_uninitialze causes keyboard problems with
// embedded help which causing ctrl+c to not work. According to messages found on a Newsgroup this
// is a known issue and that not using these is the solution. The general advice was to stay
// away from these messages - and it does seem to solve the problem (jjt)
//DOC/ Interface=Private
Procedure DoInitialize
// //Must be sent before any HTML commands can be used
// Handle hRetVal
// Integer dwCookie
// String sBuffer
// Pointer pBuffer
// ZeroType tDWORD To sBuffer
// GetAddress Of sBuffer To pBuffer
// Move (HtmlHelp(0, "", HH_INITIALIZE, pBuffer)) To hRetVal
// GetBuff From sBuffer At tDWORD.DWord To dwCookie
// Set private_piCookie To dwCookie
End_Procedure // DoInitialize
//DOC/ Interface=Private
Procedure DoDeInitialize
//Must be sent to free resources
// DWord dwCookie
Handle hRetVal
// String sHelpFile
// Get private_piCookie To dwCookie
// not sure hh_close_all was used. Was added by Dennis who cannot remember why
// Move (HtmlHelp(0, 0, HH_CLOSE_ALL, 0)) To hRetVal // added DP
// Move (HtmlHelp(0, "", HH_UNINITIALIZE, dwCookie)) To hRetVal
End_Procedure // DoDeInitialize
// C++ Calls to emulate when calling an HTML help file with included sub-files:
// HtmlHelp( GetDesktopWindow(), "C:\\Allison\\Main Project\\Main Project.chm",
// HH_DISPLAY_TOPIC, NULL);
//
// HtmlHelp( GetDesktopWindow(), "Joe.chm::/Joe_s_Second_Topic.htm", HH_DISPLAY_TOPIC, NULL);
//DOC/ Interface=Public
Procedure DoDisplayTopic String sTopic
//Most-used command. Pops up the tri-pane Help Viewer.
Handle hRetVal hWnd
Pointer psNull
String sHelpFile sSubHelpFile sNull sHelpWindow
//Move (GetDesktopWindow()) To hWnd
Get GetOwnerWindowHandle to hWnd
Get psGlobalHelpWindow To sHelpWindow
Get GetHelpFile To sHelpFile
Move "" To sNull
GetAddress Of sNull To psNull
Move (HtmlHelp(hWnd, sHelpFile, HH_DISPLAY_TOPIC, psNull)) To hRetVal
Get psSubHelpFile To sSubHelpFile
Append sSubHelpFile "::/" sTopic
Move (HtmlHelp(hWnd, sSubHelpFile, HH_DISPLAY_TOPIC, psNull)) To hRetVal
Send DoSyncToc sTopic sHelpWindow
End_Procedure // DoDisplayTopic
//DOC/ Interface=Public
Procedure DoDisplayIndex
//Another commonly-used command. Pops up the topic for the current index entry.
Handle hRetVal
String sHelpFile
Get GetHelpFile To sHelpFile
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_DISPLAY_INDEX, 0)) To hRetVal
End_Procedure // DoDisplayIndex
//DOC/ Interface=Public
Procedure DoDisplayIndexString String sIndex
//Another commonly-used command. Shows the Index, and highlights the sIndex entry
Handle hRetVal
String sHelpFile
Pointer lpsIndex
GetAddress Of sIndex To lpsIndex
//Get GetHelpFile To sHelpFile
Get psHelpFile To sHelpFile
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_DISPLAY_INDEX, lpsIndex)) To hRetVal
End_Procedure // DoDisplayIndexString
// 2004-06-15 ------------------------------------ Start Nils G. Svedmyr
// Code copied from cHtmlHelp.pkg from the pkg folder:
Procedure DoShowMapId Integer iMapID
//Passed an integer of the MapID allocated to the topic
Handle hRetVal
String sHelpFile
Get GetHelpFile To sHelpFile
If (sHelpFile ="") Error DFERR_HELP_SYSTEM C_$ThereIsNoHelpfileDefined
Else Begin
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_HELP_CONTEXT, iMapID)) To hRetVal
Send DoDisplayTOC
//Send DoSyncToc
End
End_Procedure
//DOC/ Interface=Public
// Procedure DoShowMapId Integer iMapID
// //Passed an integer of the MapID allocated to the topic
// Handle hRetVal
// String sHelpFile sSubHelpFile sDefaultPage
// Get GetHelpFile To sHelpFile
// Get psSubHelpFile To sSubHelpFile
// Get psDefaultPage To sDefaultPage
// If (sHelpFile="") ;
// Error DFERR_HELP_SYSTEM C_$ThereIsNoHelpfileDefined
// Else Begin
// Send DoDisplayTopic sDefaultPage // show main help book, default page
// Move (HtmlHelp(GetOwnerWindowHandle(Self), sSubHelpFile, HH_HELP_CONTEXT, iMapID)) To hRetVal
// Send DoDisplayTOC
// //Send DoSyncToc
// End
// End_Procedure // DoShowMapId
// 2004-06-15 ------------------------------------ Stop Nils G. Svedmyr
//DOC/ Interface=Public
Procedure DoDisplayKeyword String sKeyword
Handle hRetVal
Pointer lpsKeyword lpsAkLink lpsErrorText
String sHelpFile sAkLink sErrorText sDefaultPageBook sDefaultPage
GetAddress Of sKeyword To lpsKeyword
Get GetHelpFile To sHelpFile
Move (SFormat(C_$SorryIsNotInTheIndex, sKeyword)) To sErrorText
GetAddress Of sErrorText To lpsErrorText
ZeroType tAkLink To sAkLink
Put tAkLink_Size To sAkLink At tAkLink.cbStruct
Put 0 To sAkLink At tAkLink.fReserved
Put lpsKeyword To sAkLink At tAkLink.pszKeywords
Put 0 To sAkLink At tAkLink.pszUrl
//Put lpsErrorText To sAkLink At tAkLink.pszMsgText
Put 0 To sAkLink At tAkLink.pszMsgText
Put 0 To sAkLink At tAkLink.pszMsgTitle
Put 0 To sAkLink At tAkLink.pszWindow
Put 0 To sAkLink At tAkLink.fIndexOnFail
// Put 1 To sAkLink At tAkLink.fIndexOnFail // DP
GetAddress Of sAkLink To lpsAkLink
// DP - doc says to call HH_DISPLAY_TOPIC first
// try to display the default page while index is searching
// or while a box shopwing multiple found topics is up
Get psDefaultPageBook To sDefaultPageBook
Get psDefaultPage To sDefaultPage
Set psSubHelpFile To sDefaultPageBook
Send DoDisplayTopic sDefaultPage
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_KEYWORD_LOOKUP, lpsAkLink)) To hRetVal
If (hRetVal = 0) Begin
//Send DoDisplayTOC
Send DoDisplayIndexString sKeyword
End
End_Procedure // DoDisplayKeyword
//DOC/ Interface=Public
Procedure DoDisplayTOC
Handle hRetVal
String sHelpFile
//Get GetHelpFile To sHelpFile
Get psHelpFile To sHelpFile
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_DISPLAY_TOC, 0)) To hRetVal
End_Procedure // DoDisplayTOC
// C++ Call to emulate:
// HtmlHelp( GetDesktopWindow(), "Joe.chm>$global_main",
// HH_SYNC,(DWORD_PTR)"Joe.chm::/Joe_s_Second_Topic.htm");
//DOC/ Interface=Public
Procedure DoSyncToc String sTopicName
Handle hRetVal hWnd
String sHelpFile sTopic sHelpWindow
Pointer psTopic
Move (GetDesktopWindow()) To hWnd
Get psGlobalHelpWindow To sHelpWindow
Get psSubHelpFile To sTopic
Append sTopic "::/" sTopicName
GetAddress Of sTopic To psTopic
Get psSubHelpFile To sHelpFile
Append sHelpFile ">" sHelpWindow
Move (HtmlHelp(hWnd, sHelpFile, HH_SYNC, psTopic)) To hRetVal
End_Procedure // DoSyncToc
//DOC/ Interface=Public
Procedure DO_HH_DISPLAY_SEARCH String sTopic
Handle hRetVal
Pointer psTopic
String sHelpFile
GetAddress Of sTopic To psTopic
Get GetHelpFile To sHelpFile
Move (HtmlHelp(GetOwnerWindowHandle(Self), sHelpFile, HH_DISPLAY_SEARCH, psTopic)) To hRetVal
End_Procedure // DO_HH_DISPLAY_SEARCH
End_Class // cHtmlHelpNew