]>
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"
25 #include "wx/filefn.h"
26 #include "wx/msw/helpwin.h"
31 #include "wx/msw/private.h"
36 static HWND
GetSuitableHWND(wxWinHelpController
* controller
)
38 if (controller
->GetParentWindow())
39 return (HWND
) controller
->GetParentWindow()->GetHWND();
40 else if (wxTheApp
->GetTopWindow())
41 return (HWND
) wxTheApp
->GetTopWindow()->GetHWND();
43 return GetDesktopWindow();
46 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController
, wxHelpControllerBase
)
48 bool wxWinHelpController::Initialize(const wxString
& filename
)
50 m_helpFile
= filename
;
54 bool wxWinHelpController::LoadFile(const wxString
& file
)
61 bool wxWinHelpController::DisplayContents(void)
63 if (m_helpFile
.IsEmpty()) return false;
65 wxString str
= GetValidFilename(m_helpFile
);
67 return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_FINDER
, 0L) != 0);
70 bool wxWinHelpController::DisplaySection(int section
)
73 if (m_helpFile
.IsEmpty()) return false;
75 wxString str
= GetValidFilename(m_helpFile
);
77 return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
) != 0);
80 bool wxWinHelpController::DisplayContextPopup(int contextId
)
82 if (m_helpFile
.IsEmpty()) return false;
84 wxString str
= GetValidFilename(m_helpFile
);
86 return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_CONTEXTPOPUP
, (DWORD
) contextId
) != 0);
89 bool wxWinHelpController::DisplayBlock(long block
)
91 DisplaySection(block
);
95 bool wxWinHelpController::KeywordSearch(const wxString
& k
,
96 wxHelpSearchMode
WXUNUSED(mode
))
98 if (m_helpFile
.IsEmpty()) return false;
100 wxString str
= GetValidFilename(m_helpFile
);
102 return (WinHelp(GetSuitableHWND(this), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
) != 0);
105 // Can't close the help window explicitly in WinHelp
106 bool wxWinHelpController::Quit(void)
108 return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT
, 0L) != 0);
111 // Append extension if necessary.
112 wxString
wxWinHelpController::GetValidFilename(const wxString
& file
) const
114 wxString path
, name
, ext
;
115 wxSplitPath(file
, & path
, & name
, & ext
);
119 fullName
= name
+ wxT(".hlp");
120 else if (path
.Last() == wxT('\\'))
121 fullName
= path
+ name
+ wxT(".hlp");
123 fullName
= path
+ wxT("\\") + name
+ wxT(".hlp");