]>
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
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
23 #include "wx/filename.h"
24 #include "wx/msw/helpwin.h"
29 #include "wx/msw/private.h"
34 static HWND
GetSuitableHWND(wxWinHelpController
* controller
)
36 if (controller
->GetParentWindow())
37 return (HWND
) controller
->GetParentWindow()->GetHWND();
38 else if (wxTheApp
->GetTopWindow())
39 return (HWND
) wxTheApp
->GetTopWindow()->GetHWND();
41 return GetDesktopWindow();
44 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController
, wxHelpControllerBase
)
46 bool wxWinHelpController::Initialize(const wxString
& filename
)
48 m_helpFile
= filename
;
52 bool wxWinHelpController::LoadFile(const wxString
& file
)
59 bool wxWinHelpController::DisplayContents(void)
61 if (m_helpFile
.empty()) return false;
63 wxString str
= GetValidFilename(m_helpFile
);
65 return (WinHelp(GetSuitableHWND(this), str
.t_str(), HELP_FINDER
, 0L) != 0);
68 bool wxWinHelpController::DisplaySection(int section
)
71 if (m_helpFile
.empty()) return false;
73 wxString str
= GetValidFilename(m_helpFile
);
75 return (WinHelp(GetSuitableHWND(this), str
.t_str(), HELP_CONTEXT
, (DWORD
)section
) != 0);
78 bool wxWinHelpController::DisplayContextPopup(int contextId
)
80 if (m_helpFile
.empty()) return false;
82 wxString str
= GetValidFilename(m_helpFile
);
84 return (WinHelp(GetSuitableHWND(this), str
.t_str(), HELP_CONTEXTPOPUP
, (DWORD
) contextId
) != 0);
87 bool wxWinHelpController::DisplayBlock(long block
)
89 DisplaySection(block
);
93 bool wxWinHelpController::KeywordSearch(const wxString
& k
,
94 wxHelpSearchMode
WXUNUSED(mode
))
96 if (m_helpFile
.empty()) return false;
98 wxString str
= GetValidFilename(m_helpFile
);
100 return WinHelp(GetSuitableHWND(this), str
.t_str(), HELP_PARTIALKEY
,
101 (ULONG_PTR
)wxMSW_CONV_LPCTSTR(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
, 0) != 0;
110 // Append extension if necessary.
111 wxString
wxWinHelpController::GetValidFilename(const wxString
& file
) const
113 wxString path
, name
, ext
;
114 wxFileName::SplitPath(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");