[Ttssh2-commit] [7238] ログダイアログが表示できていなかったので対応

scmno****@osdn***** scmno****@osdn*****
2018年 9月 13日 (木) 23:47:43 JST


Revision: 7238
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7238
Author:   zmatsuo
Date:     2018-09-13 23:47:43 +0900 (Thu, 13 Sep 2018)
Log Message:
-----------
ログダイアログが表示できていなかったので対応

Modified Paths:
--------------
    branches/cmake/.gitignore
    branches/cmake/teraterm/teraterm/filesys.cpp
    branches/cmake/teraterm/teraterm/ftdlg.cpp
    branches/cmake/teraterm/teraterm/tmfc.cpp
    branches/cmake/teraterm/teraterm/tmfc.h
    branches/cmake/teraterm/teraterm/tmfc_frame.cpp
    branches/cmake/teraterm/teraterm/ttdialog.c
    branches/cmake/teraterm/ttpfile/CMakeLists.txt
    branches/cmake/teraterm/ttpfile/ttfile.c

-------------- next part --------------
Modified: branches/cmake/.gitignore
===================================================================
--- branches/cmake/.gitignore	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/.gitignore	2018-09-13 14:47:43 UTC (rev 7238)
@@ -10,6 +10,7 @@
 *.exp
 *.log
 *.tlog
+*.aps
 .vs/
 **/Debug/*
 **/Release/*

Modified: branches/cmake/teraterm/teraterm/filesys.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/filesys.cpp	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/filesys.cpp	2018-09-13 14:47:43 UTC (rev 7238)
@@ -188,11 +188,9 @@
 static PFileTransDlg SendDlg = NULL;
 static PProtoDlg PtDlg = NULL;
 
-BOOL OpenFTDlg(PFileVar fv)
+static BOOL OpenFTDlg(PFileVar fv)
 {
 	PFileTransDlg FTDlg;
-	HWND HFTDlg;
-	char uimsg[MAX_UIMSG];
 
 	FTDlg = new CFileTransDlg();
 
@@ -217,32 +215,9 @@
 	else
 		SendDlg = FTDlg; /* File send */
 
-	HFTDlg=FTDlg->GetSafeHwnd();
-
-	GetDlgItemText(HFTDlg, IDC_TRANS_FILENAME, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_FILENAME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_TRANS_FILENAME, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDC_FULLPATH_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_FULLPATH", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_FULLPATH_LABEL, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDC_TRANS_TRANS, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_TRNAS", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_TRANS_TRANS, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDC_TRANS_ELAPSED, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_ELAPSED", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_TRANS_ELAPSED, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDCANCEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_CLOSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDCANCEL, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDC_TRANSPAUSESTART, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FILETRANS_PAUSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_TRANSPAUSESTART, ts.UIMsg);
-	GetDlgItemText(HFTDlg, IDC_TRANSHELP, uimsg, sizeof(uimsg));
-	get_lang_msg("BTN_HELP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HFTDlg, IDC_TRANSHELP, ts.UIMsg);
-
 	fv->StartTime = GetTickCount();
 	if (fv->OpId == OpSendFile) {
+		HWND HFTDlg = FTDlg->GetSafeHwnd();
 		InitDlgProgress(HFTDlg, IDC_TRANSPROGRESS, &fv->ProgStat);
 		ShowWindow(GetDlgItem(HFTDlg, IDC_TRANS_ELAPSED), SW_SHOW);
 	}

Modified: branches/cmake/teraterm/teraterm/ftdlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-09-13 14:47:43 UTC (rev 7238)
@@ -45,6 +45,7 @@
 BOOL CFileTransDlg::Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PComVar pcv, PTTSet pts)
 {
 	BOOL Ok;
+	WNDCLASS wc;
 	int fuLoad = LR_DEFAULTCOLOR;
 	HWND hwnd;
 
@@ -52,6 +53,19 @@
 	cv = pcv;
 	cv->FilePause &= ~fv->OpId;
 	ts = pts;
+
+	wc.style = CS_PARENTDC;
+	wc.lpfnWndProc = TTCDialog::ProcStub;
+	wc.cbClsExtra = 0;
+	wc.cbWndExtra = DLGWINDOWEXTRA;
+	wc.hInstance = hInstance;
+	wc.hIcon = NULL;
+	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
+	wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
+	wc.lpszMenuName = NULL;
+	wc.lpszClassName = "FTDlg32";
+	RegisterClass(&wc);
+
 	Pause = FALSE;
 
 	hwnd = GetForegroundWindow();
@@ -146,6 +160,16 @@
 
 void CFileTransDlg::OnInitDialog()
 {
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_TRANS_FILENAME, "DLG_FILETRANS_FILENAME" },
+		{ IDC_FULLPATH_LABEL, "DLG_FILETRANS_FULLPATH" },
+		{ IDC_TRANS_TRANS, "DLG_FILETRANS_TRNAS" },
+		{ IDC_TRANS_ELAPSED, "DLG_FILETRANS_ELAPSED" },
+		{ IDCANCEL, "DLG_FILETRANS_CLOSE" },
+		{ IDC_TRANSPAUSESTART, "DLG_FILETRANS_PAUSE" },
+		{ IDC_TRANSHELP, "BTN_HELP" },
+	};
+
 	int fuLoad = LR_DEFAULTCOLOR;
 
 	if (fv->HideDialog) {
@@ -163,20 +187,22 @@
 	// \x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82̓t\x83\x8B\x83p\x83X\x95\\x8E\xA6\x82ɂ\xB7\x82\xE9(2004.8.6 yutaka)
 	SetDlgItemText(IDC_EDIT_FULLPATH, &(fv->FullName[0]));
 
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts->UILanguageFile);
+
 	if (IsWindowsNT4()) {
 		fuLoad = LR_VGACOLOR;
 	}
 	SmallIcon = LoadImage(m_hInst,
-		MAKEINTRESOURCE(IDI_TTERM),
-		IMAGE_ICON, 16, 16, fuLoad);
+						  MAKEINTRESOURCE(IDI_TTERM),
+						  IMAGE_ICON, 16, 16, fuLoad);
 	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_SMALL,
-		(LPARAM)SmallIcon);
+				  (LPARAM)SmallIcon);
 
 	BigIcon = LoadImage(m_hInst,
-			MAKEINTRESOURCE(IDI_TTERM),
-			IMAGE_ICON, 0, 0, fuLoad);
+						MAKEINTRESOURCE(IDI_TTERM),
+						IMAGE_ICON, 0, 0, fuLoad);
 	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
-		(LPARAM)BigIcon);
+				  (LPARAM)BigIcon);
 }
 
 void CFileTransDlg::OnCancel( )

Modified: branches/cmake/teraterm/teraterm/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.cpp	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/tmfc.cpp	2018-09-13 14:47:43 UTC (rev 7238)
@@ -32,6 +32,7 @@
 #include "tmfc.h"
 
 #include <windowsx.h>
+#include <assert.h>
 #include "dlglib.h"
 
 TTCWnd::TTCWnd()
@@ -103,7 +104,7 @@
 	::ShowWindow(m_hWnd, nCmdShow);
 }
 
-void TTCWnd::SetWindowText(TCHAR *str)
+void TTCWnd::SetWindowText(const TCHAR *str)
 {
 	::SetWindowText(m_hWnd, str);
 }
@@ -162,11 +163,17 @@
 #else
 	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, MAKEINTRESOURCE(idd));
 #endif
+	pseudoPtr = this;
 	HWND hWnd = ::CreateDialogIndirectParam(	
 		hInstance, lpTemplate, hParent,
 		(DLGPROC)OnDlgProc, (LPARAM)this);
+	pseudoPtr = NULL;
 	if (hWnd == NULL)
 	{
+#if defined(_DEBUG)
+		DWORD e = GetLastError();
+#endif
+		assert(false);
 		return FALSE;
 	}
 
@@ -241,6 +248,25 @@
 	return TRUE;
 }
 
+TTCDialog *TTCDialog::pseudoPtr;
+
+LRESULT CALLBACK TTCDialog::ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCDialog *self;
+	if (pseudoPtr != NULL) {
+		self = pseudoPtr;
+		self->m_hWnd = hWnd;
+	} else {
+		self = (TTCDialog *)GetWindowLongPtr(hWnd, DWLP_USER);
+	}
+
+	LRESULT result = self->OnDlgProc(hWnd, msg, wp, lp);
+	if (result == FALSE) {
+		result = ::DefWindowProc(hWnd, msg, wp, lp);
+	}
+	return result;
+}
+
 ////////////////////////////////////////
 
 // quick hack :-(

Modified: branches/cmake/teraterm/teraterm/tmfc.h
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.h	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/tmfc.h	2018-09-13 14:47:43 UTC (rev 7238)
@@ -32,18 +32,6 @@
 #pragma once
 #include <windows.h>
 
-class TTCMenu
-{
-public:
-	HMENU m_hMenu;
-};
-
-class TTCPoint {
-public:
-	int x;
-	int y;
-};
-
 class TTCWnd
 {
 public:
@@ -70,7 +58,7 @@
 	void SetDlgItemInt(int id, UINT val, BOOL bSigned = TRUE);
 	UINT GetDlgItemInt(int id, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const;
 	void ShowWindow(int nCmdShow);
-	void SetWindowText(TCHAR *str);
+	void SetWindowText(const TCHAR *str);
 	void ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
 	void ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
 	int MessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
@@ -82,7 +70,7 @@
 	TTCFrameWnd();
 	virtual ~TTCFrameWnd();
 	static TTCFrameWnd *pseudoPtr;
-	static LRESULT ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
+	static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
 	virtual BOOL Create(HINSTANCE hInstance,
 						LPCTSTR lpszClassName,
 						LPCTSTR lpszWindowName,
@@ -98,7 +86,6 @@
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 	///
 #if 1
-	void OnInitMenuPopup(TTCMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
 	void OnKillFocus(HWND hNewWnd);
 	void OnDestroy();
 	void OnSetFocus(HWND hOldWnd);
@@ -114,6 +101,8 @@
 public:
 	TTCDialog();
 	virtual ~TTCDialog();
+	static TTCDialog *pseudoPtr;
+	static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
 	BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
 	void DestroyWindow();
 	virtual void OnInitDialog();

Modified: branches/cmake/teraterm/teraterm/tmfc_frame.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc_frame.cpp	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/tmfc_frame.cpp	2018-09-13 14:47:43 UTC (rev 7238)
@@ -74,9 +74,6 @@
 	return FALSE;
 }
 
-void TTCFrameWnd::OnInitMenuPopup(TTCMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
-{}
-
 void TTCFrameWnd::OnKillFocus(HWND hNewWnd)
 {}
 

Modified: branches/cmake/teraterm/teraterm/ttdialog.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttdialog.c	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/teraterm/ttdialog.c	2018-09-13 14:47:43 UTC (rev 7238)
@@ -50,7 +50,11 @@
 
 BOOL LoadTTDLG()
 {
-	TTXGetUIHooks(); /* TTPLUG */
+	static BOOL initialized;
+	if (!initialized) {
+		TTXGetUIHooks(); /* TTPLUG */
+		initialized = TRUE;
+	}
 	return TRUE;
 }
 

Modified: branches/cmake/teraterm/ttpfile/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-09-13 14:47:43 UTC (rev 7238)
@@ -16,6 +16,8 @@
 set(COMMON_SRC
   ../common/dlglib.c
   ../common/dlglib.h
+  ../common/dlglib_cpp.cpp
+  ../common/dlglib_tmpl.cpp
   ../common/ttlib.c
   ../common/ttlib.h
   )

Modified: branches/cmake/teraterm/ttpfile/ttfile.c
===================================================================
--- branches/cmake/teraterm/ttpfile/ttfile.c	2018-09-13 14:47:31 UTC (rev 7237)
+++ branches/cmake/teraterm/ttpfile/ttfile.c	2018-09-13 14:47:43 UTC (rev 7238)
@@ -46,6 +46,7 @@
 #include "quickvan.h"
 // resource IDs
 #include "file_res.h"
+#include "dlglib.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -53,6 +54,16 @@
 
 #include "compat_w95.h"
 
+#undef DialogBoxParam
+#define DialogBoxParam(p1,p2,p3,p4,p5) \
+	TTDialogBoxParam(p1,p2,p3,p4,p5)
+#undef DialogBox
+#define DialogBox(p1,p2,p3,p4) \
+	TTDialogBox(p1,p2,p3,p4)
+#undef EndDialog
+#define EndDialog(p1,p2) \
+	TTEndDialog(p1, p2)
+
 #undef DllExport
 #define DllExport __declspec(dllexport) 
 
@@ -170,13 +181,13 @@
 	return Ok;
 }
 
-void SetLogFlags(HWND Dialog)
+static void SetLogFlags(HWND Dialog)
 {
 	LPLONG pl;
 	WORD BinFlag, val;
 	long opt = 0;
 
-	pl = (LPLONG)GetWindowLong(Dialog, DWL_USER);
+	pl = (LPLONG)GetWindowLongPtr(Dialog, DWLP_USER);
 	if (pl) {
 		GetRB(Dialog, &BinFlag, IDC_FOPTBIN, IDC_FOPTBIN);
 		if (BinFlag) {
@@ -233,7 +244,7 @@
 }
 
 /* Hook function for file name dialog box */
-BOOL CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	LPOPENFILENAME ofn;
 	WORD BinFlag, TsFlag;
@@ -250,7 +261,7 @@
 		ofn = (LPOPENFILENAME)lParam;
 		pl = (LPLONG)(ofn->lCustData);
 		opt = *pl;
-		SetWindowLong(Dialog, DWL_USER, (LONG)pl);
+		SetWindowLongPtr(Dialog, DWLP_USER, (LONG)pl);
 
 		font = (HFONT)SendMessage(Dialog, WM_GETFONT, 0, 0);
 		GetObject(font, sizeof(LOGFONT), &logfont);
@@ -422,7 +433,7 @@
 	return FALSE;
 }
 
-BOOL CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam);
+static BOOL CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam);
 
 DllExport BOOL WINAPI GetTransFname(PFileVar fv, PCHAR CurDir, WORD FuncId, LPLONG Option)
 {
@@ -569,7 +580,7 @@
 	return Ok;
 }
 
-BOOL CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	LPOPENFILENAME ofn;
 	LPWORD pw;
@@ -790,8 +801,7 @@
 	return Ok;
 }
 
-BOOL CALLBACK GetFnDlg
-  (HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK GetFnDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PFileVar fv;
 	char TempFull[MAX_PATH];
@@ -952,7 +962,7 @@
 }
 
 /* Hook function for XMODEM file name dialog box */
-BOOL CALLBACK XFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
+static BOOL CALLBACK XFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	LPOPENFILENAME ofn;
 	WORD Hi, Lo;



Ttssh2-commit メーリングリストの案内