[ttssh2-commit] [9931] ftdlg, ftdlg_lite でディスプレイ解像度に応じて適切なアイコンを使用するようにした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 5月 18日 (水) 00:49:57 JST


Revision: 9931
          https://osdn.net/projects/ttssh2/scm/svn/commits/9931
Author:   zmatsuo
Date:     2022-05-18 00:49:56 +0900 (Wed, 18 May 2022)
Log Message:
-----------
ftdlg, ftdlg_lite でディスプレイ解像度に応じて適切なアイコンを使用するようにした

Modified Paths:
--------------
    branches/adjust_icon/teraterm/teraterm/ftdlg.cpp
    branches/adjust_icon/teraterm/teraterm/ftdlg.h
    branches/adjust_icon/teraterm/teraterm/ftdlg_lite.cpp

-------------- next part --------------
Modified: branches/adjust_icon/teraterm/teraterm/ftdlg.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/ftdlg.cpp	2022-05-17 15:49:47 UTC (rev 9930)
+++ branches/adjust_icon/teraterm/teraterm/ftdlg.cpp	2022-05-17 15:49:56 UTC (rev 9931)
@@ -49,8 +49,6 @@
 
 CFileTransDlg::CFileTransDlg()
 {
-	SmallIcon = NULL;
-	BigIcon = NULL;
 	DlgCaption = NULL;
 	FileName = NULL;
 	FullName = NULL;
@@ -212,8 +210,6 @@
 		{ IDC_TRANSHELP, "BTN_HELP" },
 	};
 
-	int fuLoad = LR_DEFAULTCOLOR;
-
 	if (HideDialog) {
 		// Visible = False \x82ł\xE0\x83t\x83H\x83A\x83O\x83\x89\x83E\x83\x93\x83h\x82ɗ\x88\x82Ă\xB5\x82܂\xA4\x82̂ŁA\x82\xBB\x82\xA4\x82Ȃ\xE7\x82Ȃ\xA2
 		// \x82悤\x82Ɋg\x92\xA3\x83X\x83^\x83C\x83\x8B WS_EX_NOACTIVATE \x82\xF0\x8Ew\x92肷\x82\xE9\x81B
@@ -229,21 +225,8 @@
 
 	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 
-	if (IsWindowsNT4()) {
-		fuLoad = LR_VGACOLOR;
-	}
-	SmallIcon = LoadImage(m_hInst,
-						  MAKEINTRESOURCE(IDI_TTERM),
-						  IMAGE_ICON, 16, 16, fuLoad);
-	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_SMALL,
-				  (LPARAM)SmallIcon);
+	TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTERM), 0);
 
-	BigIcon = LoadImage(m_hInst,
-						MAKEINTRESOURCE(IDI_TTERM),
-						IMAGE_ICON, 0, 0, fuLoad);
-	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
-				  (LPARAM)BigIcon);
-
 	AddModelessHandle(m_hWnd);
 
 	return TRUE;
@@ -285,23 +268,29 @@
 	}
 }
 
+BOOL CFileTransDlg::OnClose()
+{
+	TTSetIcon(m_hInst, m_hWnd, NULL, 0);
+	return TRUE;
+}
+
 BOOL CFileTransDlg::PostNcDestroy()
 {
-	// logopen\x82\xC6logclose\x82\xF0\x8CJ\x82\xE8\x95Ԃ\xB7\x82ƁAGDI\x83\x8A\x83\\x81[\x83X\x83\x8A\x81[\x83N\x82ƂȂ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B
-	//   - LoadImage()\x82ɂ\xE6\x82\xE9\x83A\x83C\x83R\x83\x93\x83\x8A\x83\\x81[\x83X\x82\xF0\x89\xF0\x95\xFA\x82\xB7\x82\xE9\x81B
-	// (2016.10.5 yutaka)
-	if (SmallIcon) {
-		DestroyIcon((HICON)SmallIcon);
-		SmallIcon = NULL;
-	}
-
-	if (BigIcon) {
-		DestroyIcon((HICON)BigIcon);
-		BigIcon = NULL;
-	}
-
 	RemoveModelessHandle(m_hWnd);
 
 	delete this;
 	return TRUE;
 }
+
+LRESULT CFileTransDlg::DlgProc(UINT msg, WPARAM wp, LPARAM)
+{
+	switch (msg) {
+	case WM_DPICHANGED: {
+		const UINT NewDPI = LOWORD(wp);
+		TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTERM), NewDPI);
+		return (LRESULT)TRUE;
+	}
+	default:
+		return (LRESULT)FALSE;
+	}
+}

Modified: branches/adjust_icon/teraterm/teraterm/ftdlg.h
===================================================================
--- branches/adjust_icon/teraterm/teraterm/ftdlg.h	2022-05-17 15:49:47 UTC (rev 9930)
+++ branches/adjust_icon/teraterm/teraterm/ftdlg.h	2022-05-17 15:49:56 UTC (rev 9931)
@@ -64,11 +64,11 @@
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 	virtual BOOL PostNcDestroy();
 	virtual BOOL OnInitDialog();
+	virtual BOOL OnClose();
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
 
 private:
 	BOOL Pause;
-	HANDLE SmallIcon;
-	HANDLE BigIcon;
 	const char *UILanguageFile;
 	WORD OpId;
 	int ProgStat;	// \x83v\x83\x8D\x83O\x83\x8C\x83X\x83o\x81[\x82̐i\x92\xBB\x82\xAA\x96߂\xE7\x82Ȃ\xA2\x82悤\x8BL\x89\xAF\x82\xB5\x82Ă\xA8\x82\xAD

Modified: branches/adjust_icon/teraterm/teraterm/ftdlg_lite.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/ftdlg_lite.cpp	2022-05-17 15:49:47 UTC (rev 9930)
+++ branches/adjust_icon/teraterm/teraterm/ftdlg_lite.cpp	2022-05-17 15:49:56 UTC (rev 9931)
@@ -53,8 +53,6 @@
 {
 public:
 	PrivateData() {
-		SmallIcon = NULL;
-		BigIcon = NULL;
 		check_2sec = NULL;
 		show = FALSE;
 		UILanguageFile_ = NULL;
@@ -98,8 +96,6 @@
 
 private:
 	virtual BOOL OnInitDialog() {
-		int fuLoad = LR_DEFAULTCOLOR;
-
 		if (HideDialog) {
 			// Visible = False \x82ł\xE0\x83t\x83H\x83A\x83O\x83\x89\x83E\x83\x93\x83h\x82ɗ\x88\x82Ă\xB5\x82܂\xA4\x82̂ŁA\x82\xBB\x82\xA4\x82Ȃ\xE7\x82Ȃ\xA2
 			// \x82悤\x82Ɋg\x92\xA3\x83X\x83^\x83C\x83\x8B WS_EX_NOACTIVATE \x82\xF0\x8Ew\x92肷\x82\xE9\x81B
@@ -109,21 +105,8 @@
 			ModifyStyleEx(0, WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
 		}
 
-		if (IsWindowsNT4()) {
-			fuLoad = LR_VGACOLOR;
-		}
-		SmallIcon = LoadImage(m_hInst,
-							  MAKEINTRESOURCE(IDI_TTERM),
-							  IMAGE_ICON, 16, 16, fuLoad);
-		::PostMessage(m_hWnd, WM_SETICON, ICON_SMALL,
-					  (LPARAM)SmallIcon);
+		TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTERM), 0);
 
-		BigIcon = LoadImage(m_hInst,
-							MAKEINTRESOURCE(IDI_TTERM),
-							IMAGE_ICON, 0, 0, fuLoad);
-		::PostMessage(m_hWnd, WM_SETICON, ICON_BIG,
-					  (LPARAM)BigIcon);
-
 		AddModelessHandle(m_hWnd);
 
 		if (observer_ == NULL){
@@ -136,6 +119,7 @@
 
 	virtual BOOL OnClose()
 	{
+		TTSetIcon(m_hInst, m_hWnd, NULL, 0);
 		if (observer_ != NULL) {
 			observer_->OnClose();
 		}
@@ -178,6 +162,18 @@
 		return TRUE;
 	}
 
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM) {
+		switch (msg) {
+		case WM_DPICHANGED: {
+			const UINT NewDPI = LOWORD(wp);
+			TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTERM), NewDPI);
+			return (LRESULT)TRUE;
+		}
+		default:
+			return (LRESULT)FALSE;
+		}
+	}
+
 private:
 	HANDLE SmallIcon;
 	HANDLE BigIcon;


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