]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/helpwin.cpp
abaa425609b7dbfe36620e2a780214ca006ac20c
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Help system: WinHelp implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "helpwin.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
29 #include "wx/filefn.h"
30 #include "wx/msw/helpwin.h"
35 #include "wx/msw/private.h"
40 static HWND
GetSuitableHWND()
42 if (wxTheApp
->GetTopWindow())
43 return (HWND
) wxTheApp
->GetTopWindow()->GetHWND();
45 return GetDesktopWindow();
48 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController
, wxHelpControllerBase
)
50 bool wxWinHelpController::Initialize(const wxString
& filename
)
52 m_helpFile
= filename
;
56 bool wxWinHelpController::LoadFile(const wxString
& file
)
63 bool wxWinHelpController::DisplayContents(void)
65 if (m_helpFile
.IsEmpty()) return FALSE
;
67 wxString str
= GetValidFilename(m_helpFile
);
69 #if defined(__WIN95__)
70 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_FINDER
, 0L) != 0);
72 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_CONTENTS
, 0L) != 0);
76 bool wxWinHelpController::DisplaySection(int section
)
79 if (m_helpFile
.IsEmpty()) return FALSE
;
81 wxString str
= GetValidFilename(m_helpFile
);
83 return (WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
) != 0);
86 bool wxWinHelpController::DisplayContextPopup(int contextId
)
88 if (m_helpFile
.IsEmpty()) return FALSE
;
90 wxString str
= GetValidFilename(m_helpFile
);
92 return (WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXTPOPUP
, (DWORD
) contextId
) != 0);
95 bool wxWinHelpController::DisplayBlock(long block
)
97 DisplaySection(block
);
101 bool wxWinHelpController::KeywordSearch(const wxString
& k
,
102 wxHelpSearchMode
WXUNUSED(mode
))
104 if (m_helpFile
.IsEmpty()) return FALSE
;
106 wxString str
= GetValidFilename(m_helpFile
);
108 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
) != 0);
111 // Can't close the help window explicitly in WinHelp
112 bool wxWinHelpController::Quit(void)
114 return (WinHelp(GetSuitableHWND(), 0, HELP_QUIT
, 0L) != 0);
117 // Append extension if necessary.
118 wxString
wxWinHelpController::GetValidFilename(const wxString
& file
) const
120 wxString path
, name
, ext
;
121 wxSplitPath(file
, & path
, & name
, & ext
);
125 fullName
= name
+ wxT(".hlp");
126 else if (path
.Last() == wxT('\\'))
127 fullName
= path
+ name
+ wxT(".hlp");
129 fullName
= path
+ wxT("\\") + name
+ wxT(".hlp");