[ttssh2-commit] [9914] ttxsshからアイコンを設定できるようにした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 5月 12日 (木) 00:19:47 JST


Revision: 9914
          https://osdn.net/projects/ttssh2/scm/svn/commits/9914
Author:   zmatsuo
Date:     2022-05-12 00:19:46 +0900 (Thu, 12 May 2022)
Log Message:
-----------
ttxsshからアイコンを設定できるようにした

Modified Paths:
--------------
    branches/adjust_icon/teraterm/common/tttypes.h
    branches/adjust_icon/teraterm/teraterm/vtwin.cpp
    branches/adjust_icon/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: branches/adjust_icon/teraterm/common/tttypes.h
===================================================================
--- branches/adjust_icon/teraterm/common/tttypes.h	2022-05-08 13:25:16 UTC (rev 9913)
+++ branches/adjust_icon/teraterm/common/tttypes.h	2022-05-11 15:19:46 UTC (rev 9914)
@@ -348,6 +348,8 @@
 } cygterm_t;
 
 /* TTTSet */
+typedef struct tttset TTTSet, *PTTSet;
+
 struct tttset {
 /*------ VTSet --------*/
 	/* Tera Term home directory */
@@ -549,6 +551,7 @@
 	WORD CRSend_ini;
 	WORD LocalEcho_ini;
 	WORD UnicodeDecSpMapping;
+	HINSTANCE Instance;
 	WORD VTIcon;
 	WORD TEKIcon;
 	WORD ScrollWindowClearScreen;
@@ -645,10 +648,11 @@
 	wchar_t *ExeDirW;					// ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_
 	wchar_t *LogDirW;					// log\x82\xE2\x83_\x83\x93\x83v\x82\xF0\x92u\x82\xAD\x83t\x83H\x83\x8B\x83_
 	wchar_t *FileDirW;					// \x83_\x83E\x83\x93\x83\x8D\x81[\x83h\x83p\x83X("%APPDATA%" \x93\x99\x82\xAA\x8A܂܂\xEA\x82\xE9,\x8Eg\x97p\x91O\x82Ɋ‹\xAB\x95ϐ\x94\x82\xF0\x93W\x8AJ\x82\xB7\x82邱\x82\xC6)
+
+
+	void (*SetVTIcon)(TTTSet *ts, HINSTANCE Inst, WORD icon_id);
 };
 
-typedef struct tttset TTTSet, *PTTSet;
-
   /* New Line modes */
 #define IdCR   1
 #define IdCRLF 2

Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-08 13:25:16 UTC (rev 9913)
+++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp	2022-05-11 15:19:46 UTC (rev 9914)
@@ -256,8 +256,28 @@
 	if (icon != NULL) {
 		DestroyIcon(icon);
 	}
+
+	// \x92ʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93
+	//if (IsWindows2000()) {
+	if (IsWindows2000OrLater()) {
+		icon  = GetCustomNotifyIcon();
+		if (icon != NULL) {
+			DestroyIcon(icon);
+		}
+		icon = TTLoadIcon(hInst_, icon_name, 0, 0, dpi);
+		SetCustomNotifyIcon(icon);
+	}
 }
 
+static void SetVTIcon(TTTSet *ts, HINSTANCE inst, WORD icon_id)
+{
+	ts->Instance = inst;
+	ts->VTIcon = icon_id;
+
+	const int dpi = GetMonitorDpiFromWindow(HVTWin);
+	SetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), dpi);
+}
+
 /////////////////////////////////////////////////////////////////////////////
 // CVTWindow constructor
 
@@ -269,8 +289,10 @@
 	int CmdShow;
 	BOOL isFirstInstance;
 	m_hInst = hInstance;
+	ts.Instance = hInstance;
 
 	CommInit(&cv);
+	ts.SetVTIcon = SetVTIcon;
 	isFirstInstance = StartTeraTerm(&ts);
 
 	TTXInit(&ts, &cv); /* TTPLUG */
@@ -5051,7 +5073,8 @@
 	{
 		const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT;
 		const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id);
-		SetIcon(m_hInst, m_hWnd, icon_name, NewDPI);
+		const HINSTANCE inst = ts.Instance;
+		SetIcon(inst, m_hWnd, icon_name, NewDPI);
 	}
 
 	return TRUE;

Modified: branches/adjust_icon/ttssh2/ttxssh/ttxssh.c
===================================================================
--- branches/adjust_icon/ttssh2/ttxssh/ttxssh.c	2022-05-08 13:25:16 UTC (rev 9913)
+++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.c	2022-05-11 15:19:46 UTC (rev 9914)
@@ -676,46 +676,8 @@
 
 void notify_established_secure_connection(PTInstVar pvar)
 {
-	int fuLoad = LR_DEFAULTCOLOR;
+	pvar->ts->SetVTIcon(pvar->ts, hInst, pvar->settings.IconID);
 
-	if (IsWindowsNT4()) {
-		fuLoad = LR_VGACOLOR;
-	}
-
-	// LoadIcon \x82ł͂Ȃ\xAD LoadImage \x82\xF0\x8Eg\x82\xA4\x82悤\x82ɂ\xB5\x81A
-	// 16x16 \x82̃A\x83C\x83R\x83\x93\x82𖾎\xA6\x93I\x82Ɏ擾\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD (2006.8.9 maya)
-	if (SecureLargeIcon == NULL) {
-		SecureLargeIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
-		                            IMAGE_ICON, 0, 0, fuLoad);
-	}
-	if (SecureSmallIcon == NULL) {
-		SecureSmallIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
-		                            IMAGE_ICON, 16, 16, fuLoad);
-	}
-
-	if (SecureLargeIcon != NULL && SecureSmallIcon != NULL) {
-		pvar->OldLargeIcon =
-			(HICON) SendMessage(pvar->NotificationWindow, WM_GETICON,
-			                    ICON_BIG, 0);
-		pvar->OldSmallIcon =
-			(HICON) SendMessage(pvar->NotificationWindow, WM_GETICON,
-			                    ICON_SMALL, 0);
-
-		PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_BIG,
-		            (LPARAM) SecureLargeIcon);
-		PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_SMALL,
-		            (LPARAM) SecureSmallIcon);
-	}
-
-	if (IsWindows2000()) {
-		if (SecureNotifyIcon == NULL) {
-			SecureNotifyIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
-			                             IMAGE_ICON, 0, 0, LR_VGACOLOR | LR_SHARED);
-		}
-		OldNotifyIcon = GetCustomNotifyIcon();
-		SetCustomNotifyIcon(SecureNotifyIcon);
-	}
-
 	logputs(LOG_LEVEL_VERBOSE, "Entering secure mode");
 }
 
@@ -4921,7 +4883,6 @@
 		// \x83\x8A\x81[\x83N\x8E\x9E\x82̃u\x83\x8D\x83b\x83N\x94ԍ\x86\x82\xF0\x8C\xB3\x82Ƀu\x83\x8C\x81[\x83N\x82\xF0\x8Ed\x8A|\x82\xAF\x82\xE9\x82ɂ́A\x88ȉ\xBA\x82̂悤\x82ɂ\xB7\x82\xE9\x81B
 		//_CrtSetBreakAlloc(3228);
 #endif
-//		_CrtSetBreakAlloc(259);
 		DisableThreadLibraryCalls(hInstance);
 		hInst = hInstance;
 		pvar = &InstVar;


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