• R/O
  • SSH
  • HTTPS

copalpro: Commit


Commit MetaInfo

Revision5 (tree)
Time2011-08-01 10:25:35
Authorkaityo

Log Message

Bugfix on HTMLHhelp

Change Summary

Incremental Difference

--- CopalPro/HHelp.cpp (revision 4)
+++ CopalPro/HHelp.cpp (revision 5)
@@ -10,10 +10,7 @@
1010 //---------------------------------------------------------------------------
1111 #pragma package(smart_init)
1212 //---------------------------------------------------------------------------
13-HINSTANCE Htmlhelp::Handle = NULL;
14-//---------------------------------------------------------------------------
15-void
16-Htmlhelp::Init(void){
13+Htmlhelp::Htmlhelp(void){
1714 Handle = LoadLibrary("HHCTRL.OCX");
1815 if(Handle==NULL) {
1916 ShowMessage("HHCTRL.OCXが見つかりません");
@@ -21,8 +18,7 @@
2118 }
2219 }
2320 //---------------------------------------------------------------------------
24-void
25-Htmlhelp::Free(void){
21+Htmlhelp::~Htmlhelp(void){
2622 FreeLibrary(Handle);
2723 }
2824 //---------------------------------------------------------------------------
--- CopalPro/htmlhelp.h (revision 4)
+++ CopalPro/htmlhelp.h (revision 5)
@@ -17,18 +17,18 @@
1717 extern "C" {
1818 #endif // __cplusplus
1919
20- // Defines for Win64
20+// Defines for Win64
2121 #ifndef _WIN64
2222 #define DWORD_PTR DWORD
2323 #endif
2424
25- // Commands to pass to HtmlHelp()
25+// Commands to pass to HtmlHelp()
2626
2727 #define HH_DISPLAY_TOPIC 0x0000
2828 #define HH_HELP_FINDER 0x0000 // WinHelp equivalent
29-#define HH_DISPLAY_TOC 0x0001
30-#define HH_DISPLAY_INDEX 0x0002
31-#define HH_DISPLAY_SEARCH 0x0003
29+#define HH_DISPLAY_TOC 0x0001
30+#define HH_DISPLAY_INDEX 0x0002
31+#define HH_DISPLAY_SEARCH 0x0003
3232 #define HH_SET_WIN_TYPE 0x0004
3333 #define HH_GET_WIN_TYPE 0x0005
3434 #define HH_GET_WIN_HANDLE 0x0006
@@ -53,7 +53,7 @@
5353 #define HH_SET_EXCLUSIVE_FILTER 0x0019 // set exclusive filtering method for untyped topics to be excluded from display
5454 #define HH_INITIALIZE 0x001C // Initializes the help system.
5555 #define HH_UNINITIALIZE 0x001D // Uninitializes the help system.
56-#define HH_PRETRANSLATEMESSAGE 0x00fd // Pumps messages. (NULL, NULL, MSG*).
56+#define HH_PRETRANSLATEMESSAGE 0x00fd // Pumps messages. (NULL, NULL, MSG*).
5757 #define HH_SET_GLOBAL_PROPERTY 0x00fc // Set a global property. (NULL, NULL, HH_GPROP)
5858
5959 #define HHWIN_PROP_TAB_AUTOHIDESHOW (1 << 0) // Automatically hide/show tri-pane window
@@ -129,7 +129,7 @@
129129 HHWIN_BUTTON_OPTIONS | \
130130 HHWIN_BUTTON_PRINT)
131131
132- // Button IDs
132+// Button IDs
133133
134134 #define IDTB_EXPAND 200
135135 #define IDTB_CONTRACT 201
@@ -156,7 +156,7 @@
156156 #define IDTB_TOC_NEXT 223
157157 #define IDTB_TOC_PREV 224
158158
159- // Notification codes
159+// Notification codes
160160
161161 #define HHN_FIRST (0U-860U)
162162 #define HHN_LAST (0U-879U)
@@ -165,13 +165,14 @@
165165 #define HHN_TRACK (HHN_FIRST-1)
166166 #define HHN_WINDOW_CREATE (HHN_FIRST-2)
167167
168- typedef struct tagHHN_NOTIFY {
168+typedef struct tagHHN_NOTIFY
169+{
169170 NMHDR hdr;
170171 PCSTR pszUrl; // Multi-byte, null-terminated string
171- }
172- HHN_NOTIFY;
172+} HHN_NOTIFY;
173173
174- typedef struct tagHH_POPUP {
174+typedef struct tagHH_POPUP
175+{
175176 int cbStruct; // sizeof this structure
176177 HINSTANCE hinst; // instance handle for string resource
177178 UINT idString; // string resource id, or text id if pszFile is specified in HtmlHelp call
@@ -181,10 +182,10 @@
181182 COLORREF clrBackground; // use -1 for default
182183 RECT rcMargins; // amount of space between edges of window and text, -1 for each member to ignore
183184 LPCTSTR pszFont; // facename, point size, char set, BOLD ITALIC UNDERLINE
184- }
185- HH_POPUP;
185+} HH_POPUP;
186186
187- typedef struct tagHH_AKLINK {
187+typedef struct tagHH_AKLINK
188+{
188189 int cbStruct; // sizeof this structure
189190 BOOL fReserved; // must be FALSE (really!)
190191 LPCTSTR pszKeywords; // semi-colon separated keywords
@@ -193,10 +194,9 @@
193194 LPCTSTR pszMsgTitle; // Message text to display in MessageBox if pszUrl is NULL and no keyword match
194195 LPCTSTR pszWindow; // Window to display URL in
195196 BOOL fIndexOnFail; // Displays index if keyword lookup fails.
196- }
197- HH_AKLINK;
197+} HH_AKLINK;
198198
199- enum {
199+enum {
200200 HHWIN_NAVTYPE_TOC,
201201 HHWIN_NAVTYPE_INDEX,
202202 HHWIN_NAVTYPE_SEARCH,
@@ -204,49 +204,49 @@
204204 HHWIN_NAVTYPE_HISTORY, // not implemented
205205 HHWIN_NAVTYPE_AUTHOR,
206206 HHWIN_NAVTYPE_CUSTOM_FIRST = 11
207- };
207+};
208208
209- enum {
209+enum {
210210 IT_INCLUSIVE,
211211 IT_EXCLUSIVE,
212212 IT_HIDDEN,
213- };
213+};
214214
215- typedef struct tagHH_ENUM_IT {
215+typedef struct tagHH_ENUM_IT
216+{
216217 int cbStruct; // size of this structure
217218 int iType; // the type of the information type ie. Inclusive, Exclusive, or Hidden
218219 LPCSTR pszCatName; // Set to the name of the Category to enumerate the info types in a category; else NULL
219220 LPCSTR pszITName; // volitile pointer to the name of the infotype. Allocated by call. Caller responsible for freeing
220221 LPCSTR pszITDescription; // volitile pointer to the description of the infotype.
221- }
222- HH_ENUM_IT, *PHH_ENUM_IT;
222+} HH_ENUM_IT, *PHH_ENUM_IT;
223223
224- typedef struct tagHH_ENUM_CAT {
224+typedef struct tagHH_ENUM_CAT
225+{
225226 int cbStruct; // size of this structure
226227 LPCSTR pszCatName; // volitile pointer to the category name
227228 LPCSTR pszCatDescription; // volitile pointer to the category description
228- }
229- HH_ENUM_CAT, *PHH_ENUM_CAT;
229+} HH_ENUM_CAT, *PHH_ENUM_CAT;
230230
231- typedef struct tagHH_SET_INFOTYPE {
231+typedef struct tagHH_SET_INFOTYPE
232+{
232233 int cbStruct; // the size of this structure
233234 LPCSTR pszCatName; // the name of the category, if any, the InfoType is a member of.
234235 LPCSTR pszInfoTypeName; // the name of the info type to add to the filter
235- }
236- HH_SET_INFOTYPE, *PHH_SET_INFOTYPE;
236+} HH_SET_INFOTYPE, *PHH_SET_INFOTYPE;
237237
238- typedef DWORD HH_INFOTYPE;
239- typedef HH_INFOTYPE* PHH_INFOTYPE;
238+typedef DWORD HH_INFOTYPE;
239+typedef HH_INFOTYPE* PHH_INFOTYPE;
240240
241- enum {
241+enum {
242242 HHWIN_NAVTAB_TOP,
243243 HHWIN_NAVTAB_LEFT,
244244 HHWIN_NAVTAB_BOTTOM,
245- };
245+};
246246
247247 #define HH_MAX_TABS 19 // maximum number of tabs
248248
249- enum {
249+enum {
250250 HH_TAB_CONTENTS,
251251 HH_TAB_INDEX,
252252 HH_TAB_SEARCH,
@@ -256,15 +256,16 @@
256256
257257 HH_TAB_CUSTOM_FIRST = 11,
258258 HH_TAB_CUSTOM_LAST = HH_MAX_TABS
259- };
259+};
260260
261261 #define HH_MAX_TABS_CUSTOM (HH_TAB_CUSTOM_LAST - HH_TAB_CUSTOM_FIRST + 1)
262262
263- // HH_DISPLAY_SEARCH Command Related Structures and Constants
263+// HH_DISPLAY_SEARCH Command Related Structures and Constants
264264
265265 #define HH_FTS_DEFAULT_PROXIMITY (-1)
266266
267- typedef struct tagHH_FTS_QUERY {
267+typedef struct tagHH_FTS_QUERY
268+{
268269 int cbStruct; // Sizeof structure in bytes.
269270 BOOL fUniCodeStrings; // TRUE if all strings are unicode.
270271 LPCTSTR pszSearchQuery; // String containing the search query.
@@ -273,12 +274,11 @@
273274 BOOL fTitleOnly; // TRUE for Title search only.
274275 BOOL fExecute; // TRUE to initiate the search.
275276 LPCTSTR pszWindow; // Window to display in
276- }
277- HH_FTS_QUERY;
277+} HH_FTS_QUERY;
278278
279- // HH_WINTYPE Structure
279+// HH_WINTYPE Structure
280280
281- typedef struct tagHH_WINTYPE {
281+typedef struct tagHH_WINTYPE {
282282 int cbStruct; // IN: size of this structure including all Information Types
283283 BOOL fUniCodeStrings; // IN/OUT: TRUE if all strings are in UNICODE
284284 LPCTSTR pszType; // IN/OUT: Name of a type of window
@@ -322,10 +322,9 @@
322322 RECT rcMinSize; // Minimum size for window (ignored in version 1)
323323 int cbInfoTypes; // size of paInfoTypes;
324324 LPCTSTR pszCustomTabs; // multiple zero-terminated strings
325- }
326- HH_WINTYPE, *PHH_WINTYPE;
325+} HH_WINTYPE, *PHH_WINTYPE;
327326
328- enum {
327+enum {
329328 HHACT_TAB_CONTENTS,
330329 HHACT_TAB_INDEX,
331330 HHACT_TAB_SEARCH,
@@ -352,33 +351,33 @@
352351 HHACT_NOTES,
353352
354353 HHACT_LAST_ENUM,
355- };
354+};
356355
357- typedef struct tagHHNTRACK {
356+typedef struct tagHHNTRACK
357+{
358358 NMHDR hdr;
359359 PCSTR pszCurUrl; // Multi-byte, null-terminated string
360360 int idAction; // HHACT_ value
361361 HH_WINTYPE* phhWinType; // Current window type structure
362- }
363- HHNTRACK;
362+} HHNTRACK;
364363
365- HWND
366- WINAPI
367- HtmlHelpA(
364+HWND
365+WINAPI
366+HtmlHelpA(
368367 HWND hwndCaller,
369368 LPCSTR pszFile,
370369 UINT uCommand,
371370 DWORD_PTR dwData
372- );
371+ );
373372
374- HWND
375- WINAPI
376- HtmlHelpW(
373+HWND
374+WINAPI
375+HtmlHelpW(
377376 HWND hwndCaller,
378377 LPCWSTR pszFile,
379378 UINT uCommand,
380379 DWORD_PTR dwData
381- );
380+ );
382381 #ifdef UNICODE
383382 #define HtmlHelp HtmlHelpW
384383 #else
@@ -385,37 +384,37 @@
385384 #define HtmlHelp HtmlHelpA
386385 #endif // !UNICODE
387386
388- // Use the following for GetProcAddress to load from hhctrl.ocx
387+// Use the following for GetProcAddress to load from hhctrl.ocx
389388
390389 #define ATOM_HTMLHELP_API_ANSI (LPTSTR)((DWORD)((WORD)(14)))
391390 #define ATOM_HTMLHELP_API_UNICODE (LPTSTR)((DWORD)((WORD)(15)))
392391
393- ///////////////////////////////////////////////////////////////////////////////
394- //
395- // Global Control Properties.
396- //
397- typedef enum tagHH_GPROPID
398- {
392+///////////////////////////////////////////////////////////////////////////////
393+//
394+// Global Control Properties.
395+//
396+typedef enum tagHH_GPROPID
397+{
399398 HH_GPROPID_SINGLETHREAD=1, // VARIANT_BOOL: True for single thread
400399 HH_GPROPID_TOOLBAR_MARGIN=2, // long: Provides a left/right margin around the toolbar.
401400 HH_GPROPID_UI_LANGUAGE=3, // long: LangId of the UI.
402401 HH_GPROPID_CURRENT_SUBSET=4, // BSTR: Current subset.
403402 HH_GPROPID_CONTENT_LANGUAGE=5 // long: LandId for desired content.
404- } HH_GPROPID;
403+} HH_GPROPID;
405404
406- ///////////////////////////////////////////////////////////////////////////////
407- //
408- // Global Property structure
409- //
405+///////////////////////////////////////////////////////////////////////////////
406+//
407+// Global Property structure
408+//
410409 #ifdef __oaidl_h__
411410
412411 #pragma pack(push, 8)
413412
414- typedef struct tagHH_GLOBAL_PROPERTY {
413+typedef struct tagHH_GLOBAL_PROPERTY
414+{
415415 HH_GPROPID id;
416416 VARIANT var;
417- }
418- HH_GLOBAL_PROPERTY ;
417+} HH_GLOBAL_PROPERTY ;
419418
420419 #pragma pack(pop)
421420 #endif
--- CopalPro/HHelp.h (revision 4)
+++ CopalPro/HHelp.h (revision 5)
@@ -1,16 +1,21 @@
11 //---------------------------------------------------------------------------
2-// HTMLヘルプを表示する関数
2+// HTML Help Wrapper
33 //---------------------------------------------------------------------------
44 #ifndef HHelpH
55 #define HHelpH
66 //---------------------------------------------------------------------------
77 class Htmlhelp{
8- static HINSTANCE Handle;
8+ private:
9+ HINSTANCE Handle;
10+ Htmlhelp(void);
911 public:
10- static void ShowHtmlHelp(HWND handle,char *helpfile);
11- static void ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword);
12- static void Init(void);
13- static void Free(void);
12+ ~Htmlhelp(void);
13+ static Htmlhelp * GetInstance(void){
14+ static Htmlhelp hhelp;
15+ return &hhelp;
16+ };
17+ void ShowHtmlHelp(HWND handle,char *helpfile);
18+ void ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword);
1419 };
1520 //---------------------------------------------------------------------------
1621 #endif
--- CopalPro/Main.cpp (revision 4)
+++ CopalPro/Main.cpp (revision 5)
@@ -12,7 +12,6 @@
1212
1313 #include "KExecProc.h"
1414 #include "KCopalConfig.h"
15-#include "HHelp.h"
1615 //---------------------------------------------------------------------------
1716 #include "Main.h"
1817 #include "Editor.h"
@@ -52,6 +51,7 @@
5251
5352 MakeLanguageMenu();
5453
54+ htmlhelp = Htmlhelp::GetInstance();
5555 }
5656 //---------------------------------------------------------------------------
5757 /**
@@ -79,9 +79,6 @@
7979 MMEncode->Enabled = false;
8080 }
8181
82- //HHCTRL.OCXのロード
83- Htmlhelp::Init();
84-
8582 //BREGEXP.DLLのロード
8683 KRegexp::Init();
8784
@@ -119,7 +116,6 @@
119116 delete FileHistory;
120117
121118 KRegexp::Free();
122- Htmlhelp::Free();
123119 KCodeConv::FreeNKF32();
124120 }
125121 //---------------------------------------------------------------------------
@@ -649,9 +645,9 @@
649645 }else{
650646 AnsiString HtmlHelp = ChangeFileExt(CopalConfig->HelpFile,".chm");
651647 if(FileExists(HtmlHelp)){
652- Htmlhelp::ShowHtmlHelp(this->Handle,HtmlHelp.c_str());
648+ htmlhelp->ShowHtmlHelp(this->Handle,HtmlHelp.c_str());
653649 }else{
654- ShowMessage("ヘルプファイル(copalpro.html, copalpro.chm)が見つかりません");
650+ ShowMessage("ヘルプファイル(copalpro.chm)が見つかりません");
655651 }
656652 }
657653 }
@@ -669,7 +665,7 @@
669665 }
670666
671667 if(ExtractFileExt(CopalConfig->GetHelpFile()).LowerCase()==".chm"){
672- Htmlhelp::ShowHtmlHelpSearch(Application->Handle,CopalConfig->GetHelpFile().c_str(),FScript->GetHelpKeyWord().c_str());
668+ htmlhelp->ShowHtmlHelpSearch(Application->Handle,CopalConfig->GetHelpFile().c_str(),FScript->GetHelpKeyWord().c_str());
673669 } else {
674670 WinHelp(Application->Handle,CopalConfig->GetHelpFile().c_str(),HELP_KEY,(DWORD)FScript->GetHelpKeyWord().c_str());
675671 }
--- CopalPro/Main.h (revision 4)
+++ CopalPro/Main.h (revision 5)
@@ -25,6 +25,7 @@
2525 #include "NewLang.h"
2626 #include "OpenFile.h"
2727 #include "OpenDir.h"
28+#include "HHelp.h"
2829 //---------------------------------------------------------------------------
2930 // 定数の宣言
3031 //---------------------------------------------------------------------------
@@ -207,6 +208,7 @@
207208
208209 KCopalConfig *CopalConfig;//コンフィグ情報
209210 KFileHistory *FileHistory;//ファイルヒストリ情報
211+ Htmlhelp *htmlhelp; //HTMLヘルプのラッパ
210212
211213 int LastError; //エラーコード
212214 int GetErrorCode(void) {
Show on old repository browser