helpuser.cpp File Reference

(r1785/r1729)

#include "camtypes.h"
#include <stdlib.h>
#include "camelot.h"
#include "helpuser.h"
#include "helptabs.h"
#include "product.h"
#include "keypress.h"

Go to the source code of this file.

Defines

#define SPLITPATH   (_tsplitpath)
#define MAKEPATH   (_tmakepath)
#define GETSHORTPATHNAME   ("GetShortPathNameA")
#define TABBED_DIALOG_CLASS   (CC_RUNTIME_CLASS(DialogTabOp))
#define BUTTON_CLASS   (TEXT("BUTTON"))
#define NTLAUNCHER_TIMEOUT   (3)

Functions

 DECLARE_SOURCE ("$Revision: 1729 $")
static DWORD LookupDialogTopic (LPCTSTR lpcszLookupClass, UINT32 nPageResID)
 Private helper function that finds the help topic associated with "named" dialogs, ie. those dialogs that are managed by a specialised C++ class, not error or warning dialogs.
static DWORD LookupOperationTopic (LPCTSTR lpcszOpName)
 Private helper function that finds the help topic associated with Camelot operations, eg. those things exposed in menus!
static DWORD LookupMessageTopic (UINT32 nMessageID)
 Private helper function that finds the help topic associated with the given message, generally diaplayed in an error or warning dialog.
static BOOL FakeHelpButtonClick (HWND hwndDialog)
 Searches through the child windows of the given dialog, looking for a push button with the label "Help". If it finds one then the routine posts a "faked" click message for the button, so help is invoked.
static LRESULT CALLBACK EXPORT F1HookProc (INT32 nCode, WPARAM wParam, LPARAM lParam)
static BOOL RunOilHelp (LPCTSTR lpcszHelpPath, UINT32 nCommand, DWORD dwData)
 Private helper function that runs the system's help engine, whatever that might be, passing the given command. On Windows this is WINHELP.EXE or WINHLP32.EXE, on RISCOS it's get-the-manual-out time . . .
BOOL MakeShortPath (LPTSTR lpszPath, size_t cchMaxLen)
 Special function to work around an ommission in Win32s, which does not include the GetShortPathName function, even though Win32s is supposed to export ALL Win32 functions. This version does nothing under Win32s, which shortens pathnames automatically (?), under other versions of Windows it dynamically links to the function in the kernel32 library, thus avoiding an explicit link to the function which would prevent the app loading.
static BOOL ShowHelp (UINT32 nCommand, DWORD dwData)
 Called to display the given topic in the Xara Studio general help file. Makes a note if help is run successfully that we have to shut it down when we quit.
BOOL HelpUser (const DialogOp &DlgOp)
 Public function that finds the help topic associated with the given dialog operation and runs the system help engine to display the topic.
BOOL HelpUser (const wxDialog &dlg)
 Public function that finds the help topic associated with the given MFC dialog and runs the system help engine to display the topic.
BOOL HelpUser (const OpDescriptor &opdesc)
 Public function that finds the help topic associated with the given OpDescriptor and runs the system help engine to display the topic.
BOOL HelpUser (UINT32 nMessageID)
 Public function that finds the help topic associated with the given message and runs the system help engine to display the topic.
BOOL HelpUserPropertyPage (UINT32 PageID)
 Public function that finds the help topic associated with the given property page. This is required due to the new way the tabbed dialogs work (via MFC).
BOOL HelpUserTopic (DWORD dwHelpIndex)
 Public function that finds the help topic associated with the given message and runs the system help engine to display the topic.
BOOL _HelpUser (LPCTSTR lpcszClassName, UINT32 nSubTopic)
 Public function that finds the help topic associated with the given object and runs the system help engine to display it. This is a "bodgey" direct-access function for invoking help in those tricky cases, such as the print-setup dialog, that do not have any Camelot object directly associated with them.
BOOL HelpContents ()
 Runs the system help engine, displaying the "Contents" page.
BOOL HelpUsingHelp ()
 Runs the system help engine, displaying the system's instructions for using it.
BOOL HelpUsingTools ()
 Runs the system help engine, displaying the help on tools.
BOOL HelpUsingGalleries ()
 Runs the system help engine, displaying the help on galleries.
BOOL HelpOnlineDemos ()
 Runs the system help engine, displaying the on-line demos help page.
BOOL HelpTechnicalSupport ()
 Runs the system help engine, displaying the tech support help page.
BOOL CanHelpUser (UINT32 nMessageID)
 Public function to query whether a help topic exists for a given message. Depending on this the caller may display a help button in a message box, or may not etc.
void SetNextMsgHelpContext (UINT32 nMessageID)
 Remembers the last format string passed to MakeMsg. If a call is made to InformWarning, InformError etc and no string resource ID is passed then we have a problem using the string resource as an index into the help file. This remembers that last one, which we use if the "error ID" is zero.
UINT32 GetNextMsgHelpContext ()
 Gets the last help context set by SetNextMsgHelpContext.
BOOL InitHelpPath (BOOL bMainHelp)
 Initialises the help system. This should generally be called before just about everything else, so help is available for startup problems.
BOOL HelpFileExists (LPTSTR FileName)
BOOL InitUserHelp ()
BOOL DeInitUserHelp ()
 Shuts down the help system. This should be called as late as possible, so help is available for app shut-down problems. Note that MFC will call WinHelp(HELP_QUIT) for us when the main frame window is destroyed.

Variables

static String_256 achzHelpPath
static TCHAR achzMoviesHelpPath [_MAX_PATH]
static HHOOK hF1Hook = NULL
static BOOL fHaveUsedHelp = FALSE
static UINT32 nNextMessageHelpContext = 0


Define Documentation

#define BUTTON_CLASS   (TEXT("BUTTON"))
 

Definition at line 160 of file helpuser.cpp.

#define GETSHORTPATHNAME   ("GetShortPathNameA")
 

Definition at line 149 of file helpuser.cpp.

#define MAKEPATH   (_tmakepath)
 

Definition at line 148 of file helpuser.cpp.

#define NTLAUNCHER_TIMEOUT   (3)
 

Definition at line 165 of file helpuser.cpp.

#define SPLITPATH   (_tsplitpath)
 

Definition at line 147 of file helpuser.cpp.

#define TABBED_DIALOG_CLASS   (CC_RUNTIME_CLASS(DialogTabOp))
 

Definition at line 155 of file helpuser.cpp.


Function Documentation

BOOL _HelpUser LPCTSTR  lpcszClassName,
UINT32  nSubTopic
 

Public function that finds the help topic associated with the given object and runs the system help engine to display it. This is a "bodgey" direct-access function for invoking help in those tricky cases, such as the print-setup dialog, that do not have any Camelot object directly associated with them.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/5/95
Parameters:
lpcszClassName the class name of the object to run help for [INPUTS] nSubTopic which sub-topic for the object to display (by default, no sub-topic)
Returns:
TRUE if the help system is started successfully.
See also:
HelpUser; LookupDialogTopic; RunOilHelp

Definition at line 799 of file helpuser.cpp.

00800 {
00801     DWORD dwHelpIndex = LookupDialogTopic(lpcszClassName, nSubTopic);
00802     if (dwHelpIndex == 0)
00803     {
00804         TRACEUSER( "Ollie", _T("Can't find raw help topic for %s (sub %lu)\n"),
00805                                     lpcszClassName, nSubTopic);
00806         return FALSE;
00807     }
00808 
00809     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00810 }

BOOL CanHelpUser UINT32  nMessageID  ) 
 

Public function to query whether a help topic exists for a given message. Depending on this the caller may display a help button in a message box, or may not etc.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
nMessageID the resource identifier of the message that is being [INPUTS] enquired about
Returns:
TRUE if a help topic descrbing this message exists, FALSE otherwise.
See also:
LookupMessageTopic; InformGeneral

Definition at line 962 of file helpuser.cpp.

00963 {
00964     // Just return TRUE if a help topic for the message exists.
00965     return LookupMessageTopic(nMessageID) != 0;
00966 }

DECLARE_SOURCE "$Revision: 1729 $"   ) 
 

BOOL DeInitUserHelp  ) 
 

Shuts down the help system. This should be called as late as possible, so help is available for app shut-down problems. Note that MFC will call WinHelp(HELP_QUIT) for us when the main frame window is destroyed.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Returns:
TRUE if successful.
See also:
InitUserHelp

Definition at line 1108 of file helpuser.cpp.

01109 {
01110 PORTNOTETRACE("help", "Help function unimplemented!");
01111 #if !defined(EXCLUDE_FROM_XARALX)
01112     // Tell the help engine we've finished using the help file(s).
01113     // NB. KNWON BUG: this doesn't do the job on Windows NT, leaving the helpfiles open.
01114     // As yet I have no idea why - it is as per the docs and works on Win32s & Chicago.
01115     if (fHaveUsedHelp)
01116     {
01117         TRACEUSER( "Ollie", _T("Closing general helpfile\n"));
01118         ShowHelp(HELP_QUIT, 0);
01119     }
01120 
01121 #ifdef STANDALONE
01122     // Same if we ran the special helpfile.
01123     if (fHaveUsedSpecHelp)
01124     {
01125         TRACEUSER( "Ollie", _T("Closing special helpfile\n"));
01126         RunOilHelp(achzSpecPath, HELP_QUIT, 0);
01127     }
01128 #endif
01129 
01130     // Remove our F1 message hook.
01131     return hF1Hook == NULL || ::UnhookWindowsHookEx(hF1Hook);
01132 #else
01133     return TRUE;
01134 #endif
01135 }

static LRESULT CALLBACK EXPORT F1HookProc INT32  nCode,
WPARAM  wParam,
LPARAM  lParam
[static]
 

Definition at line 399 of file helpuser.cpp.

00400 {
00401     // Check if it's the F1 key going down within a dialog box . . .
00402     LPMSG lpmsg = (LPMSG) lParam;
00403     BOOL fHandleOK = ::IsWindow(lpmsg->hwnd);
00404     if (nCode == MSGF_DIALOGBOX && lpmsg->message == WM_KEYDOWN && lpmsg->wParam == CAMKEY(F1))
00405     {
00406         // Simulate the help button within the dialog being clicked, if there is one.
00407         // Empirically I have discovered that the window handle contained within the
00408         // message is that of the first child window in the dialog.
00409         if (fHandleOK) FakeHelpButtonClick(::GetParent(lpmsg->hwnd));
00410     }
00411 
00412     // Pass this event on to the next hook proc if it's valid.
00413     return (fHandleOK) ? ::CallNextHookEx(hF1Hook, nCode, wParam, lParam) : 0;
00414 }

static BOOL FakeHelpButtonClick HWND  hwndDialog  )  [static]
 

Searches through the child windows of the given dialog, looking for a push button with the label "Help". If it finds one then the routine posts a "faked" click message for the button, so help is invoked.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/5/95
Parameters:
hwndDialog the dialog box to fake a help button click within [INPUTS]
Returns:
TRUE if the fake click was possible, FALSE otherwise (maybe the dialog doesn't have a help button?)
See also:
F1HookProc

Definition at line 341 of file helpuser.cpp.

00342 {
00343     // Make sure we've been passed a genuine window handle.
00344     if (!::IsWindow(hwndDialog)) return FALSE;
00345 
00346     // Get the text of a "help" button.
00347     String_256 strHelpLabel(_R(IDS_HELP));
00348 
00349     // Search through all child windows of the given dialog, looking for a push-button
00350     // with the label "Help".
00351     for (HWND hwndChild = ::GetWindow(hwndDialog, GW_CHILD);
00352          hwndChild != NULL;
00353          hwndChild = ::GetWindow(hwndChild, GW_HWNDNEXT))
00354     {
00355         // Find out the window class of the child window.
00356         TCHAR achzClassName[256];
00357         ::GetClassName(hwndChild, achzClassName, 256);
00358 
00359         // If it is a button then examine the label.
00360         if (camStricmp(achzClassName, BUTTON_CLASS) == 0)
00361         {
00362             // It is a button.  Get its label.
00363             TCHAR achzButtonLabel[256];
00364             ::GetWindowText(hwndChild, achzButtonLabel, 256);
00365             
00366             // Does its label match the "help" label?
00367             if (camStricmp(achzButtonLabel, strHelpLabel) == 0)
00368             {
00369                 // It does!  Fake a click on it and return.
00370                 return ::PostMessage(hwndDialog,
00371                                      WM_COMMAND,
00372                                      (WPARAM) MAKEWPARAM(::GetDlgCtrlID(hwndChild), BN_CLICKED),
00373                                      (LPARAM) hwndChild);
00374             }
00375         }
00376     }
00377 
00378     // No help button found, can't do it.
00379     return FALSE;
00380 }

UINT32 GetNextMsgHelpContext  ) 
 

Gets the last help context set by SetNextMsgHelpContext.

Author:
Andy_Hills (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/11/00
Parameters:
none [INPUTS]
Returns:
help context
See also:
used by ScreenView::OnActivateView

Definition at line 1002 of file helpuser.cpp.

01003 {
01004     return nNextMessageHelpContext;
01005 }

BOOL HelpContents  ) 
 

Runs the system help engine, displaying the "Contents" page.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Returns:
TRUE if successful.

Errors: -

See also:
HelpUser; HelpSearch; HelpUsingHelp

Definition at line 825 of file helpuser.cpp.

00826 {
00827 #ifndef STANDALONE
00828 
00829     // If F1 was pressed, popup help in the context of the current tool. Use the tool's OpToken (of 
00830     // the form "TOOL<ToolId>") to look-up its help page. Fixes #10489
00831     if (KeyPress::IsKeyPressed(CAMKEY(F1)))
00832     {
00833         String OpToken;
00834         OpToken._MakeMsg( _T("TOOL%u"), Tool::GetCurrentID() );
00835         DWORD dwHelpIndex = LookupOperationTopic(OpToken);
00836         return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00837     }
00838 
00839     return ShowHelp(HELP_FINDER, 0);
00840 
00841 #else // STANDALONE
00842     // On the viewer go directly to the contents page on all OS's
00843     #ifdef WEBSTER
00844         return ShowHelp(HELP_CONTEXT, _R(IDH_Contents));
00845     #else //WEBSTER
00846         return ShowHelp(HELP_CONTEXT, _R(IDH_Misc_Contents));
00847     #endif // WEBSTER
00848 #endif // STANDALONE
00849 }

BOOL HelpFileExists LPTSTR  FileName  ) 
 

BOOL HelpOnlineDemos  ) 
 

Runs the system help engine, displaying the on-line demos help page.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Returns:
TRUE if successful.
See also:
HelpUser; HelpContents; HelpSearch

Definition at line 915 of file helpuser.cpp.

00916 {
00917 PORTNOTETRACE("help", "Help function unimplemented!");
00918 #if !defined(EXCLUDE_FROM_XARALX)
00919     return RunOilHelp(achzMoviesHelpPath, 0, 0);
00920 #else
00921     return FALSE;
00922 #endif
00923 }

BOOL HelpTechnicalSupport  ) 
 

Runs the system help engine, displaying the tech support help page.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/95
Returns:
TRUE if successful.
See also:
HelpUser; HelpContents; HelpSearch

Definition at line 937 of file helpuser.cpp.

00938 {
00939 #ifdef WEBSTER
00940     return FALSE;
00941 #else
00942     return ShowHelp(HELP_CONTEXT, _R(IDH_Misc_Tech_Support));
00943 #endif
00944 }

BOOL HelpUser UINT32  nMessageID  ) 
 

Public function that finds the help topic associated with the given message and runs the system help engine to display the topic.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
nMessageID the resource identifier of the message to display [INPUTS] help about
Returns:
TRUE if help was successfully provided, FALSE otherwise
See also:
RunOilHelp; LookupMessageTopic

Definition at line 722 of file helpuser.cpp.

00723 {
00724     // Look-up the message ID in our list of help topics.  If we can't find it
00725     // then return a failure code.
00726     DWORD dwHelpIndex = LookupMessageTopic(nMessageID);
00727     if (dwHelpIndex == 0)
00728     {
00729         TRACEUSER( "Ollie", _T("Can't find help topic for message 0x%lX\n"),
00730                                 (UINT32) nMessageID);
00731         return FALSE;
00732     }
00733 
00734     // Show this topic in the help system and return a success code.
00735     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00736 }

BOOL HelpUser const OpDescriptor opdesc  ) 
 

Public function that finds the help topic associated with the given OpDescriptor and runs the system help engine to display the topic.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
opdesc the OpDescriptor of the Operation to provide help for [INPUTS]
Returns:
TRUE if help was successfully provided, FALSE if not.
See also:
RunOilHelp; LookupOperationTopic

Definition at line 686 of file helpuser.cpp.

00687 {
00688     // Check if a help topic is already recorded within the OpDescriptor.  If it isn't
00689     // then we will have to look it up instead.
00690 /*
00691     //  NB. all the help topic ID's within the OpDescriptors are wrong, so ignore them!
00692     DWORD dwHelpIndex = ((OpDescriptor&) opdesc).GetHelpId();
00693     if (dwHelpIndex == 0) dwHelpIndex = LookupOperationTopic(opdesc.Token);
00694 */
00695     DWORD dwHelpIndex = LookupOperationTopic(opdesc.Token);
00696     if (dwHelpIndex == 0)
00697     {
00698         TRACEUSER( "Ollie", _T("Can't find help topic for the %s OpDescriptor\n"),
00699                                 (LPCTSTR) opdesc.Token);
00700         return FALSE;
00701     }
00702 
00703     // Show the topic we have found.
00704     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00705 }

BOOL HelpUser const wxDialog &  dlg  ) 
 

Public function that finds the help topic associated with the given MFC dialog and runs the system help engine to display the topic.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
dlg the MFC dialog that requires help [INPUTS]
Returns:
TRUE if help was successfully provided, FALSE if not.
See also:
RunOilHelp; LookupDialogTopic

Definition at line 656 of file helpuser.cpp.

00657 {
00658     // Look-up the class name/page ID in our list of help topics.  If we can't find it
00659     // then we return a failure code.
00660     DWORD dwHelpIndex = LookupDialogTopic(dlg.GetClassInfo()->GetClassName(), 0);
00661     if (dwHelpIndex == 0)
00662     {
00663         TRACEUSER( "Ollie", _T("Can't find help topic for the %s MFC dialog\n"),
00664                                 (LPCTSTR) dlg.GetClassInfo()->GetClassName());
00665         return FALSE;
00666     }
00667 
00668     // Show this topic in the help system and return a success code.
00669     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00670 }

BOOL HelpUser const DialogOp DlgOp  ) 
 

Public function that finds the help topic associated with the given dialog operation and runs the system help engine to display the topic.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
DlgOp reference to a (constant) dialog operation to display [INPUTS] help about
Returns:
TRUE if help was successfully provided, FALSE if not.
See also:
RunOilHelp; LookupDialogTopic

Definition at line 592 of file helpuser.cpp.

00593 {
00594     // Work out which page within the dialog is visible, if appropriate.  We begin by
00595     // assuming this isn't relevant.
00596     UINT32 nPageResID = 0;
00597     if (DlgOp.IsKindOf(TABBED_DIALOG_CLASS))
00598     {
00599         // Work out which is the active (top-most) page within the tabbed dialog.
00600         wxWindow* pWnd = (wxWindow*) DlgOp.WindowID;
00601         if (pWnd != NULL)
00602         {
00603             // We got the window handle, get its MFC CWnd analogue.
00604             wxBookCtrlBase* pSheet = DialogManager::GetBookControl( pWnd );
00605             if (pSheet != NULL)
00606             {
00607                 // Ask it for the resource ID of its currently active page.
00608                 nPageResID = (UINT32) pSheet->GetCurrentPage()->GetId();
00609             }
00610 #ifdef _DEBUG
00611             else
00612             {
00613                 TRACEUSER( "Ollie", _T("Null OurPropSheet pointer in HelpUser\n"));
00614             }
00615 #endif
00616         }
00617 #ifdef _DEBUG
00618         else
00619         {
00620             TRACEUSER( "Ollie", _T("Null DialogOp window handle in HelpUser\n"));
00621         }
00622 #endif
00623     }
00624 
00625     // Get the run-time class name etc of the dialog.
00626     LPCTSTR lpcszDialogClass = DlgOp.GetRuntimeClass()->m_lpszClassName;
00627 
00628     // Look-up the class name/page ID in our list of help topics.  If we can't find it
00629     // then we return a failure code.
00630     DWORD dwHelpIndex = LookupDialogTopic(lpcszDialogClass, nPageResID);
00631     if (dwHelpIndex == 0)
00632     {
00633         TRACEUSER( "Ollie", _T("Can't find help topic for %s dialog (page ID %lu)\n"),
00634                                 (LPTSTR) lpcszDialogClass, (UINT32) nPageResID);
00635         return FALSE;
00636     }
00637 
00638     // Show this topic in the help system and return a success code.
00639     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00640 }

BOOL HelpUserPropertyPage UINT32  PageID  ) 
 

Public function that finds the help topic associated with the given property page. This is required due to the new way the tabbed dialogs work (via MFC).

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/5/97
Parameters:
PageID ResourceID of the currently active page [INPUTS]
Returns:
TRUE if help was successfully provided, FALSE otherwise

Definition at line 752 of file helpuser.cpp.

00753 {
00754     DWORD dwHelpIndex = LookupDialogTopic(NULL, PageID);
00755     return (HelpUserTopic(dwHelpIndex));
00756 }

BOOL HelpUserTopic DWORD  dwHelpIndex  ) 
 

Public function that finds the help topic associated with the given message and runs the system help engine to display the topic.

> BOOL HelpUserTopic(DWORD dwHelpIndex)

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
nMessageID the resource identifier of the message to display [INPUTS] help about
Returns:
TRUE if help was successfully provided, FALSE otherwise

Definition at line 772 of file helpuser.cpp.

00773 {
00774     if (dwHelpIndex == 0)
00775         return FALSE;
00776     
00777     // Show this topic in the help system and return a success code.
00778     return ShowHelp(HELP_CONTEXT, dwHelpIndex);
00779 }

BOOL HelpUsingGalleries  ) 
 

Runs the system help engine, displaying the help on galleries.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Returns:
TRUE if successful.
See also:
HelpUser; HelpContents; HelpSearch

Definition at line 898 of file helpuser.cpp.

00899 {
00900     return ShowHelp(HELP_CONTEXT, _R(IDH_Overview_Galleries));
00901 }

BOOL HelpUsingHelp  ) 
 

Runs the system help engine, displaying the system's instructions for using it.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Returns:
TRUE if successful.
See also:
HelpUser; HelpContents; HelpSearch

Definition at line 864 of file helpuser.cpp.

00865 {
00866     return RunOilHelp(NULL, HELP_HELPONHELP, 0);
00867 }

BOOL HelpUsingTools  ) 
 

Runs the system help engine, displaying the help on tools.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Returns:
TRUE if successful.
See also:
HelpUser; HelpContents; HelpSearch

Definition at line 881 of file helpuser.cpp.

00882 {
00883     return ShowHelp(HELP_CONTEXT, _R(IDH_Misc_Tools));
00884 }

BOOL InitHelpPath BOOL  bMainHelp  ) 
 

Initialises the help system. This should generally be called before just about everything else, so help is available for startup problems.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Returns:
TRUE if successful.
See also:
DeInitUserHelp

Definition at line 1052 of file helpuser.cpp.

01053 {
01054     if( !bMainHelp )
01055     {
01056         PORTNOTETRACE("help", "InitHelpPath does not support Movie path yet");
01057     }
01058 
01059     // Get the locale id
01060     wxString    strLocale( setlocale( LC_MESSAGES, NULL ), wxConvUTF8 );
01061     INT32       ordSep = strLocale.Find( _T('_' ) );
01062     if ( -1 != ordSep )
01063         strLocale = strLocale.Left( ordSep );
01064     TRACEUSER( "jlh92", _T("Locale = %s\n"), PCTSTR(strLocale) );
01065     
01066     // Locale C is considered a synonym for en
01067     if( strLocale == _T("C") )
01068         strLocale = _T("en");
01069 
01070     // Check the help dir exists, if not bomb out
01071     wxString    strHelpPath( (PCTSTR)CCamApp::GetResourceDirectory() );
01072     strHelpPath += _T("/doc/");
01073     TRACEUSER( "jlh92", _T("Using filter discovery directory \"%s\"\n"), PCTSTR(strHelpPath + strLocale) );
01074     if( wxDir::Exists( strHelpPath + strLocale ) )
01075         strHelpPath += strLocale + _T("/");
01076     else
01077     {
01078         if( wxDir::Exists( strHelpPath + _T("en") ) )
01079             strHelpPath += _T("en/");
01080 #if defined(_DEBUG)
01081         else
01082         {
01083             // We'll try default location under debug to make life easier
01084             strHelpPath = _T("/usr/share/xaralx/doc/en/");
01085             TRACEUSER( "jlh92", _T("Try = \"%s\"\n"), PCTSTR(strHelpPath) );
01086         }
01087 #endif
01088     }
01089 
01090     achzHelpPath = strHelpPath;
01091     PORTNOTE( "help", "We should check and report non-existant help directory at some point" )
01092     return TRUE; // wxDir::Exists( strHelpPath );
01093 }

BOOL InitUserHelp  ) 
 

Definition at line 1024 of file helpuser.cpp.

01025 {
01026 #if !defined(EXCLUDE_FROM_XARALX)
01027     // If we have any deferred file copies, deal with them now...
01028     HelpDownloadOp::DoDeferredFileCopy();
01029 #endif
01030 
01031     // init main help file:
01032     BOOL bOK = InitHelpPath(TRUE);
01033 
01034     // init movies help file
01035     bOK = bOK && InitHelpPath(FALSE);
01036 
01037 #if !defined(EXCLUDE_FROM_XARALX)
01038     // Install a message filter hook to trap F1 being pressed in dialogs etc.  We don't need
01039     // one for menus as our "custom menu code" (ha ha ha) does this already.
01040     hF1Hook = ::SetWindowsHookEx(WH_MSGFILTER, F1HookProc, NULL, ::GetCurrentThreadId());
01041     ERROR3IF(hF1Hook == NULL, "Couldn't set F1 key hook in InitUserHelp");
01042 
01043     // Success!?!
01044     return hF1Hook != NULL;
01045 #else
01046     return bOK;
01047 #endif
01048 }

static DWORD LookupDialogTopic LPCTSTR  lpcszLookupClass,
UINT32  nPageResID
[static]
 

Private helper function that finds the help topic associated with "named" dialogs, ie. those dialogs that are managed by a specialised C++ class, not error or warning dialogs.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
lpcszLookupClass the run-time class name of the dialog to find [INPUTS] on-line help about. Can be null - in which case we just check the PageID nPageResID the resource ID of the current page, if we want help on a 'tabbed' dialog
Returns:
The index ID of the appropriate help topic, or zero if there isn't one.
See also:
HelpUser

Definition at line 223 of file helpuser.cpp.

00224 {
00225     // Check we're not being passed junk.
00226 //  ERROR3IF(lpcszLookupClass == NULL, "No dialog class in LookupDialogTopic");
00227         
00228     // Scan through the whole table.
00229     for (DialogHelpTuple* ptpl = atplDialogTopics;
00230          ptpl->lpcszDialogClass != NULL;
00231          ptpl++)
00232     {
00233         // If the class-names & page ID's match then return the associated topic index.
00234         if ((lpcszLookupClass == NULL || ::camStricmp(ptpl->lpcszDialogClass, lpcszLookupClass) == 0) &&
00235             ptpl->nPageResID == nPageResID)
00236         {
00237             return ptpl->dwTopicIndex;
00238         }
00239     }
00240 
00241     // Couldn't find such a dialog class.
00242     return 0;
00243 }

static DWORD LookupMessageTopic UINT32  nMessageID  )  [static]
 

Private helper function that finds the help topic associated with the given message, generally diaplayed in an error or warning dialog.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
nMessageID the resource identifier of the message displayed in an [INPUTS] error or warning dialog
Returns:
The index ID of the appropriate help topic, or zero if there isn't one.
See also:
HelpUser

Definition at line 296 of file helpuser.cpp.

00297 {
00298 #ifndef STANDALONE
00299     // If we have no message ID then use the last one passed to MakeMsg.
00300     if (nMessageID == 0) nMessageID = nNextMessageHelpContext;
00301 
00302     // Start at the beginning of the table, naturally . . .
00303     MsgHelpTuple* ptpl = atplMsgTopics;
00304     DWORD dwHelpTopic;
00305 
00306     // The table is terminated by a zero topic index.
00307     while ((dwHelpTopic = *ptpl++) != 0)
00308     {
00309         // Each sub-table is terminated by a zero message ID.
00310         while (*ptpl != 0)
00311         {
00312             // If one of the following matches the message then return the help topic.
00313             if (*ptpl++ == nMessageID) return dwHelpTopic;
00314         }
00315 
00316         // Skip over the terminating message ID.
00317         ptpl++;
00318     }
00319 #endif
00320     // No help topic for this message, so sorry.
00321     return 0;
00322 }

static DWORD LookupOperationTopic LPCTSTR  lpcszOpName  )  [static]
 

Private helper function that finds the help topic associated with Camelot operations, eg. those things exposed in menus!

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/5/95
Parameters:
lpcszOpName the OPTOKEN value of the Operation to look up help [INPUTS] for
Returns:
The index ID of the appropriate help topic, or zero if there isn't one.
See also:
HelpUser

Definition at line 260 of file helpuser.cpp.

00261 {
00262     // Check for junk.
00263     ERROR3IF(lpcszOpName == NULL, "No valid OpToken in LookupOperationTopic");
00264 
00265     // Scan through the whole table.
00266     for (OpHelpTuple* ptpl = atplOpTopics;
00267          ptpl->lpcszToken != NULL;
00268          ptpl++)
00269     {
00270         // If the token values match then we've found our help topic.
00271         if (::camStricmp(ptpl->lpcszToken, lpcszOpName) == 0)
00272         {
00273             return ptpl->dwTopicIndex;
00274         }
00275     }
00276 
00277     // No help topic, so sorry.
00278     return 0;
00279 }

BOOL MakeShortPath LPTSTR  lpszPath,
size_t  cchMaxLen
 

Special function to work around an ommission in Win32s, which does not include the GetShortPathName function, even though Win32s is supposed to export ALL Win32 functions. This version does nothing under Win32s, which shortens pathnames automatically (?), under other versions of Windows it dynamically links to the function in the kernel32 library, thus avoiding an explicit link to the function which would prevent the app loading.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/95
Parameters:
lpszPath the full path to shorten. The shortened version will be [INPUTS] "outputed" into this same buffer. cchMaxLen the size of the above buffer
lpszPath contains the shortened path [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise.

Errors: -

See also:
-

Definition at line 514 of file helpuser.cpp.

00515 {
00516 PORTNOTETRACE("help", "Help function unimplemented!");
00517 #if !defined(EXCLUDE_FROM_XARALX)
00518     // Under Win32s we don't want to do this, because (i) Win32s does it anyway;
00519     // and (ii) the bloody GetShortPathName function isn't supported because they
00520     // forgot it (a serious bug, Mr Gates!)
00521     if (IsWin32s() && !IsWin32c()) return TRUE;
00522 
00523     // Now we have some aggro.  Because GetShortPathName isn't recognised as a Win32
00524     // function by Win32s, we must NOT have any explicit references to it in the program,
00525     // or the app won't load under Win32s.  Instead, we will try to dynamically link to it.
00526     HMODULE hlib = ::GetModuleHandle(TEXT("KERNEL32"));
00527     if (hlib == NULL)
00528     {
00529         TRACEUSER( "Ollie", _T("MakeShortPath: GetModuleHandle failed (error: %lu)\n"),
00530                                 (UINT32) ::GetLastError());
00531         return FALSE;
00532     }
00533 
00534     // OK, we've loaded the relevant library.  Now try to link to the function it contains.
00535     typedef DWORD (WINAPI *GSPNFUNC)(LPCTSTR, LPTSTR, DWORD);
00536     GSPNFUNC lpfn = (GSPNFUNC) ::GetProcAddress(hlib, GETSHORTPATHNAME);
00537     if (lpfn == NULL)
00538     {
00539         TRACEUSER( "Ollie", _T("MakeShortPath: GetProcAddress failed (error: %lu)\n"),
00540                                 (UINT32) ::GetLastError());
00541         return FALSE;
00542     }
00543 
00544     // Now call the GetShortPathName function and return a success code.
00545     DWORD dwResult = (*lpfn)(lpszPath, lpszPath, cchMaxLen);
00546     return dwResult != 0 && dwResult < cchMaxLen;
00547 #else
00548     return FALSE;
00549 #endif
00550 }

static BOOL RunOilHelp LPCTSTR  lpcszHelpPath,
UINT32  nCommand,
DWORD  dwData
[static]
 

Private helper function that runs the system's help engine, whatever that might be, passing the given command. On Windows this is WINHELP.EXE or WINHLP32.EXE, on RISCOS it's get-the-manual-out time . . .

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/95
Parameters:
lpcszHelpPath string containing the path to the helpfile to display. [INPUTS] nCommand the command identifier to pass to the help engine, eg HELP_CONTEXT or HELP_CONTENTS. dwData extra data to pass to the help engine, eg. the topic index, or zero.
Returns:
TRUE if the help engine was run successfully, FALSE otherwise.
See also:
HelpUser

Definition at line 435 of file helpuser.cpp.

00436 {
00437 #if !defined(EXCLUDE_FROM_XARALX)
00438     // Firing up the help engine can take a while, so show an hour-glass cursor.
00439     HCURSOR hOldCursor;
00440     HCURSOR hBusyCursor = ::LoadCursor(NULL, _R(IDC_WAIT));
00441     if (hBusyCursor != NULL) hOldCursor = ::SetCursor(hBusyCursor);
00442 
00443     // We always pass the handle of the main-frame window as the "owning" window.
00444     HWND hwndInvoker = GetMainFrame()->GetSafeHwnd();
00445 #endif
00446 
00447     // If we are running on a pure 32-bit platform such as Windows NT then we must fake
00448     // the WinHelp() function, as we want the 16-bit engine to be run, not WINHLP32.EXE.
00449     // The current help-file build includes references to 16-bit DLLs that seem to be
00450     // almost too much for the 32-bit engine.  We don't have to do this if we aren't
00451     // running the engine to browse a file, but simply issuing a command, such as
00452     // HELP_HELPONHELP.
00453     BOOL fOk;
00454     
00455         // Running under Chicago or Win32s, or the helpfile parameter is NULL, so run the
00456         // "normal" engine.  Here we should really "thunk" (translate) the 32-bit HWND
00457         // to a 16-bit HWND, I think?
00458 //      TRACEUSER( "JustinF", _T("Help being invoked normally\n"));
00459 
00460 
00461         fOk = TRUE;
00462         if(nCommand != HELP_QUIT)
00463         {
00464             wxString strHelpFileName(lpcszHelpPath);
00465             wxString Context = _T("");
00466             if (dwData)
00467             {
00468                 Context = PCTSTR(String_256( dwData ));
00469                 if (_T("") != Context)
00470                     // so that the string table contains a bit less, the ::/xarax/ and .htm
00471                     // are here, because they are common to every HTML help path.
00472                     strHelpFileName += _T("xarax/") + Context + _T(".htm");
00473             }
00474 
00475             CCamApp::LaunchWebBrowser( strHelpFileName );
00476         }
00477 
00478 #if !defined(EXCLUDE_FROM_XARALX)
00479     // Get some slightly useful information if it all goes horribly wrong.
00480 #ifdef _DEBUG
00481     if (!fOk) TRACEUSER( "Ollie", _T("RunOilHelp failed - last error: %lu\n"),
00482                                         (UINT32) ::GetLastError());
00483 #endif
00484 
00485     // Undo the hour-glass cursor and return a success code.
00486     if (hBusyCursor != NULL) ::SetCursor(hOldCursor);
00487 #endif
00488 
00489     return fOk;
00490 }

void SetNextMsgHelpContext UINT32  nMessageID  ) 
 

Remembers the last format string passed to MakeMsg. If a call is made to InformWarning, InformError etc and no string resource ID is passed then we have a problem using the string resource as an index into the help file. This remembers that last one, which we use if the "error ID" is zero.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/5/95
Parameters:
nMessageID the last message format string passed to MakeMsg [INPUTS]
See also:
StringBase::MakeMsg

Definition at line 983 of file helpuser.cpp.

00984 {
00985     nNextMessageHelpContext = nMessageID;
00986     //TRACEUSER( "Andy", _T("\tSetNextMsgHelpContext(%d)\n"), nMessageID);
00987 }

static BOOL ShowHelp UINT32  nCommand,
DWORD  dwData
[static]
 

Called to display the given topic in the Xara Studio general help file. Makes a note if help is run successfully that we have to shut it down when we quit.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/95
Parameters:
nCommand the command to pass to the help engine, eg. HELP_CONTENTS [INPUTS]
Returns:
TRUE if successful.

Definition at line 566 of file helpuser.cpp.

00567 {
00568     BOOL fResult = RunOilHelp(achzHelpPath, nCommand, dwData);
00569     if (!fHaveUsedHelp && fResult) fHaveUsedHelp = TRUE;
00570     return fResult;
00571 }


Variable Documentation

String_256 achzHelpPath [static]
 

Definition at line 173 of file helpuser.cpp.

TCHAR achzMoviesHelpPath[_MAX_PATH] [static]
 

Definition at line 177 of file helpuser.cpp.

BOOL fHaveUsedHelp = FALSE [static]
 

Definition at line 190 of file helpuser.cpp.

HHOOK hF1Hook = NULL [static]
 

Definition at line 185 of file helpuser.cpp.

UINT32 nNextMessageHelpContext = 0 [static]
 

Definition at line 199 of file helpuser.cpp.


Generated on Sat Nov 10 03:49:32 2007 for Camelot by  doxygen 1.4.4