• R/O
  • SSH
  • HTTPS

ttssh2: コミット


コミットメタ情報

リビジョン7174 (tree)
日時2018-08-05 22:28:57
作者zmatsuo

ログメッセージ

teraterm/teraterm/dnddlg.cpp フォントの削除をNCDESTROYで行うようにした
teraterm/teraterm/prnabort.cpp,h MFCを使わないようにした
teraterm/common/dlglib.c,h dnddlgからSetDlgFonts()を移動

変更サマリ

差分

--- trunk/teraterm/teraterm/prnabort.cpp (revision 7173)
+++ trunk/teraterm/teraterm/prnabort.cpp (revision 7174)
@@ -1,6 +1,6 @@
1-/*
1+/*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2007-2017 TeraTerm Project
3+ * (C) 2007-2018 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -28,82 +28,102 @@
2828 */
2929
3030 /* TERATERM.EXE, print-abort dialog box */
31-#include "stdafx.h"
31+#include <windows.h>
32+#include <windowsx.h>
3233 #include "teraterm.h"
3334 #include "tttypes.h"
3435 #include "ttlib.h"
36+#include "dlglib.h"
3537 #include "tt_res.h"
3638 #include "prnabort.h"
3739
38-#ifdef _DEBUG
39-#define new DEBUG_NEW
40-#undef THIS_FILE
41-static char THIS_FILE[] = __FILE__;
42-#endif
40+LRESULT CALLBACK CPrnAbortDlg::OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
41+{
42+ static const DlgTextInfo TextInfos[] = {
43+ { IDC_PRNABORT_PRINTING, "DLG_PRNABORT_PRINTING" },
44+ { IDCANCEL, "BTN_CANCEL" },
45+ };
46+ static const int FontIDs[] = {
47+ IDC_PRNABORT_PRINTING, IDCANCEL
48+ };
4349
44-// CPrnAbortDlg dialog
45-BEGIN_MESSAGE_MAP(CPrnAbortDlg, CDialog)
46- //{{AFX_MSG_MAP(CPrnAbortDlg)
47- //}}AFX_MSG_MAP
48-END_MESSAGE_MAP()
50+ CPrnAbortDlg *self = (CPrnAbortDlg *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
4951
50-// CPrnAbortDlg message handler
51-BOOL CPrnAbortDlg::Create(CWnd* p_Parent, PBOOL AbortFlag, PTTSet pts)
52-{
53- BOOL Ok;
54- HWND HParent;
55- LOGFONT logfont;
56- HFONT font;
52+ switch (msg) {
53+ case WM_INITDIALOG:
54+ {
55+ CPrnAbortDlg *self = (CPrnAbortDlg *)lp;
56+ SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
57+ SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), self->m_ts->UILanguageFile);
58+ self->m_hNewFont =
59+ SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs),
60+ self->m_ts->UILanguageFile, "DLG_SYSTEM_FONT");
61+ return TRUE;
62+ }
5763
58- m_pParent = p_Parent;
59- if (p_Parent!=NULL) {
60- HParent = p_Parent->GetSafeHwnd();
64+ case WM_COMMAND:
65+ {
66+ WORD wID = GET_WM_COMMAND_ID(wp, lp);
67+ const WORD wCMD = GET_WM_COMMAND_CMD(wp, lp);
68+ if (wID == IDOK) {
69+ self->DestroyWindow();
70+ }
71+ if (wID == IDCANCEL) {
72+ self->OnCancel();
73+ }
74+ return FALSE;
6175 }
62- else {
63- HParent = NULL;
76+ case WM_NCDESTROY:
77+ self->PostNcDestroy();
78+ return TRUE;
79+
80+ default:
81+ return FALSE;
6482 }
65- Abort = AbortFlag;
66- Ok = (CDialog::Create(CPrnAbortDlg::IDD, m_pParent));
67- if (Ok) {
68- ::EnableWindow(HParent,FALSE);
69- ::EnableWindow(GetSafeHwnd(),TRUE);
70- }
83+ return TRUE;
84+}
7185
72- font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
73- GetObject(font, sizeof(LOGFONT), &logfont);
74- if (get_lang_font("DLG_SYSTEM_FONT", GetSafeHwnd(), &logfont, &DlgFont, pts->UILanguageFile)) {
75- SendDlgItemMessage(IDC_PRNABORT_PRINTING, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
76- SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
86+BOOL CPrnAbortDlg::Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts)
87+{
88+ m_pAbort = AbortFlag;
89+ m_hParentWnd = hParent;
90+ m_ts = pts;
91+
92+ HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(IDD_PRNABORTDLG), RT_DIALOG);
93+ HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
94+ DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
95+ HWND hWnd = ::CreateDialogIndirectParam(
96+ hInstance, lpTemplate, hParent,
97+ (DLGPROC)OnDlgProc, (LPARAM)this);
98+ if (hWnd == NULL)
99+ {
100+ return FALSE;
77101 }
78102
79- return Ok;
103+ m_hWnd = hWnd;
104+ ::EnableWindow(hParent,FALSE);
105+ ::ShowWindow(hWnd, SW_SHOW);
106+ ::EnableWindow(m_hWnd,TRUE);
107+ return TRUE;
80108 }
81109
82110 void CPrnAbortDlg::OnCancel()
83111 {
84- *Abort = TRUE;
112+ *m_pAbort = TRUE;
85113 DestroyWindow();
86114 }
87115
88-BOOL CPrnAbortDlg::OnCommand(WPARAM wParam, LPARAM lParam)
89-{
90- *Abort = TRUE;
91- DestroyWindow();
92-
93- return CDialog::OnCommand(wParam, lParam);
94-}
95-
96116 void CPrnAbortDlg::PostNcDestroy()
97117 {
118+ ::DeleteObject(m_hNewFont);
98119 delete this;
99120 }
100121
101122 BOOL CPrnAbortDlg::DestroyWindow()
102123 {
103- HWND HParent;
124+ ::EnableWindow(m_hParentWnd,TRUE);
125+ ::SetFocus(m_hParentWnd);
126+ ::DestroyWindow(m_hWnd);
127+ return TRUE;
128+}
104129
105- HParent = m_pParent->GetSafeHwnd();
106- ::EnableWindow(HParent,TRUE);
107- ::SetFocus(HParent);
108- return CDialog::DestroyWindow();
109-}
--- trunk/teraterm/teraterm/prnabort.h (revision 7173)
+++ trunk/teraterm/teraterm/prnabort.h (revision 7174)
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2007-2017 TeraTerm Project
3+ * (C) 2007-2018 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -28,40 +28,25 @@
2828 */
2929
3030 /* TERATERM.EXE, print-abort dialog box */
31+#pragma once
3132
33+#include "tttypes.h" // for TTSet
34+
3235 // CPrnAbortDlg dialog
33-class CPrnAbortDlg : public CDialog
36+class CPrnAbortDlg
3437 {
35-#ifndef NO_I18N
36-private:
37- HFONT DlgFont;
38-#endif
39-
4038 public:
41-#ifndef NO_I18N
42- BOOL Create(CWnd* p_Parent, PBOOL AbortFlag, PTTSet pts);
43-#else
44- BOOL Create(CWnd* p_Parent, PBOOL AbortFlag);
45-#endif
39+ HWND m_hWnd;
40+ HWND GetSafeHwnd() const {return m_hWnd;}
41+ BOOL Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts);
42+ BOOL DestroyWindow();
43+ HFONT m_hNewFont;
4644
47- //{{AFX_DATA(CPrnAbortDlg)
48- enum { IDD = IDD_PRNABORTDLG };
49- //}}AFX_DATA
50-
51- //{{AFX_VIRTUAL(CPrnAbortDlg)
52- public:
53- virtual BOOL DestroyWindow();
54- protected:
55- virtual void OnCancel( );
56- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
57- virtual void PostNcDestroy();
58- //}}AFX_VIRTUAL
59-
60- protected:
61- CWnd* m_pParent;
62- BOOL *Abort;
63-
64- //{{AFX_MSG(CPrnAbortDlg)
65- //}}AFX_MSG
66- DECLARE_MESSAGE_MAP()
45+private:
46+ void OnCancel();
47+ void PostNcDestroy();
48+ HWND m_hParentWnd;
49+ BOOL *m_pAbort;
50+ TTTSet *m_ts;
51+ static LRESULT CALLBACK OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
6752 };
--- trunk/teraterm/teraterm/teraprn.cpp (revision 7173)
+++ trunk/teraterm/teraterm/teraprn.cpp (revision 7174)
@@ -129,7 +129,6 @@
129129 DOCINFO Doc;
130130 char DocName[50];
131131 CWnd* pParent;
132- char uimsg[MAX_UIMSG];
133132
134133 Printing = FALSE;
135134 PrintAbortFlag = FALSE;
@@ -144,16 +143,9 @@
144143 else {
145144 pParent = (CWnd*)pTEKWin;
146145 }
147- PrnAbortDlg->Create(pParent,&PrintAbortFlag,&ts);
146+ PrnAbortDlg->Create(hInst, pParent->GetSafeHwnd(),&PrintAbortFlag,&ts);
148147 HPrnAbortDlg = PrnAbortDlg->GetSafeHwnd();
149148
150- GetDlgItemText(HPrnAbortDlg, IDC_PRNABORT_PRINTING, uimsg, sizeof(uimsg));
151- get_lang_msg("DLG_PRNABORT_PRINTING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
152- SetDlgItemText(HPrnAbortDlg, IDC_PRNABORT_PRINTING, ts.UIMsg);
153- GetDlgItemText(HPrnAbortDlg, IDCANCEL, uimsg, sizeof(uimsg));
154- get_lang_msg("BTN_CANCEL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
155- SetDlgItemText(HPrnAbortDlg, IDCANCEL, ts.UIMsg);
156-
157149 SetAbortProc(PrintDC,PrnAbortProc);
158150
159151 Doc.cbSize = sizeof(DOCINFO);
@@ -595,7 +587,7 @@
595587 else {
596588 pParent = (CWnd*)pTEKWin;
597589 }
598- PrnAbortDlg->Create(pParent,&PrintAbortFlag,&ts);
590+ PrnAbortDlg->Create(hInst, pParent->GetSafeHwnd(),&PrintAbortFlag,&ts);
599591 HPrnAbortDlg = PrnAbortDlg->GetSafeHwnd();
600592
601593 HPrnFile = _lopen(PrnFName,OF_READ);
--- trunk/teraterm/teraterm/dnddlg.cpp (revision 7173)
+++ trunk/teraterm/teraterm/dnddlg.cpp (revision 7174)
@@ -56,26 +56,10 @@
5656 };
5757
5858 struct DrapDropDlgData {
59- HFONT hPrevFont;
59+ HFONT hNewFont;
6060 DrapDropDlgParam *Param;
6161 };
6262
63-static HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount, const char *UILanguageFile, PCHAR key)
64-{
65- if (key == NULL) key = "DLG_TAHOMA_FONT";
66- HFONT hPrevFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
67- LOGFONT logfont;
68- GetObject(hPrevFont, sizeof(LOGFONT), &logfont);
69- HFONT hNewFont;
70- if (get_lang_font("DLG_TAHOMA_FONT", hDlg, &logfont, &hNewFont, UILanguageFile)) {
71- for (int i = 0 ; i < nIDDlgItemCount ; i++) {
72- const int nIDDlgItem = nIDDlgItems[i];
73- SendDlgItemMessage(hDlg, nIDDlgItem, WM_SETFONT, (WPARAM)hNewFont, MAKELPARAM(TRUE,0));
74- }
75- }
76- return hNewFont;
77-}
78-
7963 static LRESULT CALLBACK OnDragDropDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
8064 {
8165 static const int FontIDs[] = {
@@ -117,7 +101,7 @@
117101 SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)DlgData);
118102 DrapDropDlgParam *Param = (DrapDropDlgParam *)lp;
119103 DlgData->Param = Param;
120- DlgData->hPrevFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
104+ DlgData->hNewFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
121105 SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), Param->UILanguageFile);
122106
123107 // target file
@@ -258,15 +242,18 @@
258242 DlgData->Param->DropType = DROP_TYPE_CANCEL;
259243 }
260244 if (wID == IDOK || wID == IDCANCEL) {
261- if (DlgData->hPrevFont != NULL) {
262- DeleteObject(DlgData->hPrevFont);
263- }
264245 EndDialog(hDlgWnd, wID);
265- free(DlgData);
266246 break;
267247 }
268248 return FALSE;
269249 }
250+ case WM_NCDESTROY:
251+ if (DlgData->hNewFont != NULL) {
252+ DeleteObject(DlgData->hNewFont);
253+ DlgData->hNewFont = NULL;
254+ }
255+ free(DlgData);
256+ break;
270257
271258 default:
272259 return FALSE;
--- trunk/teraterm/common/dlglib.c (revision 7173)
+++ trunk/teraterm/common/dlglib.c (revision 7174)
@@ -373,3 +373,21 @@
373373 }
374374 }
375375 }
376+
377+HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
378+ const char *UILanguageFile, PCHAR key)
379+{
380+ if (key == NULL) key = "DLG_TAHOMA_FONT";
381+ HFONT hPrevFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
382+ LOGFONT logfont;
383+ GetObject(hPrevFont, sizeof(LOGFONT), &logfont);
384+ HFONT hNewFont;
385+ if (get_lang_font(key, hDlg, &logfont, &hNewFont, UILanguageFile)) {
386+ for (int i = 0 ; i < nIDDlgItemCount ; i++) {
387+ const int nIDDlgItem = nIDDlgItems[i];
388+ SendDlgItemMessage(hDlg, nIDDlgItem, WM_SETFONT, (WPARAM)hNewFont, MAKELPARAM(TRUE,0));
389+ }
390+ }
391+ return hNewFont;
392+}
393+
--- trunk/teraterm/common/dlglib.h (revision 7173)
+++ trunk/teraterm/common/dlglib.h (revision 7174)
@@ -49,6 +49,8 @@
4949 char *key;
5050 } DlgTextInfo;
5151 void SetDlgTexts(HWND hDlgWnd, const DlgTextInfo *infos, int infoCount, const char *UILanguageFile);
52+HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
53+ const char *UILanguageFile, PCHAR key);
5254
5355 #ifdef __cplusplus
5456 }
旧リポジトリブラウザで表示