]>
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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
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 WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_FINDER
, 0L);
72 WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_CONTENTS
, 0L);
77 bool wxWinHelpController::DisplaySection(int section
)
80 if (m_helpFile
.IsEmpty()) return FALSE
;
82 wxString str
= GetValidFilename(m_helpFile
);
84 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
);
88 bool wxWinHelpController::DisplayBlock(long block
)
90 DisplaySection(block
);
94 bool wxWinHelpController::KeywordSearch(const wxString
& k
)
96 if (m_helpFile
.IsEmpty()) return FALSE
;
98 wxString str
= GetValidFilename(m_helpFile
);
100 WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
);
104 // Can't close the help window explicitly in WinHelp
105 bool wxWinHelpController::Quit(void)
107 WinHelp(GetSuitableHWND(), 0, HELP_QUIT
, 0L);
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");