]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/helpwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
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()
38 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
.IsEmpty()) return false;
63 wxString str
= GetValidFilename(m_helpFile
);
65 #if defined(__WIN95__)
66 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_FINDER
, 0L) != 0);
68 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_CONTENTS
, 0L) != 0);
72 bool wxWinHelpController::DisplaySection(int section
)
75 if (m_helpFile
.IsEmpty()) return false;
77 wxString str
= GetValidFilename(m_helpFile
);
79 return (WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
) != 0);
82 bool wxWinHelpController::DisplayContextPopup(int contextId
)
84 if (m_helpFile
.IsEmpty()) return false;
86 wxString str
= GetValidFilename(m_helpFile
);
88 return (WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXTPOPUP
, (DWORD
) contextId
) != 0);
91 bool wxWinHelpController::DisplayBlock(long block
)
93 DisplaySection(block
);
97 bool wxWinHelpController::KeywordSearch(const wxString
& k
,
98 wxHelpSearchMode
WXUNUSED(mode
))
100 if (m_helpFile
.IsEmpty()) return false;
102 wxString str
= GetValidFilename(m_helpFile
);
104 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
) != 0);
107 // Can't close the help window explicitly in WinHelp
108 bool wxWinHelpController::Quit(void)
110 return (WinHelp(GetSuitableHWND(), 0, HELP_QUIT
, 0L) != 0);
113 // Append extension if necessary.
114 wxString
wxWinHelpController::GetValidFilename(const wxString
& file
) const
116 wxString path
, name
, ext
;
117 wxSplitPath(file
, & path
, & name
, & ext
);
121 fullName
= name
+ wxT(".hlp");
122 else if (path
.Last() == wxT('\\'))
123 fullName
= path
+ name
+ wxT(".hlp");
125 fullName
= path
+ wxT("\\") + name
+ wxT(".hlp");