wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / msw / wince / helpwce.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/wince/helpwce.cpp
3 // Purpose: Help system: Windows CE help implementation
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2003-07-12
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_HELP
19
20 #include "wx/filefn.h"
21 #include "wx/msw/wince/helpwce.h"
22
23 #ifndef WX_PRECOMP
24 #include "wx/msw/missing.h"
25 #include "wx/intl.h"
26 #endif
27
28 #include "wx/msw/private.h"
29
30 IMPLEMENT_DYNAMIC_CLASS(wxWinceHelpController, wxHelpControllerBase)
31
32 bool wxWinceHelpController::Initialize(const wxString& filename)
33 {
34 m_helpFile = filename;
35 return true;
36 }
37
38 bool wxWinceHelpController::LoadFile(const wxString& file)
39 {
40 if (!file.empty())
41 m_helpFile = file;
42 return true;
43 }
44
45 bool wxWinceHelpController::DisplayContents()
46 {
47 return ViewURL();
48 }
49
50 // Use topic
51 bool wxWinceHelpController::DisplaySection(const wxString& section)
52 {
53 return ViewURL(section);
54 }
55
56 // Use context number
57 bool wxWinceHelpController::DisplaySection(int WXUNUSED(section))
58 {
59 return true;
60 }
61
62 bool wxWinceHelpController::DisplayContextPopup(int WXUNUSED(contextId))
63 {
64 return true;
65 }
66
67 bool wxWinceHelpController::DisplayTextPopup(const wxString& WXUNUSED(text), const wxPoint& WXUNUSED(pos))
68 {
69 return true;
70 }
71
72 bool wxWinceHelpController::DisplayBlock(long WXUNUSED(block))
73 {
74 return true;
75 }
76
77 bool wxWinceHelpController::KeywordSearch(const wxString& WXUNUSED(k),
78 wxHelpSearchMode WXUNUSED(mode))
79 {
80 return true;
81 }
82
83 bool wxWinceHelpController::Quit()
84 {
85 return true;
86 }
87
88 // Append extension if necessary.
89 wxString wxWinceHelpController::GetValidFilename(const wxString& file) const
90 {
91 wxString path, name, ext;
92 wxFileName::SplitPath(file, & path, & name, & ext);
93
94 wxString fullName;
95 if (path.empty())
96 fullName = name + wxT(".htm");
97 else if (path.Last() == wxT('\\'))
98 fullName = path + name + wxT(".htm");
99 else
100 fullName = path + wxT("\\") + name + wxT(".htm");
101
102 if (!wxFileExists(fullName))
103 fullName = wxT("\\Windows\\") + name + wxT(".htm");
104
105 return fullName;
106 }
107
108 // View URL
109 bool wxWinceHelpController::ViewURL(const wxString& topic)
110 {
111 if (m_helpFile.empty()) return false;
112
113 wxString url( wxT("file:") + GetValidFilename(m_helpFile) );
114 if (!topic.empty())
115 url = url + wxT("#") + topic;
116
117 return CreateProcess(wxT("peghelp.exe"),
118 url, NULL, NULL, FALSE, 0, NULL,
119 NULL, NULL, NULL) != 0 ;
120 }
121
122 #endif // wxUSE_HELP