]>
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 #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
)
103 if (m_helpFile
.IsEmpty()) return FALSE
;
105 wxString str
= GetValidFilename(m_helpFile
);
107 return (WinHelp(GetSuitableHWND(), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
) != 0);
110 // Can't close the help window explicitly in WinHelp
111 bool wxWinHelpController::Quit(void)
113 return (WinHelp(GetSuitableHWND(), 0, HELP_QUIT
, 0L) != 0);
116 // Append extension if necessary.
117 wxString
wxWinHelpController::GetValidFilename(const wxString
& file
) const
119 wxString path
, name
, ext
;
120 wxSplitPath(file
, & path
, & name
, & ext
);
124 fullName
= name
+ wxT(".hlp");
125 else if (path
.Last() == wxT('\\'))
126 fullName
= path
+ name
+ wxT(".hlp");
128 fullName
= path
+ wxT("\\") + name
+ wxT(".hlp");