• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9914 (tree)
Time2022-05-12 00:19:46
Authorzmatsuo

Log Message

ttxsshからアイコンを設定できるようにした

Change Summary

Incremental Difference

--- branches/adjust_icon/teraterm/common/tttypes.h (revision 9913)
+++ branches/adjust_icon/teraterm/common/tttypes.h (revision 9914)
@@ -348,6 +348,8 @@
348348 } cygterm_t;
349349
350350 /* TTTSet */
351+typedef struct tttset TTTSet, *PTTSet;
352+
351353 struct tttset {
352354 /*------ VTSet --------*/
353355 /* Tera Term home directory */
@@ -549,6 +551,7 @@
549551 WORD CRSend_ini;
550552 WORD LocalEcho_ini;
551553 WORD UnicodeDecSpMapping;
554+ HINSTANCE Instance;
552555 WORD VTIcon;
553556 WORD TEKIcon;
554557 WORD ScrollWindowClearScreen;
@@ -645,10 +648,11 @@
645648 wchar_t *ExeDirW; // ttermpro.exe のあるフォルダ
646649 wchar_t *LogDirW; // logやダンプを置くフォルダ
647650 wchar_t *FileDirW; // ダウンロードパス("%APPDATA%" 等が含まれる,使用前に環境変数を展開すること)
651+
652+
653+ void (*SetVTIcon)(TTTSet *ts, HINSTANCE Inst, WORD icon_id);
648654 };
649655
650-typedef struct tttset TTTSet, *PTTSet;
651-
652656 /* New Line modes */
653657 #define IdCR 1
654658 #define IdCRLF 2
--- branches/adjust_icon/teraterm/teraterm/vtwin.cpp (revision 9913)
+++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp (revision 9914)
@@ -256,8 +256,28 @@
256256 if (icon != NULL) {
257257 DestroyIcon(icon);
258258 }
259+
260+ // 通知領域のアイコン
261+ //if (IsWindows2000()) {
262+ if (IsWindows2000OrLater()) {
263+ icon = GetCustomNotifyIcon();
264+ if (icon != NULL) {
265+ DestroyIcon(icon);
266+ }
267+ icon = TTLoadIcon(hInst_, icon_name, 0, 0, dpi);
268+ SetCustomNotifyIcon(icon);
269+ }
259270 }
260271
272+static void SetVTIcon(TTTSet *ts, HINSTANCE inst, WORD icon_id)
273+{
274+ ts->Instance = inst;
275+ ts->VTIcon = icon_id;
276+
277+ const int dpi = GetMonitorDpiFromWindow(HVTWin);
278+ SetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), dpi);
279+}
280+
261281 /////////////////////////////////////////////////////////////////////////////
262282 // CVTWindow constructor
263283
@@ -269,8 +289,10 @@
269289 int CmdShow;
270290 BOOL isFirstInstance;
271291 m_hInst = hInstance;
292+ ts.Instance = hInstance;
272293
273294 CommInit(&cv);
295+ ts.SetVTIcon = SetVTIcon;
274296 isFirstInstance = StartTeraTerm(&ts);
275297
276298 TTXInit(&ts, &cv); /* TTPLUG */
@@ -5051,7 +5073,8 @@
50515073 {
50525074 const int icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT;
50535075 const wchar_t *icon_name = MAKEINTRESOURCEW(icon_id);
5054- SetIcon(m_hInst, m_hWnd, icon_name, NewDPI);
5076+ const HINSTANCE inst = ts.Instance;
5077+ SetIcon(inst, m_hWnd, icon_name, NewDPI);
50555078 }
50565079
50575080 return TRUE;
--- branches/adjust_icon/ttssh2/ttxssh/ttxssh.c (revision 9913)
+++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.c (revision 9914)
@@ -676,46 +676,8 @@
676676
677677 void notify_established_secure_connection(PTInstVar pvar)
678678 {
679- int fuLoad = LR_DEFAULTCOLOR;
679+ pvar->ts->SetVTIcon(pvar->ts, hInst, pvar->settings.IconID);
680680
681- if (IsWindowsNT4()) {
682- fuLoad = LR_VGACOLOR;
683- }
684-
685- // LoadIcon ではなく LoadImage を使うようにし、
686- // 16x16 のアイコンを明示的に取得するようにした (2006.8.9 maya)
687- if (SecureLargeIcon == NULL) {
688- SecureLargeIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
689- IMAGE_ICON, 0, 0, fuLoad);
690- }
691- if (SecureSmallIcon == NULL) {
692- SecureSmallIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
693- IMAGE_ICON, 16, 16, fuLoad);
694- }
695-
696- if (SecureLargeIcon != NULL && SecureSmallIcon != NULL) {
697- pvar->OldLargeIcon =
698- (HICON) SendMessage(pvar->NotificationWindow, WM_GETICON,
699- ICON_BIG, 0);
700- pvar->OldSmallIcon =
701- (HICON) SendMessage(pvar->NotificationWindow, WM_GETICON,
702- ICON_SMALL, 0);
703-
704- PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_BIG,
705- (LPARAM) SecureLargeIcon);
706- PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_SMALL,
707- (LPARAM) SecureSmallIcon);
708- }
709-
710- if (IsWindows2000()) {
711- if (SecureNotifyIcon == NULL) {
712- SecureNotifyIcon = LoadImage(hInst, MAKEINTRESOURCE(pvar->settings.IconID),
713- IMAGE_ICON, 0, 0, LR_VGACOLOR | LR_SHARED);
714- }
715- OldNotifyIcon = GetCustomNotifyIcon();
716- SetCustomNotifyIcon(SecureNotifyIcon);
717- }
718-
719681 logputs(LOG_LEVEL_VERBOSE, "Entering secure mode");
720682 }
721683
@@ -4921,7 +4883,6 @@
49214883 // リーク時のブロック番号を元にブレークを仕掛けるには、以下のようにする。
49224884 //_CrtSetBreakAlloc(3228);
49234885 #endif
4924-// _CrtSetBreakAlloc(259);
49254886 DisableThreadLibraryCalls(hInstance);
49264887 hInst = hInstance;
49274888 pvar = &InstVar;
Show on old repository browser