• R/O
  • SSH
  • HTTPS

meijiro: Commit


Commit MetaInfo

Revision16 (tree)
Time2011-08-05 06:53:14
Authorkaityo

Log Message

Bugfix on Htmlhelp

Change Summary

Incremental Difference

--- HHelp.cpp (revision 15)
+++ HHelp.cpp (revision 16)
@@ -7,50 +7,46 @@
77 #include "htmlhelp.h"
88 #include "HHelp.h"
99
10-HINSTANCE HHCTRL = NULL;
11-typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT, DWORD);
12-FPHH htmlHelp = NULL;
13-
1410 //---------------------------------------------------------------------------
1511 #pragma package(smart_init)
1612 //---------------------------------------------------------------------------
17-void
18-InitHtmlHelp(void){
19- HHCTRL = LoadLibrary("HHCTRL.OCX");
20- if(HHCTRL==NULL) {
13+Htmlhelp::Htmlhelp(void){
14+ Handle = LoadLibrary("HHCTRL.OCX");
15+ if(Handle==NULL) {
2116 ShowMessage("HHCTRL.OCXが見つかりません");
2217 return;
2318 }
24- htmlHelp = (FPHH)GetProcAddress(HHCTRL,"HtmlHelpA");
25- if(htmlHelp == NULL){
26- ShowMessage("HtmlHelpA のアドレス取得に失敗しました。");
27- return;
28- }
2919 }
3020 //---------------------------------------------------------------------------
31-void
32-FreeHtmlHelp(void) {
33- if(HHCTRL != NULL){
34- FreeLibrary(HHCTRL);
35- }
21+Htmlhelp::~Htmlhelp(void){
22+ FreeLibrary(Handle);
3623 }
3724 //---------------------------------------------------------------------------
3825 void
39-ShowHtmlHelp(HWND handle,char *helpfile) {
40-
41- if(htmlHelp == NULL) {
26+Htmlhelp::ShowHtmlHelp(HWND handle,char *helpfile) {
27+ typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT, DWORD);
28+ if(Handle == NULL){
4229 return;
4330 }
44-
31+ FPHH htmlHelp = (FPHH)GetProcAddress(Handle,"HtmlHelpA");
32+ if(htmlHelp==NULL){
33+ ShowMessage("HtmlHelpAが見つかりません");
34+ return;
35+ }
4536 htmlHelp(handle,helpfile, HH_DISPLAY_TOPIC, NULL);
4637 }
4738 //---------------------------------------------------------------------------
48-void ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword) {
49-
50- if(htmlHelp == NULL) {
39+void
40+Htmlhelp::ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword) {
41+ typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT,DWORD);
42+ if(Handle == NULL){
5143 return;
5244 }
53-
45+ FPHH htmlHelp= (FPHH)GetProcAddress(Handle,"HtmlHelpA");
46+ if(htmlHelp==NULL){
47+ ShowMessage("HtmlHelpAが見つかりません");
48+ return;
49+ }
5450 HH_AKLINK link;
5551 link.cbStruct = sizeof(HH_AKLINK) ;
5652 link.fReserved = FALSE ;
--- HHelp.h (revision 15)
+++ HHelp.h (revision 16)
@@ -1,13 +1,21 @@
11 //---------------------------------------------------------------------------
2-// HTMLヘルプを表示する関数
2+// HTML Help Wrapper
33 //---------------------------------------------------------------------------
44 #ifndef HHelpH
55 #define HHelpH
66 //---------------------------------------------------------------------------
7-void InitHtmlHelp(void);
8-void FreeHtmlHelp(void);
9-
10-void ShowHtmlHelp(HWND handle,char *helpfile);
11-void ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword);
7+class Htmlhelp{
8+ private:
9+ HINSTANCE Handle;
10+ Htmlhelp(void);
11+ public:
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);
19+};
1220 //---------------------------------------------------------------------------
1321 #endif
--- main.cpp (revision 15)
+++ main.cpp (revision 16)
@@ -34,9 +34,6 @@
3434
3535 DefaultPath = ExtractFilePath(Application->ExeName);
3636 HelpFile = DefaultPath + helpfilename;
37-
38- InitHtmlHelp();
39-
4037 Mode = MODE_EDIT;
4138 FileName = "";
4239 Image->Canvas->Brush->Color = clWhite;
@@ -45,6 +42,7 @@
4542 dx[D_DOWN] = 0; dy[D_DOWN] = 1;
4643 dx[D_LEFT] = -1; dy[D_LEFT] = 0;
4744 dx[D_RIGHT] = 1; dy[D_RIGHT] = 0;
45+ htmlhelp = Htmlhelp::GetInstance();
4846
4947 }
5048 //---------------------------------------------------------------------------
@@ -54,7 +52,6 @@
5452 void __fastcall
5553 TFMain::FormClose(TObject *Sender, TCloseAction &Action) {
5654 delete Maze;
57- FreeHtmlHelp();
5855 }
5956 //---------------------------------------------------------------------------
6057 void
@@ -501,7 +498,11 @@
501498 //---------------------------------------------------------------------------
502499 void __fastcall
503500 TFMain::MMHelpClick(TObject *Sender) {
504- ShowHtmlHelp(this->Handle, HelpFile.c_str());
501+ if (!FileExists(HelpFile)){
502+ ShowMessage(HelpFile + "が見つかりません。");
503+ return;
504+ }
505+ htmlhelp->ShowHtmlHelp(this->Handle,HelpFile.c_str());
505506 }
506507 //---------------------------------------------------------------------------
507508
--- main.h (revision 15)
+++ main.h (revision 16)
@@ -13,6 +13,7 @@
1313 #include <ExtCtrls.hpp>
1414 //---------------------------------------------------------------------------
1515 #include "KMaze.h"
16+#include "HHelp.h"
1617 #include <Menus.hpp>
1718 #include <Dialogs.hpp>
1819 #include <ComCtrls.hpp>
@@ -85,6 +86,8 @@
8586 void ChangeSize(void);
8687 void ShowStatus(AnsiString msg);
8788
89+ Htmlhelp *htmlhelp; //HTMLヘルプのラッパ
90+
8891 //ファイル情報
8992 KMaze *Maze;
9093 AnsiString FileName;//編集中のファイル名
Show on old repository browser