[ttssh2-commit] [9930] TTSetIcon() を dlglib に追加

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


Revision: 9930
          https://osdn.net/projects/ttssh2/scm/svn/commits/9930
Author:   zmatsuo
Date:     2022-05-18 00:49:47 +0900 (Wed, 18 May 2022)
Log Message:
-----------
TTSetIcon() を dlglib に追加

- vtwin.cpp から移動してリネーム

Modified Paths:
--------------
    branches/adjust_icon/teraterm/common/dlglib.h
    branches/adjust_icon/teraterm/common/dlglib_cpp.cpp
    branches/adjust_icon/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: branches/adjust_icon/teraterm/common/dlglib.h
===================================================================
--- branches/adjust_icon/teraterm/common/dlglib.h	2022-05-17 12:05:38 UTC (rev 9929)
+++ branches/adjust_icon/teraterm/common/dlglib.h	2022-05-17 15:49:47 UTC (rev 9930)
@@ -97,6 +97,7 @@
 void SetDlgItemIcon(HWND dlg, int nID, const wchar_t *name, int cx, int cy);
 void SetComboBoxHostHistory(HWND dlg, int dlg_item, int maxhostlist, const wchar_t *SetupFNW);
 HICON TTLoadIcon(HINSTANCE hinst, const wchar_t *name, int cx, int cy, UINT dpi, BOOL notify);
+void TTSetIcon(HINSTANCE hInst, HWND hWnd, const wchar_t *icon_name, UINT dpi);
 
 #ifdef __cplusplus
 }

Modified: branches/adjust_icon/teraterm/common/dlglib_cpp.cpp
===================================================================
--- branches/adjust_icon/teraterm/common/dlglib_cpp.cpp	2022-05-17 12:05:38 UTC (rev 9929)
+++ branches/adjust_icon/teraterm/common/dlglib_cpp.cpp	2022-05-17 15:49:47 UTC (rev 9930)
@@ -479,3 +479,51 @@
 		i++;
 	} while (i <= maxhostlist);
 }
+
+/**
+ *	\x83E\x83B\x83\x93\x83h\x83E\x82ɃA\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9
+ *
+ *	@param	hInst		\x83A\x83C\x83R\x83\x93\x82\xF0\x95ێ\x9D\x82\xB5\x82Ă\xA2\x82郂\x83W\x83\x85\x81[\x83\x8B\x82\xCCinstance
+ *						icon_name == NULL \x82̂Ƃ\xAB NULL \x82ł\xE0\x82悢
+ *	@param	hWnd		\x83A\x83C\x83R\x83\x93\x82\xF0\x90ݒ肷\x82\xE9Window Handle
+ *	@param	icon_name	\x83A\x83C\x83R\x83\x93\x96\xBC
+ *						NULL\x82̂Ƃ\xAB \x83A\x83C\x83R\x83\x93\x82\xF0\x8D폜\x82\xB7\x82\xE9
+ *						id\x82\xA9\x82\xE7\x82̕ϊ\xB7\x82\xCDMAKEINTRESOURCEW()\x82\xF0\x8Eg\x82\xA4
+ *	@param	dpi			dpi
+ *						0 \x82̂Ƃ\xAB hWnd \x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82郂\x83j\x83^\x82\xCCDPI
+ */
+void TTSetIcon(HINSTANCE hInst, HWND hWnd, const wchar_t *icon_name, UINT dpi)
+{
+	HICON icon;
+	if (icon_name != NULL) {
+		if (dpi == 0) {
+			// hWnd \x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82郂\x83j\x83^\x82\xCCDPI
+			dpi = GetMonitorDpiFromWindow(hWnd);
+		}
+
+		// \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(32x32,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB)
+		icon = TTLoadIcon(hInst, icon_name, 0, 0, dpi, FALSE);
+		icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
+		if (icon != NULL) {
+			DestroyIcon(icon);
+		}
+
+		// \x8F\xAC\x82\xB3\x82\xA2\x83A\x83C\x83R\x83\x93(16x16,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB)
+		icon = TTLoadIcon(hInst, icon_name, 16, 16, dpi, FALSE);
+		icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
+		if (icon != NULL) {
+			DestroyIcon(icon);
+		}
+	}
+	else {
+		// \x83A\x83C\x83R\x83\x93\x82\xF0\x8D폜
+		icon = (HICON)::SendMessage(hWnd, WM_GETICON, ICON_BIG, 0);
+		if (icon != NULL) {
+			DestroyIcon(icon);
+		}
+		icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0);
+		if (icon != NULL) {
+			DestroyIcon(icon);
+		}
+	}
+}

Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-17 12:05:38 UTC (rev 9929)
+++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-17 15:49:47 UTC (rev 9930)
@@ -241,28 +241,10 @@
 	AutoDisconnectedPort = port;
 }
 
-static void SetIcon(HINSTANCE hInst_, HWND hWnd, const wchar_t *icon_name, int dpi)
-{
-	// \x91傫\x82\xA2\x83A\x83C\x83R\x83\x93(32x32,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB)
-	HICON icon = TTLoadIcon(hInst_, icon_name, 0, 0, dpi, FALSE);
-	icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
-	if (icon != NULL) {
-		DestroyIcon(icon);
-	}
-
-	// \x8F\xAC\x82\xB3\x82\xA2\x83A\x83C\x83R\x83\x93(16x16,\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̊g\x91嗦\x82\xAA100%(dpi=96)\x82̂Ƃ\xAB)
-	icon = TTLoadIcon(hInst_, icon_name, 16, 16, dpi, FALSE);
-	icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon);
-	if (icon != NULL) {
-		DestroyIcon(icon);
-	}
-}
-
 static void SetVTIcon(TTTSet *ts, HINSTANCE hInstance, WORD IconID)
 {
 	HINSTANCE inst;
 	WORD icon_id;
-	const int dpi = GetMonitorDpiFromWindow(HVTWin);
 
 	ts->PluginVTIconInstance = hInstance;
 	ts->PluginVTIconID = IconID;
@@ -271,7 +253,7 @@
 	icon_id = (ts->PluginVTIconID != 0) ? IconID :
 	                                      (ts->VTIcon != IdIconDefault) ? ts->VTIcon
 	                                                                    : IDI_VT;
-	SetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), dpi);
+	TTSetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), 0);
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -454,7 +436,6 @@
 	{
 		HINSTANCE inst;
 		WORD icon_id;
-		const int dpi = GetMonitorDpiFromWindow(m_hWnd);
 
 		// VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93
 		inst = (ts.PluginVTIconInstance != NULL) ? ts.PluginVTIconInstance : m_hInst;
@@ -461,7 +442,7 @@
 		icon_id = (ts.PluginVTIconID != 0) ? ts.PluginVTIconID
 		                                   : (ts.VTIcon != IdIconDefault) ? ts.VTIcon
 		                                                                  : IDI_VT;
-		SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), dpi);
+		TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(icon_id), 0);
 
 		// \x92ʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93
 		// Windows 2000 \x82̃^\x83X\x83N\x83g\x83\x8C\x83C\x83A\x83C\x83R\x83\x93\x82\xCD 4bit \x82̂ݑΉ\x9E\x82Ȃ̂ŁAID \x82\xF0\x95ۑ\xB6\x82\xB5\x82Ă\xA8\x82\xA2\x82ĕ\\x8E\xA6\x82̂Ƃ\xAB\x82ɓǂݍ\x9E\x82\xF1\x82ł\xE0\x82炤
@@ -5082,7 +5063,7 @@
 		icon_id = (ts.PluginVTIconID != 0) ? ts.PluginVTIconID
 		                                   : (ts.VTIcon != IdIconDefault) ? ts.VTIcon
 		                                                                  : IDI_VT;
-		SetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), NewDPI);
+		TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(icon_id), NewDPI);
 	}
 
 	return TRUE;


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