]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/helpwin.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/msw/helpwin.cpp 
   3 // Purpose:     Help system: WinHelp implementation 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  24 #include "wx/filefn.h" 
  25 #include "wx/msw/helpwin.h" 
  30 #include "wx/msw/private.h" 
  35 static HWND 
GetSuitableHWND(wxWinHelpController
* controller
) 
  37     if (controller
->GetParentWindow()) 
  38         return (HWND
) controller
->GetParentWindow()->GetHWND(); 
  39     else if (wxTheApp
->GetTopWindow()) 
  40         return (HWND
) wxTheApp
->GetTopWindow()->GetHWND(); 
  42         return GetDesktopWindow(); 
  45 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController
, wxHelpControllerBase
) 
  47 bool wxWinHelpController::Initialize(const wxString
& filename
) 
  49     m_helpFile 
= filename
; 
  53 bool wxWinHelpController::LoadFile(const wxString
& file
) 
  60 bool wxWinHelpController::DisplayContents(void) 
  62     if (m_helpFile
.empty()) return false; 
  64     wxString str 
= GetValidFilename(m_helpFile
); 
  66     return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_FINDER
, 0L) != 0); 
  69 bool wxWinHelpController::DisplaySection(int section
) 
  72     if (m_helpFile
.empty()) return false; 
  74     wxString str 
= GetValidFilename(m_helpFile
); 
  76     return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
) != 0); 
  79 bool wxWinHelpController::DisplayContextPopup(int contextId
) 
  81     if (m_helpFile
.empty()) return false; 
  83     wxString str 
= GetValidFilename(m_helpFile
); 
  85     return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_CONTEXTPOPUP
, (DWORD
) contextId
) != 0); 
  88 bool wxWinHelpController::DisplayBlock(long block
) 
  90     DisplaySection(block
); 
  94 bool wxWinHelpController::KeywordSearch(const wxString
& k
, 
  95                                         wxHelpSearchMode 
WXUNUSED(mode
)) 
  97     if (m_helpFile
.empty()) return false; 
  99     wxString str 
= GetValidFilename(m_helpFile
); 
 101     return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
) != 0); 
 104 // Can't close the help window explicitly in WinHelp 
 105 bool wxWinHelpController::Quit(void) 
 107     return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT
, 0L) != 0); 
 110 // Append extension if necessary. 
 111 wxString 
wxWinHelpController::GetValidFilename(const wxString
& file
) const 
 113     wxString path
, name
, ext
; 
 114     wxSplitPath(file
, & path
, & name
, & ext
); 
 118         fullName 
= name 
+ wxT(".hlp"); 
 119     else if (path
.Last() == wxT('\\')) 
 120         fullName 
= path 
+ name 
+ wxT(".hlp"); 
 122         fullName 
= path 
+ wxT("\\") + name 
+ wxT(".hlp");