[Ttssh2-commit] [7175] marge trunk 7174

scmno****@osdn***** scmno****@osdn*****
2018年 8月 5日 (日) 22:33:28 JST


Revision: 7175
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7175
Author:   zmatsuo
Date:     2018-08-05 22:33:28 +0900 (Sun, 05 Aug 2018)
Log Message:
-----------
marge trunk 7174

Modified Paths:
--------------
    branches/cmake/teraterm/common/dlglib.c
    branches/cmake/teraterm/common/dlglib.h
    branches/cmake/teraterm/teraterm/dnddlg.cpp
    branches/cmake/teraterm/teraterm/prnabort.cpp
    branches/cmake/teraterm/teraterm/prnabort.h
    branches/cmake/teraterm/teraterm/teraprn.cpp

Property Changed:
----------------
    branches/cmake/
    branches/cmake/teraterm/

-------------- next part --------------
Index: branches/cmake
===================================================================
--- branches/cmake	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake	2018-08-05 13:33:28 UTC (rev 7175)

Property changes on: branches/cmake
___________________________________________________________________
Modified: svn:mergeinfo
## -2,4 +2,4 ##
 /branches/ssh_ed25519:5495-5544
 /branches/vs2015_warn:6194-6285
 /tags/teraterm-4_89:6182
-/trunk:7164,7172
\ No newline at end of property
+/trunk:7164,7172,7174
\ No newline at end of property
Index: branches/cmake/teraterm
===================================================================
--- branches/cmake/teraterm	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm	2018-08-05 13:33:28 UTC (rev 7175)

Property changes on: branches/cmake/teraterm
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
 /branches/drag_and_drop/teraterm:7130,7139,7141,7143-7147
 /branches/vs2015_warn/teraterm:6194-6285
-/trunk/teraterm:7164,7172
\ No newline at end of property
+/trunk/teraterm:7164,7172,7174
\ No newline at end of property
Modified: branches/cmake/teraterm/common/dlglib.c
===================================================================
--- branches/cmake/teraterm/common/dlglib.c	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/common/dlglib.c	2018-08-05 13:33:28 UTC (rev 7175)
@@ -373,3 +373,21 @@
 		}
 	}
 }
+
+HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
+				  const char *UILanguageFile, PCHAR key)
+{
+	if (key == NULL) key = "DLG_TAHOMA_FONT";
+	HFONT hPrevFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
+	LOGFONT logfont;
+	GetObject(hPrevFont, sizeof(LOGFONT), &logfont);
+	HFONT hNewFont;
+	if (get_lang_font(key, hDlg, &logfont, &hNewFont, UILanguageFile)) {
+		for (int i = 0 ; i < nIDDlgItemCount ; i++) {
+			const int nIDDlgItem = nIDDlgItems[i];
+			SendDlgItemMessage(hDlg, nIDDlgItem, WM_SETFONT, (WPARAM)hNewFont, MAKELPARAM(TRUE,0));
+		}
+	}
+	return hNewFont;
+}
+

Modified: branches/cmake/teraterm/common/dlglib.h
===================================================================
--- branches/cmake/teraterm/common/dlglib.h	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/common/dlglib.h	2018-08-05 13:33:28 UTC (rev 7175)
@@ -49,6 +49,8 @@
 	char *key;
 } DlgTextInfo;
 void SetDlgTexts(HWND hDlgWnd, const DlgTextInfo *infos, int infoCount, const char *UILanguageFile);
+HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
+				  const char *UILanguageFile, PCHAR key);
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/teraterm/dnddlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/dnddlg.cpp	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/teraterm/dnddlg.cpp	2018-08-05 13:33:28 UTC (rev 7175)
@@ -56,26 +56,10 @@
 };
 
 struct DrapDropDlgData {
-	HFONT hPrevFont;
+	HFONT hNewFont;
 	DrapDropDlgParam *Param;
 };
 
-static HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount, const char *UILanguageFile, PCHAR key)
-{
-	if (key == NULL) key = "DLG_TAHOMA_FONT";
-	HFONT hPrevFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
-	LOGFONT logfont;
-	GetObject(hPrevFont, sizeof(LOGFONT), &logfont);
-	HFONT hNewFont;
-	if (get_lang_font("DLG_TAHOMA_FONT", hDlg, &logfont, &hNewFont, UILanguageFile)) {
-		for (int i = 0 ; i < nIDDlgItemCount ; i++) {
-			const int nIDDlgItem = nIDDlgItems[i];
-			SendDlgItemMessage(hDlg, nIDDlgItem, WM_SETFONT, (WPARAM)hNewFont, MAKELPARAM(TRUE,0));
-		}
-	}
-	return hNewFont;
-}
-
 static LRESULT CALLBACK OnDragDropDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
 {
 	static const int FontIDs[] = {
@@ -117,7 +101,7 @@
 		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)DlgData);
 		DrapDropDlgParam *Param = (DrapDropDlgParam *)lp;
 		DlgData->Param = Param;
-		DlgData->hPrevFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
+		DlgData->hNewFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
 		SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), Param->UILanguageFile);
 
 		// target file
@@ -258,15 +242,18 @@
 			DlgData->Param->DropType = DROP_TYPE_CANCEL;
 		}
 		if (wID == IDOK || wID == IDCANCEL) {
-			if (DlgData->hPrevFont != NULL) {
-				DeleteObject(DlgData->hPrevFont);
-			}
 			EndDialog(hDlgWnd, wID);
-			free(DlgData);
 			break;
 		}
 		return FALSE;
 	}
+	case WM_NCDESTROY:
+		if (DlgData->hNewFont != NULL) {
+			DeleteObject(DlgData->hNewFont);
+			DlgData->hNewFont = NULL;
+		}
+		free(DlgData);
+		break;
 
 	default:
 		return FALSE;

Modified: branches/cmake/teraterm/teraterm/prnabort.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.cpp	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/teraterm/prnabort.cpp	2018-08-05 13:33:28 UTC (rev 7175)
@@ -1,6 +1,6 @@
-/*
+/*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,82 +28,102 @@
  */
 
 /* TERATERM.EXE, print-abort dialog box */
-#include "stdafx.h"
+#include <windows.h>
+#include <windowsx.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttlib.h"
+#include "dlglib.h"
 #include "tt_res.h"
 #include "prnabort.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+LRESULT CALLBACK CPrnAbortDlg::OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_PRNABORT_PRINTING, "DLG_PRNABORT_PRINTING" }, 
+		{ IDCANCEL, "BTN_CANCEL" },
+	};
+	static const int FontIDs[] = {
+		IDC_PRNABORT_PRINTING, IDCANCEL
+	};
 
-// CPrnAbortDlg dialog
-BEGIN_MESSAGE_MAP(CPrnAbortDlg, CDialog)
-	//{{AFX_MSG_MAP(CPrnAbortDlg)
-	//}}AFX_MSG_MAP
-END_MESSAGE_MAP()
+	CPrnAbortDlg *self = (CPrnAbortDlg *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
 
-// CPrnAbortDlg message handler
-BOOL CPrnAbortDlg::Create(CWnd* p_Parent, PBOOL AbortFlag, PTTSet pts)
-{
-	BOOL Ok;
-	HWND HParent;
-	LOGFONT logfont;
-	HFONT font;
+	switch (msg) {
+	case WM_INITDIALOG:
+	{
+		CPrnAbortDlg *self = (CPrnAbortDlg *)lp;
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
+		SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), self->m_ts->UILanguageFile);
+		self->m_hNewFont =
+			SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs),
+						self->m_ts->UILanguageFile, "DLG_SYSTEM_FONT");
+		return TRUE;
+	}
 
-	m_pParent = p_Parent;
-	if (p_Parent!=NULL) {
-		HParent = p_Parent->GetSafeHwnd();
+	case WM_COMMAND:
+	{
+		WORD wID = GET_WM_COMMAND_ID(wp, lp);
+		const WORD wCMD = GET_WM_COMMAND_CMD(wp, lp);
+		if (wID == IDOK) {
+			self->DestroyWindow();
+		}
+		if (wID == IDCANCEL) {
+			self->OnCancel();
+		}
+		return FALSE;
 	}
-	else {
-		HParent = NULL;
+	case WM_NCDESTROY:
+		self->PostNcDestroy();
+		return TRUE;
+
+	default:
+		return FALSE;
 	}
-	Abort = AbortFlag;
-	Ok = (CDialog::Create(CPrnAbortDlg::IDD, m_pParent));
-	if (Ok) {
-		::EnableWindow(HParent,FALSE);
-		::EnableWindow(GetSafeHwnd(),TRUE);
-	}
+	return TRUE;
+}
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", GetSafeHwnd(), &logfont, &DlgFont, pts->UILanguageFile)) {
-		SendDlgItemMessage(IDC_PRNABORT_PRINTING, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
+BOOL CPrnAbortDlg::Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts)
+{
+	m_pAbort = AbortFlag;
+	m_hParentWnd = hParent;
+	m_ts = pts;
+
+	HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(IDD_PRNABORTDLG), RT_DIALOG);
+	HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
+	DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
+	HWND hWnd = ::CreateDialogIndirectParam(	
+		hInstance, lpTemplate, hParent,
+		(DLGPROC)OnDlgProc, (LPARAM)this);
+	if (hWnd == NULL)
+	{
+		return FALSE;
 	}
 
-	return Ok;
+	m_hWnd = hWnd;
+	::EnableWindow(hParent,FALSE);
+	::ShowWindow(hWnd, SW_SHOW);
+	::EnableWindow(m_hWnd,TRUE);
+	return TRUE;
 }
 
 void CPrnAbortDlg::OnCancel()
 {
-	*Abort = TRUE;
+	*m_pAbort = TRUE;
 	DestroyWindow();
 }
 
-BOOL CPrnAbortDlg::OnCommand(WPARAM wParam, LPARAM lParam)
-{
-	*Abort = TRUE;
-	DestroyWindow();
-
-	return CDialog::OnCommand(wParam, lParam);
-}
-
 void CPrnAbortDlg::PostNcDestroy()
 {
+	::DeleteObject(m_hNewFont);
 	delete this;
 }
 
 BOOL CPrnAbortDlg::DestroyWindow()
 {
-	HWND HParent;
+	::EnableWindow(m_hParentWnd,TRUE);
+	::SetFocus(m_hParentWnd);
+	::DestroyWindow(m_hWnd);
+	return TRUE;
+}
 
-	HParent = m_pParent->GetSafeHwnd();
-	::EnableWindow(HParent,TRUE);
-	::SetFocus(HParent);
-	return CDialog::DestroyWindow();
-}

Modified: branches/cmake/teraterm/teraterm/prnabort.h
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.h	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/teraterm/prnabort.h	2018-08-05 13:33:28 UTC (rev 7175)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,40 +28,25 @@
  */
 
 /* TERATERM.EXE, print-abort dialog box */
+#pragma once
 
+#include "tttypes.h"	// for TTSet
+
 // CPrnAbortDlg dialog
-class CPrnAbortDlg : public CDialog
+class CPrnAbortDlg
 {
-#ifndef NO_I18N
-private:
-	HFONT DlgFont;
-#endif
-
 public:
-#ifndef NO_I18N
-	BOOL Create(CWnd* p_Parent, PBOOL AbortFlag, PTTSet pts);
-#else
-	BOOL Create(CWnd* p_Parent, PBOOL AbortFlag);
-#endif
+	HWND m_hWnd;
+	HWND GetSafeHwnd() const {return m_hWnd;}
+	BOOL Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts);
+	BOOL DestroyWindow();
+	HFONT m_hNewFont;
 
-	//{{AFX_DATA(CPrnAbortDlg)
-	enum { IDD = IDD_PRNABORTDLG };
-	//}}AFX_DATA
-
-	//{{AFX_VIRTUAL(CPrnAbortDlg)
-	public:
-	virtual BOOL DestroyWindow();
-	protected:
-	virtual void OnCancel( );
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	virtual void PostNcDestroy();
-	//}}AFX_VIRTUAL
-
-	protected:
-	CWnd* m_pParent;
-	BOOL *Abort;
-
-	//{{AFX_MSG(CPrnAbortDlg)
-	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
+private:
+	void OnCancel();
+	void PostNcDestroy();
+	HWND m_hParentWnd;
+	BOOL *m_pAbort;
+	TTTSet *m_ts;
+	static LRESULT CALLBACK OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
 };

Modified: branches/cmake/teraterm/teraterm/teraprn.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/teraprn.cpp	2018-08-05 13:28:57 UTC (rev 7174)
+++ branches/cmake/teraterm/teraterm/teraprn.cpp	2018-08-05 13:33:28 UTC (rev 7175)
@@ -129,7 +129,6 @@
 	DOCINFO Doc;
 	char DocName[50];
 	CWnd* pParent;
-	char uimsg[MAX_UIMSG];
 
 	Printing = FALSE;
 	PrintAbortFlag = FALSE;
@@ -144,16 +143,9 @@
 	else {
 		pParent = (CWnd*)pTEKWin;
 	}
-	PrnAbortDlg->Create(pParent,&PrintAbortFlag,&ts);
+	PrnAbortDlg->Create(hInst, pParent->GetSafeHwnd(),&PrintAbortFlag,&ts);
 	HPrnAbortDlg = PrnAbortDlg->GetSafeHwnd();
 
-	GetDlgItemText(HPrnAbortDlg, IDC_PRNABORT_PRINTING, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PRNABORT_PRINTING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HPrnAbortDlg, IDC_PRNABORT_PRINTING, ts.UIMsg);
-	GetDlgItemText(HPrnAbortDlg, IDCANCEL, uimsg, sizeof(uimsg));
-	get_lang_msg("BTN_CANCEL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(HPrnAbortDlg, IDCANCEL, ts.UIMsg);
-
 	SetAbortProc(PrintDC,PrnAbortProc);
 
 	Doc.cbSize = sizeof(DOCINFO);
@@ -595,7 +587,7 @@
 	else {
 		pParent = (CWnd*)pTEKWin;
 	}
-	PrnAbortDlg->Create(pParent,&PrintAbortFlag,&ts);
+	PrnAbortDlg->Create(hInst, pParent->GetSafeHwnd(),&PrintAbortFlag,&ts);
 	HPrnAbortDlg = PrnAbortDlg->GetSafeHwnd();
 
 	HPrnFile = _lopen(PrnFName,OF_READ);



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