]>
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"
27 #include "wx/msw/helpwin.h"
33 #include "wx/msw/private.h"
39 #define _MAXPATHLEN 500
41 // MAX length of Help descriptor
42 #define _MAX_HELP_LEN 500
44 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController
, wxHelpControllerBase
)
46 wxWinHelpController::wxWinHelpController(void)
51 wxWinHelpController::~wxWinHelpController(void)
55 bool wxWinHelpController::Initialize(const wxString
& filename
)
57 m_helpFile
= filename
;
61 bool wxWinHelpController::LoadFile(const wxString
& file
)
67 bool wxWinHelpController::DisplayContents(void)
69 if (m_helpFile
== wxT("")) return FALSE
;
71 wxString str
= m_helpFile
;
72 size_t len
= str
.Length();
73 if (!(str
[(size_t)(len
-1)] == wxT('p') && str
[(size_t)(len
-2)] == wxT('l') && str
[(size_t)(len
-3)] == wxT('h') && str
[(size_t)(len
-4)] == wxT('.')))
76 if (wxTheApp
->GetTopWindow())
78 #if defined(__WIN95__)
79 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_FINDER
, 0L);
81 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTENTS
, 0L);
88 bool wxWinHelpController::DisplaySection(int section
)
91 if (m_helpFile
== wxT("")) return FALSE
;
93 wxString str
= m_helpFile
;
94 size_t len
= str
.Length();
95 if (!(str
[(size_t)(len
-1)] == wxT('p') && str
[(size_t)(len
-2)] == wxT('l') && str
[(size_t)(len
-3)] == wxT('h') && str
[(size_t)(len
-4)] == wxT('.')))
98 if (wxTheApp
->GetTopWindow())
100 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)section
);
106 bool wxWinHelpController::DisplayBlock(long block
)
108 // Use context number -- a very rough equivalent to block id!
109 if (m_helpFile
== wxT("")) return FALSE
;
111 wxString str
= m_helpFile
;
112 size_t len
= str
.Length();
113 if (!(str
[(size_t)(len
-1)] == 'p' && str
[(size_t)(len
-2)] == 'l' && str
[(size_t)(len
-3)] == 'h' && str
[(size_t)(len
-4)] == '.'))
116 if (wxTheApp
->GetTopWindow())
118 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_CONTEXT
, (DWORD
)block
);
124 bool wxWinHelpController::KeywordSearch(const wxString
& k
)
126 if (m_helpFile
== wxT("")) return FALSE
;
128 wxString str
= m_helpFile
;
129 size_t len
= str
.Length();
130 if (!(str
[(size_t)(len
-1)] == wxT('p') && str
[(size_t)(len
-2)] == wxT('l') && str
[(size_t)(len
-3)] == wxT('h') && str
[(size_t)(len
-4)] == wxT('.')))
133 if (wxTheApp
->GetTopWindow())
135 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), (const wxChar
*) str
, HELP_PARTIALKEY
, (DWORD
)(const wxChar
*) k
);
141 // Can't close the help window explicitly in WinHelp
142 bool wxWinHelpController::Quit(void)
144 if (wxTheApp
->GetTopWindow())
146 WinHelp((HWND
) wxTheApp
->GetTopWindow()->GetHWND(), 0, HELP_QUIT
, 0L);
153 // Don't get notified of WinHelp quitting
154 void wxWinHelpController::OnQuit(void)