[ttssh2-commit] [9981] OpenHelpW(), OpenHelpCV() を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 6月 1日 (水) 23:17:52 JST


Revision: 9981
          https://osdn.net/projects/ttssh2/scm/svn/commits/9981
Author:   zmatsuo
Date:     2022-06-01 23:17:51 +0900 (Wed, 01 Jun 2022)
Log Message:
-----------
OpenHelpW(), OpenHelpCV() を追加

- OpenHelpCV(), OpenHelpW() を ttcmn_lib.cpp に追加
- OpenHelp() を ttcmn.c から移動

Modified Paths:
--------------
    branches/adjust_icon/teraterm/common/ttcommon.h
    branches/adjust_icon/teraterm/teraterm/filesys_log.cpp
    branches/adjust_icon/teraterm/teraterm/setupdirdlg.cpp
    branches/adjust_icon/teraterm/teraterm/setupdirdlg.h
    branches/adjust_icon/teraterm/teraterm/tekwin.cpp
    branches/adjust_icon/teraterm/teraterm/vtwin.cpp
    branches/adjust_icon/teraterm/ttpcmn/ttcmn.c
    branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp
    branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h

-------------- next part --------------
Modified: branches/adjust_icon/teraterm/common/ttcommon.h
===================================================================
--- branches/adjust_icon/teraterm/common/ttcommon.h	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/common/ttcommon.h	2022-06-01 14:17:51 UTC (rev 9981)
@@ -61,7 +61,6 @@
 DllExport void PASCAL ShowAllWinCascade(HWND);
 DllExport void PASCAL BroadcastClosingMessage(HWND myhwnd);
 DllExport void PASCAL UndoAllWin(void);
-DllExport void PASCAL OpenHelp(UINT Command, DWORD Data, char *UILanguageFile);
 
 DllExport int PASCAL CommReadRawByte(PComVar cv, LPBYTE b);
 DllExport int PASCAL CommRead1Byte(PComVar cv, LPBYTE b);

Modified: branches/adjust_icon/teraterm/teraterm/filesys_log.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/filesys_log.cpp	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/teraterm/filesys_log.cpp	2022-06-01 14:17:51 UTC (rev 9981)
@@ -391,6 +391,7 @@
 	BOOL file_exist;
 	int current_bom;
 	TTTSet *pts;
+	TComVar *pcv;
 } LogDlgWork_t;
 
 static void ArrangeControls(HWND Dialog, LogDlgWork_t *work)
@@ -576,7 +577,7 @@
 			EndDialog(Dialog, IDCANCEL);
 			break;
 		case IDHELP:
-			OpenHelp(HH_HELP_CONTEXT, HlpFileLog, work->pts->UILanguageFile);
+			OpenHelpCV(work->pcv, HH_HELP_CONTEXT, HlpFileLog);
 			break;
 		case IDC_FOPT_FILENAME_BUTTON: {
 			/* save current dir */
@@ -1334,6 +1335,7 @@
 	work->info = info;
 	work->info->filename = srcfnameW;
 	work->pts = &ts;
+	work->pcv = &cv;
 	INT_PTR ret = TTDialogBoxParam(
 		hInst, MAKEINTRESOURCE(IDD_LOGDLG),
 		hWnd, LogFnHook, (LPARAM)work);

Modified: branches/adjust_icon/teraterm/teraterm/setupdirdlg.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/setupdirdlg.cpp	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/teraterm/setupdirdlg.cpp	2022-06-01 14:17:51 UTC (rev 9981)
@@ -333,7 +333,8 @@
 		{ IDC_CYGTERM_SETUPDIR_GROUP, "DLG_SETUPDIR_CYGTERMFILE" },
 		{ IDC_SSH_SETUPDIR_GROUP, "DLG_SETUPDIR_KNOWNHOSTSFILE" },
 	};
-	TTTSet *pts = (TTTSet *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	TComVar *pcv = (TComVar*)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	TTTSet *pts = pcv != NULL ? pcv->ts : NULL;
 	wchar_t *tmpbufW;
 	HWND hWnd;
 
@@ -340,8 +341,9 @@
 	switch (msg) {
 	case WM_INITDIALOG: {
 		BOOL ret;
-		pts = (TTTSet *)lp;
-		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)pts);
+		pcv = (TComVar *)lp;
+		pts = pcv->ts;
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)pcv);
 
 		// I18N
 		SetDlgTextsW(hDlgWnd, TextInfos, _countof(TextInfos), pts->UILanguageFileW);
@@ -517,7 +519,7 @@
 			break;
 
 		case IDHELP:
-			OpenHelp(HH_HELP_CONTEXT, HlpMenuSetupDir, pts->UILanguageFile);
+			OpenHelpCV(pcv, HH_HELP_CONTEXT, HlpMenuSetupDir);
 			break;
 
 		case IDOK:
@@ -567,8 +569,8 @@
 	return TRUE;
 }
 
-void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TTTSet *pts)
+void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TComVar *pcv)
 {
 	TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG),
-					 hWnd, OnSetupDirectoryDlgProc, (LPARAM)pts);
+					 hWnd, OnSetupDirectoryDlgProc, (LPARAM)pcv);
 }

Modified: branches/adjust_icon/teraterm/teraterm/setupdirdlg.h
===================================================================
--- branches/adjust_icon/teraterm/teraterm/setupdirdlg.h	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/teraterm/setupdirdlg.h	2022-06-01 14:17:51 UTC (rev 9981)
@@ -32,4 +32,4 @@
 #include <windows.h>
 #include "tttypes.h"
 
-void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TTTSet *pts);
+void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TComVar *pcv);

Modified: branches/adjust_icon/teraterm/teraterm/tekwin.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/tekwin.cpp	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/teraterm/tekwin.cpp	2022-06-01 14:17:51 UTC (rev 9981)
@@ -647,7 +647,7 @@
 LRESULT CTEKWindow::OnDlgHelp(WPARAM wParam, LPARAM lParam)
 {
 	DWORD help_id = (wParam == 0) ? HelpId : (DWORD)wParam;
-	OpenHelp(HH_HELP_CONTEXT, help_id, ts.UILanguageFile);
+	OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id);
 	return 0;
 }
 
@@ -771,7 +771,7 @@
 
 void CTEKWindow::OnHelpIndex()
 {
-	OpenHelp(HH_DISPLAY_TOPIC, 0, ts.UILanguageFile);
+	OpenHelpCV(&cv, HH_DISPLAY_TOPIC, 0);
 }
 
 void CTEKWindow::OnHelpAbout()

Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-06-01 14:17:51 UTC (rev 9981)
@@ -3429,7 +3429,7 @@
 LRESULT CVTWindow::OnDlgHelp(WPARAM wParam, LPARAM lParam)
 {
 	DWORD help_id = (wParam == 0) ? HelpId : (DWORD)wParam;
-	OpenHelp(HH_HELP_CONTEXT, help_id, ts.UILanguageFile);
+	OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id);
 	return 0;
 }
 
@@ -4705,7 +4705,7 @@
 //
 void CVTWindow::OnOpenSetupDirectory()
 {
-	SetupDirectoryDialog(m_hInst, HVTWin, &ts);
+	SetupDirectoryDialog(m_hInst, HVTWin, &cv);
 }
 
 void CVTWindow::OnSetupLoadKeyMap()
@@ -4884,7 +4884,7 @@
 
 void CVTWindow::OnHelpIndex()
 {
-	OpenHelp(HH_DISPLAY_TOPIC, 0, ts.UILanguageFile);
+	OpenHelpCV(&cv, HH_DISPLAY_TOPIC, 0);
 }
 
 void CVTWindow::OnHelpAbout()

Modified: branches/adjust_icon/teraterm/ttpcmn/ttcmn.c
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttcmn.c	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/ttpcmn/ttcmn.c	2022-06-01 14:17:51 UTC (rev 9981)
@@ -616,37 +616,6 @@
 	}
 }
 
-void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile)
-{
-	wchar_t Temp[MAX_PATH];
-	HWND HWin;
-	wchar_t *HelpFN;
-	wchar_t uimsg[MAX_UIMSG];
-	wchar_t *HomeDirW;
-
-	/* Get home directory  TODO ts.HomeDirW \x82֐؂\xE8\x91ւ\xA6 */
-	if (GetModuleFileNameW(NULL,Temp,_countof(Temp)) == 0) {
-		return;
-	}
-	HomeDirW = ExtractDirNameW(Temp);
-	get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile);
-	aswprintf(&HelpFN, L"%s\\%s", HomeDirW, uimsg);
-	free(HomeDirW);
-
-	// \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya)
-	HWin = GetDesktopWindow();
-	if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL) {
-		// \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD
-		static const TTMessageBoxInfoW info = {
-			"Tera Term",
-			NULL, L"Tera Term: HTML help",
-			"MSG_OPENHELP_ERROR", L"Can't open HTML help file(%s).",
-			MB_OK | MB_ICONERROR };
-		TTMessageBoxA(HWin, &info, UILanguageFile, HelpFN);
-	}
-	free(HelpFN);
-}
-
 HWND WINAPI GetNthWin(int n)
 {
 	if (n<pm->NWin) {

Modified: branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp	2022-06-01 14:17:51 UTC (rev 9981)
@@ -27,10 +27,14 @@
  */
 
 #include "tt_res.h"
-#include "ttcmn_lib.h"
 #include "dlglib.h"
-#include "ttcmn_notify.h"
+#include "asprintf.h"
+#include "compat_win.h"
+#include "win32helper.h"
+#include "codeconv.h"
 
+#include "ttcmn_lib.h"
+
 /**
  *	VT Window \x82̃A\x83C\x83R\x83\x93\x82Ƃ\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9
  *
@@ -59,3 +63,86 @@
 	                                                                    : IDI_VT;
 	TTSetIcon(icon_inst, cv->HWin, MAKEINTRESOURCEW(icon_id), 0);
 }
+
+static wchar_t *GetCHMFile(const wchar_t *exe_dir, const wchar_t *UILanguageFile)
+{
+	wchar_t *chm;
+	wchar_t *chm_fname;
+
+	GetI18nStrWW("Tera Term", "HELPFILE", L"teraterm.chm", UILanguageFile, &chm_fname);
+	if(!IsRelativePathW(chm_fname)) {
+		return chm_fname;
+	}
+	aswprintf(&chm, L"%s\\%s", exe_dir, chm_fname);
+	free(chm_fname);
+	return chm;
+}
+
+/**
+ *	\x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD
+ *
+ *	@param[in]	Command			HtmlHelp() API \x82̑\xE63\x88\xF8\x90\x94
+ *	@param[in]	Data			HtmlHelp() API \x82̑\xE64\x88\xF8\x90\x94
+ *	@param[in]	ExeDirW
+ *	@param[in]	UILanguageFileW
+ *
+ */
+void WINAPI OpenHelpW(UINT Command, DWORD Data, const wchar_t *ExeDirW, wchar_t *UILanguageFileW)
+{
+	HWND HWin;
+	wchar_t *chm;
+
+	chm = GetCHMFile(ExeDirW, UILanguageFileW);
+
+	HWin = GetDesktopWindow();
+	if (_HtmlHelpW(HWin, chm, Command, Data) == NULL) {
+		// \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD
+		static const TTMessageBoxInfoW info = {
+			"Tera Term",
+			NULL, L"Tera Term: HTML help",
+			"MSG_OPENHELP_ERROR", L"Can't open HTML help file(%s).",
+			MB_OK | MB_ICONERROR };
+		TTMessageBoxW(HWin, &info, UILanguageFileW, chm);
+	}
+	free(chm);
+}
+
+/**
+ *	\x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD
+ *
+ *	@param[in]	Command		HtmlHelp() API \x82̑\xE63\x88\xF8\x90\x94
+ *	@param[in]	Data		HtmlHelp() API \x82̑\xE64\x88\xF8\x90\x94
+ *
+ *	\x8E\x9F\x82̃R\x81[\x83h\x82\xCD
+ *		HWND HVTWin = GetParent(hDlgWnd);
+ *		PostMessage(HVTWin, WM_USER_DLGHELP2, help_id, 0);
+ *	\x8E\x9F\x82̊֐\x94\x8CĂяo\x82\xB5\x82Ɠ\xAF\x93\x99
+ *		OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id);
+ *
+ */
+void WINAPI OpenHelpCV(TComVar *cv, UINT Command, DWORD Data)
+{
+	TTTSet *ts = cv->ts;
+	return OpenHelpW(Command, Data, ts->ExeDirW, ts->UILanguageFileW);
+}
+
+/**
+ *	\x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD
+ *
+ *	\x8C݊\xB7\x88ێ\x9D\x82̂\xBD\x82ߑ\xB6\x8D\xDD
+ *	OpenHelpCV() \x82֐؂\xE8\x91ւ\xA6\x82\xF0\x82\xA8\x82\xB7\x82\xB7\x82\xDF
+ */
+void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFileA)
+{
+	wchar_t *Temp;
+	wchar_t *HomeDirW;
+	wchar_t *UILanguageFileW;
+
+	hGetModuleFileNameW(NULL, &Temp);
+	HomeDirW = ExtractDirNameW(Temp);
+	UILanguageFileW = ToWcharA(UILanguageFileA);
+	OpenHelpW(Command, Data, HomeDirW, UILanguageFileW);
+	free(UILanguageFileW);
+	free(HomeDirW);
+	free(Temp);
+}

Modified: branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h
===================================================================
--- branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h	2022-05-31 15:49:31 UTC (rev 9980)
+++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h	2022-06-01 14:17:51 UTC (rev 9981)
@@ -37,6 +37,9 @@
 #endif
 
 DllExport void SetVTIconID(TComVar *cv, HINSTANCE hInstance, WORD IconID);
+DllExport void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile);
+DllExport void WINAPI OpenHelpW(UINT Command, DWORD Data, const wchar_t *ExeDirW, wchar_t *UILanguageFileW);
+DllExport void WINAPI OpenHelpCV(TComVar *cv, UINT Command, DWORD Data);
 
 #ifdef __cplusplus
 }


ttssh2-commit メーリングリストの案内
Back to archive index