]> git.saurik.com Git - wxWidgets.git/blame - src/msw/helpwin.cpp
Warning fix.
[wxWidgets.git] / src / msw / helpwin.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
a71d815b 2// Name: src/msw/helpwin.cpp
2bda0e17
KB
3// Purpose: Help system: WinHelp implementation
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
59af881e 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
2bda0e17
KB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
7520f3da 16 #pragma hdrstop
2bda0e17
KB
17#endif
18
7520f3da
WS
19#if wxUSE_HELP
20
2bda0e17 21#ifndef WX_PRECOMP
2bda0e17
KB
22#endif
23
f6bcfd97 24#include "wx/filefn.h"
2bda0e17
KB
25#include "wx/msw/helpwin.h"
26
2bda0e17
KB
27#include <time.h>
28
2049ba38 29#ifdef __WXMSW__
3096bd2f 30#include "wx/msw/private.h"
2bda0e17
KB
31#endif
32
33#include <string.h>
34
3db52265 35static HWND GetSuitableHWND(wxWinHelpController* controller)
2bda0e17 36{
3db52265
JS
37 if (controller->GetParentWindow())
38 return (HWND) controller->GetParentWindow()->GetHWND();
39 else if (wxTheApp->GetTopWindow())
f6bcfd97
BP
40 return (HWND) wxTheApp->GetTopWindow()->GetHWND();
41 else
42 return GetDesktopWindow();
2bda0e17
KB
43}
44
f6bcfd97 45IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
2bda0e17 46
38009d39 47bool wxWinHelpController::Initialize(const wxString& filename)
2bda0e17 48{
f6bcfd97 49 m_helpFile = filename;
59af881e 50 return true;
2bda0e17
KB
51}
52
53bool wxWinHelpController::LoadFile(const wxString& file)
54{
7520f3da 55 if (!file.empty())
f6bcfd97 56 m_helpFile = file;
59af881e 57 return true;
2bda0e17
KB
58}
59
60bool wxWinHelpController::DisplayContents(void)
61{
7520f3da 62 if (m_helpFile.empty()) return false;
59af881e 63
f6bcfd97 64 wxString str = GetValidFilename(m_helpFile);
59af881e 65
3db52265 66 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_FINDER, 0L) != 0);
2bda0e17
KB
67}
68
69bool wxWinHelpController::DisplaySection(int section)
70{
33b64e6f 71 // Use context number
7520f3da 72 if (m_helpFile.empty()) return false;
59af881e 73
f6bcfd97 74 wxString str = GetValidFilename(m_helpFile);
33b64e6f 75
3db52265 76 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXT, (DWORD)section) != 0);
5100cabf
JS
77}
78
79bool wxWinHelpController::DisplayContextPopup(int contextId)
80{
7520f3da 81 if (m_helpFile.empty()) return false;
59af881e 82
5100cabf
JS
83 wxString str = GetValidFilename(m_helpFile);
84
3db52265 85 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXTPOPUP, (DWORD) contextId) != 0);
2bda0e17
KB
86}
87
88bool wxWinHelpController::DisplayBlock(long block)
89{
f6bcfd97 90 DisplaySection(block);
59af881e 91 return true;
2bda0e17
KB
92}
93
69b5cec2
VS
94bool wxWinHelpController::KeywordSearch(const wxString& k,
95 wxHelpSearchMode WXUNUSED(mode))
2bda0e17 96{
7520f3da 97 if (m_helpFile.empty()) return false;
59af881e 98
f6bcfd97 99 wxString str = GetValidFilename(m_helpFile);
59af881e 100
3db52265 101 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0);
2bda0e17
KB
102}
103
104// Can't close the help window explicitly in WinHelp
105bool wxWinHelpController::Quit(void)
106{
3db52265 107 return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0L) != 0);
2bda0e17
KB
108}
109
f6bcfd97
BP
110// Append extension if necessary.
111wxString wxWinHelpController::GetValidFilename(const wxString& file) const
2bda0e17 112{
f6bcfd97
BP
113 wxString path, name, ext;
114 wxSplitPath(file, & path, & name, & ext);
115
116 wxString fullName;
7520f3da 117 if (path.empty())
f6bcfd97
BP
118 fullName = name + wxT(".hlp");
119 else if (path.Last() == wxT('\\'))
120 fullName = path + name + wxT(".hlp");
121 else
122 fullName = path + wxT("\\") + name + wxT(".hlp");
123 return fullName;
2bda0e17
KB
124}
125
47d67540 126#endif // wxUSE_HELP