Revision: 10009 https://osdn.net/projects/ttssh2/scm/svn/commits/10009 Author: nmaya Date: 2022-06-24 08:59:07 +0900 (Fri, 24 Jun 2022) Log Message: ----------- アイコンまわりを整理した ディスプレイ拡大率にあったサイズのアイコンが使われるようにした 各ウィンドウに動的にセットされるアイコン(タイトルバー・タスクバーなどで表示される) 通知アイコン 通知アイコンにフルカラーのアイコンが使われるようにした TTSSH から通知があったときには TTSSH のアイコンが使われるようにした カスタム通知アイコンをセットする API を変更した merge from branches/adjust_icon ticket #43907, #44517 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/43907 https://osdn.net/projects/ttssh2/tracker/detail/44517 Modified Paths: -------------- trunk/doc/en/html/about/history.html trunk/doc/ja/html/about/history.html trunk/doc/ja/html/usage/migrate_to_5.html trunk/teraterm/common/dlglib.h trunk/teraterm/common/dlglib_cpp.cpp trunk/teraterm/common/ttcommon.h trunk/teraterm/common/ttlib_static.c trunk/teraterm/common/tttypes.h trunk/teraterm/keycode/CMakeLists.txt trunk/teraterm/keycode/keycode.c trunk/teraterm/keycode/keycode.v16.vcxproj trunk/teraterm/keycode/keycode.v8.vcproj trunk/teraterm/teraterm/filesys_log.cpp trunk/teraterm/teraterm/ftdlg.cpp trunk/teraterm/teraterm/ftdlg.h trunk/teraterm/teraterm/ftdlg_lite.cpp trunk/teraterm/teraterm/setupdirdlg.cpp trunk/teraterm/teraterm/setupdirdlg.h trunk/teraterm/teraterm/tekwin.cpp trunk/teraterm/teraterm/teraterm.cpp trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttermpro.v8.sln trunk/teraterm/ttpcmn/CMakeLists.txt trunk/teraterm/ttpcmn/ttcmn.c trunk/teraterm/ttpcmn/ttcmn_notify.cpp trunk/teraterm/ttpcmn/ttpcmn.def trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters trunk/teraterm/ttpcmn/ttpcmn.v8.vcproj trunk/teraterm/ttpmacro/ttmacro.cpp trunk/teraterm/ttpmacro/ttmmain.cpp trunk/teraterm/ttpmacro/ttmmain.h trunk/ttssh2/ttxssh/fwd.c trunk/ttssh2/ttxssh/fwdui.c trunk/ttssh2/ttxssh/ssh.c trunk/ttssh2/ttxssh/ttxssh.c trunk/ttssh2/ttxssh/ttxssh.h Added Paths: ----------- trunk/teraterm/ttpcmn/ttcmn_lib.cpp trunk/teraterm/ttpcmn/ttcmn_lib.h trunk/teraterm/ttpcmn/ttcmn_notify.h Property Changed: ---------------- trunk/ trunk/teraterm/ -------------- next part -------------- Index: trunk =================================================================== --- trunk 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk 2022-06-23 23:59:07 UTC (rev 10009) Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,5 ## /branches/4-stable:8924,9256-9257 +/branches/adjust_icon:9905-10008 /branches/drag_and_drop:7130,7139,7141,7143-7147 /branches/flowctrl_dsrdtr:7825-7827 /branches/libressl_3_4_2:9623-9624,9637,9648,9658,9660,9676-9677,9679-9680,9683 Modified: trunk/doc/en/html/about/history.html =================================================================== --- trunk/doc/en/html/about/history.html 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/doc/en/html/about/history.html 2022-06-23 23:59:07 UTC (rev 10009) @@ -52,6 +52,8 @@ <ul> <li>The file handle of TELNET.LOG could not be closed.</li> <!--li>telnet(cygterm)\x90ڑ\xB1\x8E\x9E\x81ANAWS(Negotiate About Window Size)\x82\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAB\x82\xBD\x82Ƃ\xAB\x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x8C\xEB\x82\xC1\x82Đݒ肷\x82\xE9\x89\\x90\xAB\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x82̂ŏC\x90\xB3\x81B</li--> + <!--li>\x92ʒm\x83A\x83C\x83R\x83\x93\x82Ƀt\x83\x8B\x83J\x83\x89\x81[\x82̃A\x83C\x83R\x83\x93\x82\xAA\x8Eg\x82\xED\x82\xEA\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li--> + <!--li>\x83J\x83X\x83^\x83\x80\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x95ύX\x82\xB5\x82Ă\xE0\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xAA\x95ύX\x82\xB3\x82\xEA\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li--> </ul> </li> @@ -3314,6 +3316,7 @@ <ul class="history"> <!--li>Changes <ul> + <li>TTSSH \x82\xA9\x82\xE7\x92ʒm\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x82Ƃ\xAB\x82ɂ\xCD TTSSH \x82̃A\x83C\x83R\x83\x93\x82\xAA\x8Eg\x82\xED\x82\xEA\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> </ul> </li--> Modified: trunk/doc/ja/html/about/history.html =================================================================== --- trunk/doc/ja/html/about/history.html 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/doc/ja/html/about/history.html 2022-06-23 23:59:07 UTC (rev 10009) @@ -50,6 +50,8 @@ <ul> <li>TELNET.LOG\x82̃t\x83@\x83C\x83\x8B\x83n\x83\x93\x83h\x83\x8B\x82\xAA\x83N\x83\x8D\x81[\x83Y\x82ł\xAB\x82Ă\xA2\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> <li>telnet(cygterm)\x90ڑ\xB1\x8E\x9E\x81ANAWS(Negotiate About Window Size)\x82\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAB\x82\xBD\x82Ƃ\xAB\x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x8C\xEB\x82\xC1\x82Đݒ肷\x82\xE9\x89\\x90\xAB\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x82̂ŏC\x90\xB3\x81B</li> + <li>\x92ʒm\x83A\x83C\x83R\x83\x93\x82Ƀt\x83\x8B\x83J\x83\x89\x81[\x82̃A\x83C\x83R\x83\x93\x82\xAA\x8Eg\x82\xED\x82\xEA\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> + <li>\x83J\x83X\x83^\x83\x80\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x95ύX\x82\xB5\x82Ă\xE0\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xAA\x95ύX\x82\xB3\x82\xEA\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> </ul> </li> @@ -3316,10 +3318,11 @@ <h3 id="ttssh_3.0">2022.xx.xx (Ver 3.0 not released)</h3> <ul class="history"> - <!--li>\x95ύX + <li>\x95ύX <ul> + <!--li>TTSSH \x82\xA9\x82\xE7\x92ʒm\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x82Ƃ\xAB\x82ɂ\xCD TTSSH \x82̃A\x83C\x83R\x83\x93\x82\xAA\x8Eg\x82\xED\x82\xEA\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li--> </ul> - </li--> + </li> <!--li>\x83o\x83O\x8FC\x90\xB3 <ul> Modified: trunk/doc/ja/html/usage/migrate_to_5.html =================================================================== --- trunk/doc/ja/html/usage/migrate_to_5.html 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/doc/ja/html/usage/migrate_to_5.html 2022-06-23 23:59:07 UTC (rev 10009) @@ -118,6 +118,17 @@ <li>\x83t\x83@\x83C\x83\x8B\x96\xBC\x81A\x83p\x83X\x82̕\xB6\x8E\x9A\x90\x94\x82\xCDMAX_PATH\x95\xB6\x8E\x9A\x88ȏ\xE3\x82ɂȂ邱\x82Ƃ\xF0\x8Dl\x97\xB6\x81B</li> <li>\x82܂\xBE\x95ω\xBB\x82\xB7\x82\xE9\x97\\x92\xE8(\x83\x81\x83\x93\x83o\x96\xBC\x81A\x8F\x87\x8F\x98\x81A\x83T\x83C\x83Y\x81A\x8C^\x82ȂǂȂ\xC7)\x81B</li> </ul> + <li>\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xCCAPI\x82\xAA\x95ύX\x82\xB3\x82\xEA\x82܂\xB5\x82\xBD\x81B</li> + <ul> + <li>\x8D\x82DPI\x82ɑΉ\x9E\x82\xB5\x82܂\xB5\x82\xBD\x81B</li> + <li>SetVerNotifyIcon(), SetCustomNotifyIcon(), GetCustomNotifyIcon() \x82͍폜\x82\xB3\x82\xEA\x82܂\xB5\x82\xBD\x81B</li> + <li><a href="https://osdn.net/projects/ttssh2/svn/view/trunk/teraterm/ttpcom/ttcmn_notify.h?view=markup&root=ttssh2">trunk/teraterm/ttpcom/ttcmn_notify.h</a></li> + </ul> + <li>\x83w\x83\x8B\x83vAPI\x82\xF0\x92lj\xC1\x81B</li> + <ul> + <li>Unicode\x83t\x83@\x83C\x83\x8B\x96\xBC\x82ɑΉ\x9E\x82\xB5\x82\xBDAPI\x82\xF0\x92lj\xC1\x82\xB5\x82܂\xB5\x82\xBD\x81B<br> + <li><a href="https://osdn.net/projects/ttssh2/svn/view/trunk/teraterm/ttpcom/ttcmn_lib.h?view=markup&root=ttssh2">trunk/teraterm/ttpcom/ttcmn_lib.h</a></li> + </ul> </ul> </body> Index: trunk/teraterm =================================================================== --- trunk/teraterm 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm 2022-06-23 23:59:07 UTC (rev 10009) Property changes on: trunk/teraterm ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,5 ## /branches/4-stable/teraterm:8924,9256-9257 +/branches/adjust_icon/teraterm:9905-10008 /branches/drag_and_drop/teraterm:7130,7139,7141,7143-7147 /branches/flowctrl_dsrdtr/teraterm:7825-7827 /branches/move_code_script/teraterm:9026-9185 Modified: trunk/teraterm/common/dlglib.h =================================================================== --- trunk/teraterm/common/dlglib.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/common/dlglib.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -96,6 +96,8 @@ wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile); 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: trunk/teraterm/common/dlglib_cpp.cpp =================================================================== --- trunk/teraterm/common/dlglib_cpp.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/common/dlglib_cpp.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -92,7 +92,7 @@ DLGPROC lpDialogFunc) { return TTCreateDialogParam(hInstance, lpTemplateName, - hWndParent, lpDialogFunc, NULL); + hWndParent, lpDialogFunc, (LPARAM)NULL); } /** @@ -116,7 +116,7 @@ */ INT_PTR TTDialogBox(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc) { - return TTDialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc, NULL); + return TTDialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc, (LPARAM)NULL); } /** @@ -337,12 +337,13 @@ * @param[in] cx \x83A\x83C\x83R\x83\x93\x83T\x83C\x83Y(96dpi\x8E\x9E) * @param[in] cy \x83A\x83C\x83R\x83\x93\x83T\x83C\x83Y * @param[in] dpi \x83A\x83C\x83R\x83\x93\x83T\x83C\x83Y(cx,cy)\x82\xCDdpi/96\x94{\x82̃T\x83C\x83Y\x82œǂݍ\x9E\x82܂\xEA\x82\xE9 + * @param[in] notify \x83J\x83X\x83^\x83\x80\x92ʒm\x83A\x83C\x83R\x83\x93\x82̏ꍇ\x82\xCD TRUE, \x83E\x83B\x83\x93\x83h\x83E\x83A\x83C\x83R\x83\x93\x82̏ꍇ\x82\xCD FALSE * @return HICON * * cx == 0 && cy == 0 \x82̂Ƃ\xAB\x83f\x83t\x83H\x83\x8B\x83g\x82̃A\x83C\x83R\x83\x93\x83T\x83C\x83Y\x82œǂݍ\x9E\x82\xDE * DestroyIcon()\x82\xB7\x82邱\x82\xC6 */ -static HICON TTLoadIcon(HINSTANCE hinst, const wchar_t *name, int cx, int cy, UINT dpi) +HICON TTLoadIcon(HINSTANCE hinst, const wchar_t *name, int cx, int cy, UINT dpi, BOOL notify) { if (cx == 0 && cy == 0) { // 100%(96dpi?)\x82̂Ƃ\xAB\x81AGetSystemMetrics(SM_CXICON)=32 @@ -360,10 +361,21 @@ cy = cy * dpi / 96; } HICON hIcon; - HRESULT hr = _LoadIconWithScaleDown(hinst, name, cx, cy, &hIcon); - if(FAILED(hr)) { - hIcon = NULL; + if (IsWindowsNT4() || (notify && IsWindows2000())) { + // 4bit \x83A\x83C\x83R\x83\x93 + // 1. NT4 \x82̂Ƃ\xAB + // Windows NT 4.0 \x82\xCD 4bit \x83A\x83C\x83R\x83\x93\x82\xB5\x82\xA9\x83T\x83|\x81[\x83g\x82\xB5\x82Ă\xA2\x82Ȃ\xA2 + // 2. Windows 2000 \x82̃^\x83X\x83N\x83g\x83\x8C\x83C\x83A\x83C\x83R\x83\x93\x82̂Ƃ\xAB + // Windows 2000 \x82̃^\x83X\x83N\x83g\x83\x8C\x83C\x82\xCD 4bit \x83A\x83C\x83R\x83\x93\x82\xB5\x82\xA9\x83T\x83|\x81[\x83g\x82\xB5\x82Ă\xA2\x82Ȃ\xA2 + // LR_VGACOLOR = 16(4bit) color = VGA color + hIcon = (HICON)LoadImageW(hinst, name, IMAGE_ICON, cx, cy, LR_VGACOLOR); } + else { + HRESULT hr = _LoadIconWithScaleDown(hinst, name, cx, cy, &hIcon); + if(FAILED(hr)) { + hIcon = NULL; + } + } return hIcon; } @@ -401,7 +413,7 @@ case WM_DPICHANGED: { const HINSTANCE hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE); const UINT new_dpi = LOWORD(wp); - HICON icon = TTLoadIcon(hinst, data->icon_name, data->cx, data->cy, new_dpi); + HICON icon = TTLoadIcon(hinst, data->icon_name, data->cx, data->cy, new_dpi, FALSE); if (icon != NULL) { DestroyIcon(data->icon); data->icon = icon; @@ -450,7 +462,7 @@ const HINSTANCE hinst = (HINSTANCE)GetWindowLongPtr(dlg, GWLP_HINSTANCE); const UINT dpi = GetMonitorDpiFromWindow(dlg); - data->icon = TTLoadIcon(hinst, name, cx, cy, dpi); + data->icon = TTLoadIcon(hinst, name, cx, cy, dpi, FALSE); const HWND hwnd = GetDlgItem(dlg, nID); SetIcon(hwnd, data->icon); @@ -478,3 +490,52 @@ 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폜 + HICON null_icon = NULL; + icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)null_icon); + if (icon != NULL) { + DestroyIcon(icon); + } + icon = (HICON)::SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)null_icon); + if (icon != NULL) { + DestroyIcon(icon); + } + } +} Modified: trunk/teraterm/common/ttcommon.h =================================================================== --- trunk/teraterm/common/ttcommon.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/common/ttcommon.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -61,7 +61,6 @@ DllExport void PASCAL ShowAllWinCascade(HWND); DllExport void PASCAL BroadcastClosingMessage(HWND myhwnd); DllExport void PASCAL UndoAllWin(void); -DllExport void PASCAL OpenHelp(UINT Command, DWORD Data, char *UILanguageFile); DllExport int PASCAL CommReadRawByte(PComVar cv, LPBYTE b); DllExport int PASCAL CommRead1Byte(PComVar cv, LPBYTE b); @@ -73,23 +72,6 @@ DllExport int PASCAL CommBinaryEcho(PComVar cv, PCHAR B, int C); DllExport int PASCAL CommTextEchoW(PComVar cv, const wchar_t *B, int C); -DllExport void PASCAL CreateNotifyIcon(PComVar cv); -DllExport void PASCAL DeleteNotifyIcon(PComVar cv); -DllExport void PASCAL NotifyMessageW(PComVar cv, const wchar_t *message, const wchar_t *title, DWORD flag); -DllExport void PASCAL NotifyMessage(PComVar cv, const char *message, const char *title, DWORD flag); -DllExport void PASCAL ShowNotifyIcon(PComVar cv); -DllExport void PASCAL HideNotifyIcon(PComVar cv); -DllExport void PASCAL SetVerNotifyIcon(PComVar cv, unsigned int ver); -DllExport void PASCAL SetCustomNotifyIcon(HICON icon); -DllExport HICON PASCAL GetCustomNotifyIcon(void); - -#define NotifyInfoMessage(cv, msg, title) NotifyMessage(cv, msg, title, 1) -#define NotifyWarnMessage(cv, msg, title) NotifyMessage(cv, msg, title, 2) -#define NotifyErrorMessage(cv, msg, title) NotifyMessage(cv, msg, title, 3) -#define NotifyInfoMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 1) -#define NotifyWarnMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 2) -#define NotifyErrorMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 3) - #ifdef __cplusplus } #endif @@ -96,3 +78,5 @@ #include "../ttpcmn/language.h" #include "../ttpcmn/ttcmn_cominfo.h" +#include "../ttpcmn/ttcmn_notify.h" +#include "../ttpcmn/ttcmn_lib.h" Modified: trunk/teraterm/common/ttlib_static.c =================================================================== --- trunk/teraterm/common/ttlib_static.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/common/ttlib_static.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -321,6 +321,7 @@ * hWnd\x82̕\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82郂\x83j\x83^\x82\xCCDPI\x82\xF0\x8E擾\x82\xB7\x82\xE9 * Per-monitor DPI awareness\x91Ή\x9E * + * @param hWnd (NULL\x82̂Ƃ\xABPrimary monitor) * @retval DPI\x92l(\x92ʏ\xED\x82\xCCDPI\x82\xCD96) */ int GetMonitorDpiFromWindow(HWND hWnd) @@ -336,7 +337,15 @@ } else { UINT dpiX; UINT dpiY; - HMONITOR hMonitor = pMonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor; + if (hWnd == NULL) { + // https://devblogs.microsoft.com/oldnewthing/20070809-00/?p=25643 + const POINT ptZero = { 0, 0 }; + hMonitor = pMonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY); + } + else { + hMonitor = pMonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + } pGetDpiForMonitor(hMonitor, 0 /*0=MDT_EFFECTIVE_DPI*/, &dpiX, &dpiY); return (int)dpiY; } Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/common/tttypes.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -652,6 +652,9 @@ 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) wchar_t *BGImageFilePathW; wchar_t *LogDefaultPathW; // \x83\x8D\x83O\x83t\x83H\x83\x8B\x83_([file]/[log]\x83\x81\x83j\x83\x85\x81[\x82̃\x8D\x83O) + HINSTANCE PluginVTIconInstance; + WORD PluginVTIconID; + HINSTANCE TeraTermInstance; }; typedef struct tttset TTTSet, *PTTSet; @@ -924,6 +927,8 @@ void (*Log1Byte)(BYTE b); void (*Log1Bin)(BYTE b); void (*LogBinSkip)(int add); + + TTTSet *ts; } TComVar; typedef TComVar *PComVar; Modified: trunk/teraterm/keycode/CMakeLists.txt =================================================================== --- trunk/teraterm/keycode/CMakeLists.txt 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/keycode/CMakeLists.txt 2022-06-23 23:59:07 UTC (rev 10009) @@ -16,7 +16,6 @@ ${PACKAGE_NAME} PRIVATE layer_for_unicode - common_static ) if(MSVC) target_sources( @@ -27,6 +26,13 @@ endif() endif(SUPPORT_OLD_WINDOWS) +target_link_libraries( + ${PACKAGE_NAME} + PRIVATE + common_static + ttpcmn +) + set_target_properties( ${PACKAGE_NAME} PROPERTIES @@ -70,7 +76,6 @@ ${PACKAGE_NAME_2} PRIVATE layer_for_unicode - common_static ) if(MSVC) target_sources( @@ -81,6 +86,13 @@ endif() endif(SUPPORT_OLD_WINDOWS) +target_link_libraries( + ${PACKAGE_NAME_2} + PRIVATE + common_static + ttpcmn +) + set_target_properties( ${PACKAGE_NAME_2} PROPERTIES Modified: trunk/teraterm/keycode/keycode.c =================================================================== --- trunk/teraterm/keycode/keycode.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/keycode/keycode.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -34,6 +34,9 @@ #include <string.h> #include <tchar.h> +#include "compat_win.h" +#include "dlglib.h" + #include "kc_res.h" #define ClassName _T("KeyCodeWin32") @@ -81,6 +84,13 @@ } } + // DPI Aware (\x8D\x82DPI\x91Ή\x9E) + if (pIsValidDpiAwarenessContext != NULL && pSetThreadDpiAwarenessContext != NULL) { + if (pIsValidDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) == TRUE) { + pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + } + if(!hPrevInstance) { wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; wc.lpfnWndProc = MainWndProc; @@ -111,14 +121,7 @@ ShowWindow(hWnd, nCmdShow); - PostMessage(hWnd,WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE(IDI_KEYCODE), - IMAGE_ICON,16,16,0)); - PostMessage(hWnd,WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE(IDI_KEYCODE), - IMAGE_ICON,0,0,0)); + TTSetIcon(hInstance, hWnd, MAKEINTRESOURCEW(IDI_KEYCODE), 0); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); @@ -202,6 +205,23 @@ } } +LRESULT OnDpiChanged(HWND hWnd, WPARAM wp, LPARAM lp) +{ + const UINT NewDPI = LOWORD(wp); + (void)lp; + TTSetIcon(ghInstance, hWnd, MAKEINTRESOURCEW(IDI_KEYCODE), NewDPI); + return TRUE; +} + +LRESULT OnDestroy(HWND hWnd) +{ + // \x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x8FI\x97\xB9\x8E\x9E\x82ɃA\x83C\x83R\x83\x93\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9\x82ƁA\x83E\x83B\x83\x93\x83h\x83E\x82\xAA\x8F\xC1\x82\xA6\x82\xE9\x91O\x82\xC9 + // \x83^\x83C\x83g\x83\x8B\x83o\x81[\x82̃A\x83C\x83R\x83\x93\x82\xAA "Windows \x82̎\xC0\x8Ds\x83t\x83@\x83C\x83\x8B\x82̃A\x83C\x83R\x83\x93" \x82ɕς\xED\x82\xE9 + // \x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x82̂Ŕj\x8A\xFC\x82\xB5\x82Ȃ\xA2 + // TTSetIcon(ghInstance, hWnd, NULL, 0); + return TRUE; +} + LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -235,8 +255,12 @@ TimerProc(hWnd, wParam); break; case WM_DESTROY: + OnDestroy(hWnd); PostQuitMessage(0); break; + case WM_DPICHANGED: + OnDpiChanged(hWnd, wParam, lParam); + break; default: return (DefWindowProc(hWnd, msg, wParam, lParam)); } Modified: trunk/teraterm/keycode/keycode.v16.vcxproj =================================================================== --- trunk/teraterm/keycode/keycode.v16.vcxproj 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/keycode/keycode.v16.vcxproj 2022-06-23 23:59:07 UTC (rev 10009) @@ -132,6 +132,14 @@ <ItemGroup> <ClInclude Include="kc_res.h" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\common\common_static.v16.vcxproj"> + <Project>{ac42387d-23ec-45db-81f9-8933c7efa52a}</Project> + </ProjectReference> + <ProjectReference Include="..\ttpcmn\ttpcmn.v16.vcxproj"> + <Project>{118e0d32-5553-4f73-9927-e873c1c500e4}</Project> + </ProjectReference> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> Modified: trunk/teraterm/keycode/keycode.v8.vcproj =================================================================== --- trunk/teraterm/keycode/keycode.v8.vcproj 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/keycode/keycode.v8.vcproj 2022-06-23 23:59:07 UTC (rev 10009) @@ -68,7 +68,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="User32.lib Gdi32.lib" + AdditionalDependencies="User32.lib Gdi32.lib SHELL32.lib Ole32.lib" LinkIncremental="1" SuppressStartupBanner="true" SubSystem="2" @@ -154,7 +154,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="User32.lib Gdi32.lib" + AdditionalDependencies="User32.lib Gdi32.lib SHELL32.lib Ole32.lib" LinkIncremental="1" SuppressStartupBanner="true" GenerateDebugInformation="true" Modified: trunk/teraterm/teraterm/filesys_log.cpp =================================================================== --- trunk/teraterm/teraterm/filesys_log.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/filesys_log.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -391,6 +391,7 @@ BOOL file_exist; int current_bom; TTTSet *pts; + TComVar *pcv; } LogDlgWork_t; static void ArrangeControls(HWND Dialog, LogDlgWork_t *work) @@ -576,7 +577,7 @@ EndDialog(Dialog, IDCANCEL); break; case IDHELP: - OpenHelp(HH_HELP_CONTEXT, HlpFileLog, work->pts->UILanguageFile); + OpenHelpCV(work->pcv, HH_HELP_CONTEXT, HlpFileLog); break; case IDC_FOPT_FILENAME_BUTTON: { /* save current dir */ @@ -1334,6 +1335,7 @@ work->info = info; work->info->filename = srcfnameW; work->pts = &ts; + work->pcv = &cv; INT_PTR ret = TTDialogBoxParam( hInst, MAKEINTRESOURCE(IDD_LOGDLG), hWnd, LogFnHook, (LPARAM)work); Modified: trunk/teraterm/teraterm/ftdlg.cpp =================================================================== --- trunk/teraterm/teraterm/ftdlg.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/ftdlg.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -43,6 +43,7 @@ #include "helpid.h" #include "filesys.h" #include "codeconv.h" +#include "compat_win.h" ///////////////////////////////////////////////////////////////////////////// // CFileTransDlg dialog @@ -49,8 +50,6 @@ CFileTransDlg::CFileTransDlg() { - SmallIcon = NULL; - BigIcon = NULL; DlgCaption = NULL; FileName = NULL; FullName = NULL; @@ -212,8 +211,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 +226,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 +269,30 @@ } } +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); + break; + } + default: + break; + } + return (LRESULT)FALSE; +} Modified: trunk/teraterm/teraterm/ftdlg.h =================================================================== --- trunk/teraterm/teraterm/ftdlg.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/ftdlg.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -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: trunk/teraterm/teraterm/ftdlg_lite.cpp =================================================================== --- trunk/teraterm/teraterm/ftdlg_lite.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/ftdlg_lite.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -40,6 +40,7 @@ #include "dlglib.h" #include "tt_res.h" #include "teraterml.h" +#include "compat_win.h" #include "ftdlg_lite.h" @@ -53,8 +54,6 @@ { public: PrivateData() { - SmallIcon = NULL; - BigIcon = NULL; check_2sec = NULL; show = FALSE; UILanguageFile_ = NULL; @@ -98,8 +97,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 +106,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 +120,7 @@ virtual BOOL OnClose() { + TTSetIcon(m_hInst, m_hWnd, NULL, 0); if (observer_ != NULL) { observer_->OnClose(); } @@ -162,16 +147,6 @@ } virtual BOOL PostNcDestroy() { - if (SmallIcon) { - DestroyIcon((HICON)SmallIcon); - SmallIcon = NULL; - } - - if (BigIcon) { - DestroyIcon((HICON)BigIcon); - BigIcon = NULL; - } - RemoveModelessHandle(m_hWnd); delete this; @@ -178,9 +153,19 @@ 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; const char *UILanguageFile_; public: Modified: trunk/teraterm/teraterm/setupdirdlg.cpp =================================================================== --- trunk/teraterm/teraterm/setupdirdlg.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/setupdirdlg.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -471,12 +471,14 @@ static const DlgTextInfo TextInfos[] = { { 0, "DLG_SETUPDIR_TITLE" }, }; - TTTSet *pts = (TTTSet *)GetWindowLongPtr(hDlgWnd, DWLP_USER); + TComVar *pcv = (TComVar*)GetWindowLongPtr(hDlgWnd, DWLP_USER); + TTTSet *pts = pcv != NULL ? pcv->ts : NULL; switch (msg) { case WM_INITDIALOG: { - pts = (TTTSet *)lp; - SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)pts); + pcv = (TComVar *)lp; + pts = pcv->ts; + SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)pcv); // I18N SetDlgTextsW(hDlgWnd, TextInfos, _countof(TextInfos), pts->UILanguageFileW); @@ -594,7 +596,7 @@ case WM_COMMAND: { switch (LOWORD(wp)) { case IDHELP: - OpenHelp(HH_HELP_CONTEXT, HlpMenuSetupDir, pts->UILanguageFile); + OpenHelpCV(pcv, HH_HELP_CONTEXT, HlpMenuSetupDir); break; case IDOK: @@ -655,8 +657,8 @@ return TRUE; } -void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TTTSet *pts) +void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TComVar *pcv) { TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG), - hWnd, OnSetupDirectoryDlgProc, (LPARAM)pts); + hWnd, OnSetupDirectoryDlgProc, (LPARAM)pcv); } Modified: trunk/teraterm/teraterm/setupdirdlg.h =================================================================== --- trunk/teraterm/teraterm/setupdirdlg.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/setupdirdlg.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -32,4 +32,4 @@ #include <windows.h> #include "tttypes.h" -void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TTTSet *pts); +void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd, TComVar *pcv); Modified: trunk/teraterm/teraterm/tekwin.cpp =================================================================== --- trunk/teraterm/teraterm/tekwin.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/tekwin.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -47,6 +47,7 @@ #include <htmlhelp.h> #include "dlglib.h" #include "codeconv.h" +#include "compat_win.h" #define TEKClassName L"TEKWin32" @@ -58,7 +59,6 @@ WNDCLASSW wc; RECT rect; DWORD Style; - int fuLoad = LR_DEFAULTCOLOR; m_hInst = hInstance; if (! LoadTTTEK()) { @@ -106,17 +106,7 @@ // register this window to the window list RegWin(HVTWin,HTEKWin); - if (IsWindowsNT4()) { - fuLoad = LR_VGACOLOR; - } - ::PostMessage(HTEKWin,WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), - IMAGE_ICON,16,16,fuLoad)); - ::PostMessage(HTEKWin,WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), - IMAGE_ICON, 0, 0, fuLoad)); + TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), 0); MainMenu = NULL; WinMenu = NULL; @@ -302,6 +292,8 @@ HTEKWin = NULL; pTEKWin = NULL; ActiveWin = IdVT; + + TTSetIcon(m_hInst, m_hWnd, NULL, 0); } void CTEKWindow::OnGetMinMaxInfo(MINMAXINFO *lpMMI) @@ -655,7 +647,7 @@ LRESULT CTEKWindow::OnDlgHelp(WPARAM wParam, LPARAM lParam) { DWORD help_id = (wParam == 0) ? HelpId : (DWORD)wParam; - OpenHelp(HH_HELP_CONTEXT, help_id, ts.UILanguageFile); + OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id); return 0; } @@ -779,7 +771,7 @@ void CTEKWindow::OnHelpIndex() { - OpenHelp(HH_DISPLAY_TOPIC, 0, ts.UILanguageFile); + OpenHelpCV(&cv, HH_DISPLAY_TOPIC, 0); } void CTEKWindow::OnHelpAbout() @@ -917,6 +909,11 @@ } break; } + case WM_DPICHANGED: { + const UINT NewDPI = LOWORD(wp); + TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), NewDPI); + break; + } default: retval = DefWindowProc(msg, wp, lp); break; Modified: trunk/teraterm/teraterm/teraterm.cpp =================================================================== --- trunk/teraterm/teraterm/teraterm.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/teraterm.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -289,6 +289,7 @@ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif + ts.TeraTermInstance = hInstance; init(); _HtmlHelpW(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&HtmlHelpCookie); hInst = hInstance; Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/teraterm/vtwin.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -41,6 +41,7 @@ #include "tttypes.h" #include "tttypes_key.h" +#define TTCMN_NOTIFY_INTERNAL 1 #include "ttcommon.h" #include "ttwinman.h" #include "ttsetup.h" @@ -250,11 +251,11 @@ RECT rect; DWORD Style; int CmdShow; - int fuLoad = LR_DEFAULTCOLOR; BOOL isFirstInstance; m_hInst = hInstance; CommInit(&cv); + cv.ts = &ts; isFirstInstance = StartTeraTerm(&ts); TTXInit(&ts, &cv); /* TTPLUG */ @@ -399,6 +400,7 @@ /*--------- Init2 -----------------*/ HVTWin = GetSafeHwnd(); if (HVTWin == NULL) return; + cv.HWin = HVTWin; // register this window to the window list SerialNo = RegWin(HVTWin,NULL); @@ -418,26 +420,12 @@ // USB\x83f\x83o\x83C\x83X\x95ω\xBB\x92ʒm\x93o\x98^ RegDeviceNotify(HVTWin); - if (IsWindowsNT4()) { - fuLoad = LR_VGACOLOR; - } - ::PostMessage(HVTWin,WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), - IMAGE_ICON,16,16,fuLoad)); - // Vista \x82\xCC Aero \x82ɂ\xA8\x82\xA2\x82\xC4 Alt+Tab \x90\xE8\x91ւ\xA6\x82ŕ\\x8E\xA6\x82\xB3\x82\xEA\x82\xE9\x83A\x83C\x83R\x83\x93\x82\xAA - // 16x16 \x83A\x83C\x83R\x83\x93\x82̊g\x91\xE5\x82ɂȂ\xC1\x82Ă\xB5\x82܂\xA4\x82̂ŁA\x91傫\x82\xA2\x83A\x83C\x83R\x83\x93\x82\xE0 - // \x83Z\x83b\x83g\x82\xB7\x82\xE9 (2008.9.3 maya) - ::PostMessage(HVTWin,WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(hInstance, - MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), - IMAGE_ICON, 0, 0, fuLoad)); + // \x92ʒm\x97̈揉\x8A\xFA\x89\xBB + NotifyInitialize(&cv); + NotifySetWindow(&cv, m_hWnd, WM_USER_NOTIFYICON, m_hInst, (ts.VTIcon != IdIconDefault) ? ts.VTIcon: IDI_VT); - SetCustomNotifyIcon( - (HICON)LoadImage( - hInstance, - MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), - IMAGE_ICON, 16, 16, LR_VGACOLOR|LR_SHARED)); + // VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93 + SetVTIconID(&cv, NULL, 0); MainMenu = NULL; WinMenu = NULL; @@ -1402,6 +1390,13 @@ ProtoEnd(); SaveVTPos(); + NotifyUnsetWindow(&cv); + + // \x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x8FI\x97\xB9\x8E\x9E\x82ɃA\x83C\x83R\x83\x93\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9\x82ƁA\x83E\x83B\x83\x93\x83h\x83E\x82\xAA\x8F\xC1\x82\xA6\x82\xE9\x91O\x82\xC9 + // \x83^\x83C\x83g\x83\x8B\x83o\x81[\x82̃A\x83C\x83R\x83\x93\x82\xAA "Windows \x82̎\xC0\x8Ds\x83t\x83@\x83C\x83\x8B\x82̃A\x83C\x83R\x83\x93" \x82ɕς\xED\x82\xE9 + // \x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x82̂Ŕj\x8A\xFC\x82\xB5\x82Ȃ\xA2 + // TTSetIcon(m_hInst, m_hWnd, NULL, 0); + DestroyWindow(); } @@ -1471,7 +1466,7 @@ TTXEnd(); /* TTPLUG */ - DeleteNotifyIcon(&cv); + NotifyUninitialize(&cv); } static void EscapeFilename(const wchar_t *src, wchar_t *dest) @@ -3443,7 +3438,7 @@ LRESULT CVTWindow::OnDlgHelp(WPARAM wParam, LPARAM lParam) { DWORD help_id = (wParam == 0) ? HelpId : (DWORD)wParam; - OpenHelp(HH_HELP_CONTEXT, help_id, ts.UILanguageFile); + OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id); return 0; } @@ -3496,14 +3491,14 @@ break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: - HideNotifyIcon(&cv); + NotifyHideIcon(&cv); break; case NIN_BALLOONTIMEOUT: - HideNotifyIcon(&cv); + NotifyHideIcon(&cv); break; case NIN_BALLOONUSERCLICK: ::SetForegroundWindow(HVTWin); - HideNotifyIcon(&cv); + NotifyHideIcon(&cv); break; } } @@ -4763,7 +4758,7 @@ { SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT"); - SetupDirectoryDialog(m_hInst, HVTWin, &ts); + SetupDirectoryDialog(m_hInst, HVTWin, &cv); } void CVTWindow::OnSetupLoadKeyMap() @@ -4942,7 +4937,7 @@ void CVTWindow::OnHelpIndex() { - OpenHelp(HH_DISPLAY_TOPIC, 0, ts.UILanguageFile); + OpenHelpCV(&cv, HH_DISPLAY_TOPIC, 0); } void CVTWindow::OnHelpAbout() @@ -5087,6 +5082,16 @@ ChangeCaret(); + { + HINSTANCE inst; + WORD icon_id; + inst = (ts.PluginVTIconInstance != NULL) ? ts.PluginVTIconInstance : m_hInst; + icon_id = (ts.PluginVTIconID != 0) ? ts.PluginVTIconID + : (ts.VTIcon != IdIconDefault) ? ts.VTIcon + : IDI_VT; + TTSetIcon(inst, m_hWnd, MAKEINTRESOURCEW(icon_id), NewDPI); + } + return TRUE; } Modified: trunk/teraterm/ttermpro.v8.sln =================================================================== --- trunk/teraterm/ttermpro.v8.sln 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttermpro.v8.sln 2022-06-23 23:59:07 UTC (rev 10009) @@ -11,6 +11,10 @@ EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keycode", "keycode\keycode.v8.vcproj", "{B31BF2E8-79E6-4735-BEA2-C1B4041C2D2E}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + {118E0D32-5553-4F73-9927-E873C1C500E4} = {118E0D32-5553-4F73-9927-E873C1C500E4} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpcmn", "ttpcmn\ttpcmn.v8.vcproj", "{118E0D32-5553-4F73-9927-E873C1C500E4}" ProjectSection(ProjectDependencies) = postProject Modified: trunk/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpcmn/CMakeLists.txt 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/CMakeLists.txt 2022-06-23 23:59:07 UTC (rev 10009) @@ -5,6 +5,7 @@ add_library( ${PACKAGE_NAME} SHARED + ../teraterm/unicode.cpp language.c language.h ttcmn.c @@ -12,10 +13,12 @@ ttcmn_cominfo.h ttcmn_dup.cpp ttcmn_dup.h + ttcmn_lib.cpp + ttcmn_lib.h ttcmn_notify.cpp + ttcmn_notify.h ttpcmn-version.rc ttpcmn.def - ../teraterm/unicode.cpp ) if(SUPPORT_OLD_WINDOWS) Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttcmn.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -270,6 +270,9 @@ else { return FALSE; } + + ts->PluginVTIconInstance = NULL; + ts->PluginVTIconID = 0; } // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82\xF0\x83f\x83B\x83X\x83N\x82ɕۑ\xB6\x82\xB5\x81ATera Term\x96{\x91̂\xF0\x8DċN\x93\xAE\x82\xB7\x82\xE9\x81B @@ -611,37 +614,6 @@ } } -void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile) -{ - wchar_t Temp[MAX_PATH]; - HWND HWin; - wchar_t *HelpFN; - wchar_t uimsg[MAX_UIMSG]; - wchar_t *HomeDirW; - - /* Get home directory TODO ts.HomeDirW \x82\xE8\x91ւ\xA6 */ - if (GetModuleFileNameW(NULL,Temp,_countof(Temp)) == 0) { - return; - } - HomeDirW = ExtractDirNameW(Temp); - get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile); - aswprintf(&HelpFN, L"%s\\%s", HomeDirW, uimsg); - free(HomeDirW); - - // \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya) - HWin = GetDesktopWindow(); - if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL) { - // \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD - static const TTMessageBoxInfoW info = { - "Tera Term", - NULL, L"Tera Term: HTML help", - "MSG_OPENHELP_ERROR", L"Can't open HTML help file(%s).", - MB_OK | MB_ICONERROR }; - TTMessageBoxA(HWin, &info, UILanguageFile, HelpFN); - } - free(HelpFN); -} - HWND WINAPI GetNthWin(int n) { if (n<pm->NWin) { Copied: trunk/teraterm/ttpcmn/ttcmn_lib.cpp (from rev 10005, branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.cpp) =================================================================== --- trunk/teraterm/ttpcmn/ttcmn_lib.cpp (rev 0) +++ trunk/teraterm/ttpcmn/ttcmn_lib.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2022- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "tt_res.h" +#include "dlglib.h" +#include "asprintf.h" +#include "compat_win.h" +#include "win32helper.h" +#include "codeconv.h" + +#include "ttcmn_lib.h" + +/** + * VT Window \x82̃A\x83C\x83R\x83\x93\x82Ƃ\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9 + * + * @param[in] cv \x90ݒ肷\x82\xE9 Tera Term \x82\xCC cv + * @param[in] hInstance \x83A\x83C\x83R\x83\x93\x82\xF0\x95ێ\x9D\x82\xB5\x82Ă\xA2\x82郂\x83W\x83\x85\x81[\x83\x8B\x82̃C\x83\x93\x83X\x83^\x83\x93\x83X + * @param[in] IconID \x83A\x83C\x83R\x83\x93\x82\xCCID + * + * hInstance = NULL, IconID = 0 \x82Ƃ\xB7\x82\xE9\x82ƁA + * \x83R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x82Ŏw\x92肳\x82ꂽ\x83A\x83C\x83R\x83\x93\x81A + * \x8Ew\x92肪\x82Ȃ\xA2\x8E\x9E\x82͕W\x8F\x80\x82\xCCVT\x83A\x83C\x83R\x83\x93\x82\xAA\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82\xE9 + * + * \x92ʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9\x82Ƃ\xAB\x82\xCD NotifySetIconID() \x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9 + */ +void WINAPI SetVTIconID(TComVar *cv, HINSTANCE hInstance, WORD IconID) +{ + HINSTANCE icon_inst; + WORD icon_id; + TTTSet *ts = cv->ts; + + ts->PluginVTIconInstance = hInstance; + ts->PluginVTIconID = IconID; + + icon_inst = (ts->PluginVTIconInstance == NULL) ? ts->TeraTermInstance : ts->PluginVTIconInstance; + icon_id = (ts->PluginVTIconID != 0) ? ts->PluginVTIconID : + (ts->VTIcon != IdIconDefault) ? ts->VTIcon + : IDI_VT; + TTSetIcon(icon_inst, cv->HWin, MAKEINTRESOURCEW(icon_id), 0); +} + +static wchar_t *GetCHMFile(const wchar_t *exe_dir, const wchar_t *UILanguageFile) +{ + wchar_t *chm; + wchar_t *chm_fname; + + GetI18nStrWW("Tera Term", "HELPFILE", L"teraterm.chm", UILanguageFile, &chm_fname); + if(!IsRelativePathW(chm_fname)) { + return chm_fname; + } + aswprintf(&chm, L"%s\\%s", exe_dir, chm_fname); + free(chm_fname); + return chm; +} + +/** + * \x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD + * + * @param[in] Command HtmlHelp() API \x82̑\xE63\x88\xF8\x90\x94 + * @param[in] Data HtmlHelp() API \x82̑\xE64\x88\xF8\x90\x94 + * @param[in] ExeDirW + * @param[in] UILanguageFileW + * + */ +void WINAPI OpenHelpW(UINT Command, DWORD Data, const wchar_t *ExeDirW, wchar_t *UILanguageFileW) +{ + HWND HWin; + wchar_t *chm; + + chm = GetCHMFile(ExeDirW, UILanguageFileW); + + HWin = GetDesktopWindow(); + if (_HtmlHelpW(HWin, chm, Command, Data) == NULL) { + // \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD + static const TTMessageBoxInfoW info = { + "Tera Term", + NULL, L"Tera Term: HTML help", + "MSG_OPENHELP_ERROR", L"Can't open HTML help file(%s).", + MB_OK | MB_ICONERROR }; + TTMessageBoxW(HWin, &info, UILanguageFileW, chm); + } + free(chm); +} + +/** + * \x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD + * + * @param[in] Command HtmlHelp() API \x82̑\xE63\x88\xF8\x90\x94 + * @param[in] Data HtmlHelp() API \x82̑\xE64\x88\xF8\x90\x94 + * + * \x8E\x9F\x82̃R\x81[\x83h\x82\xCD + * HWND HVTWin = GetParent(hDlgWnd); + * PostMessage(HVTWin, WM_USER_DLGHELP2, help_id, 0); + * \x8E\x9F\x82̊\x94\x8CĂяo\x82\xB5\x82Ɠ\xAF\x93\x99 + * OpenHelpCV(&cv, HH_HELP_CONTEXT, help_id); + * + */ +void WINAPI OpenHelpCV(TComVar *cv, UINT Command, DWORD Data) +{ + TTTSet *ts = cv->ts; + return OpenHelpW(Command, Data, ts->ExeDirW, ts->UILanguageFileW); +} + +/** + * \x83w\x83\x8B\x83v\x82\xF0\x8AJ\x82\xAD + * + * \x8C݊\xB7\x88ێ\x9D\x82̂\xBD\x82ߑ\xB6\x8D\xDD + * OpenHelpCV() \x82\xE8\x91ւ\xA6\x82\xF0\x82\xA8\x82\xB7\x82\xB7\x82\xDF + */ +void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFileA) +{ + wchar_t *Temp; + wchar_t *HomeDirW; + wchar_t *UILanguageFileW; + + hGetModuleFileNameW(NULL, &Temp); + HomeDirW = ExtractDirNameW(Temp); + UILanguageFileW = ToWcharA(UILanguageFileA); + OpenHelpW(Command, Data, HomeDirW, UILanguageFileW); + free(UILanguageFileW); + free(HomeDirW); + free(Temp); +} Copied: trunk/teraterm/ttpcmn/ttcmn_lib.h (from rev 10005, branches/adjust_icon/teraterm/ttpcmn/ttcmn_lib.h) =================================================================== --- trunk/teraterm/ttpcmn/ttcmn_lib.h (rev 0) +++ trunk/teraterm/ttpcmn/ttcmn_lib.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <windows.h> + +#include "tttypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +DllExport void WINAPI SetVTIconID(TComVar *cv, HINSTANCE hInstance, WORD IconID); +DllExport void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile); +DllExport void WINAPI OpenHelpW(UINT Command, DWORD Data, const wchar_t *ExeDirW, wchar_t *UILanguageFileW); +DllExport void WINAPI OpenHelpCV(TComVar *cv, UINT Command, DWORD Data); + +#ifdef __cplusplus +} +#endif Modified: trunk/teraterm/ttpcmn/ttcmn_notify.cpp =================================================================== --- trunk/teraterm/ttpcmn/ttcmn_notify.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttcmn_notify.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -42,17 +42,28 @@ #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> +#include <assert.h> #include "teraterm.h" #include "tttypes.h" -#include "ttcommon.h" #include "codeconv.h" #include "compat_win.h" +#include "dlglib.h" +#define TTCMN_NOTIFY_INTERNAL 1 +#include "ttcmn_notify.h" + typedef struct { - TT_NOTIFYICONDATAW_V2 notify_icon; + BOOL enable; // FALSE \x92ʒmAPI\x82\xAA\x8Eg\x82\xA6\x82Ȃ\xA2OS or \x8Eg\x82\xA6\x82Ȃ\xA2\x8F\xF3\x91\xD4 int NotifyIconShowCount; - HICON CustomIcon; + HWND parent_wnd; + BOOL created; + UINT callback_msg; + BOOL no_sound; + HINSTANCE IconInstance; + WORD IconID; + HINSTANCE CustomIconInstance; + WORD CustomIconID; } NotifyIcon; /** @@ -67,46 +78,34 @@ */ static BOOL Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData) { - return Shell_NotifyIconW(dwMessage, (NOTIFYICONDATAW*)lpData); + BOOL r = Shell_NotifyIconW(dwMessage, (NOTIFYICONDATAW*)lpData); + assert(r != FALSE); + return r; } -static NotifyIcon *NotifyCreate(HWND hWnd, HICON icon, UINT msg) +static HICON LoadIcon(NotifyIcon *ni) { - NotifyIcon *ni = (NotifyIcon *)malloc(sizeof(NotifyIcon)); - memset(ni, 0, sizeof(*ni)); + HINSTANCE IconInstance = ni->CustomIconInstance == NULL ? ni->IconInstance : ni->CustomIconInstance; + WORD IconID = ni->CustomIconID == 0 ? ni->IconID : ni->CustomIconID; + const int primary_monitor_dpi = GetMonitorDpiFromWindow(NULL); + return TTLoadIcon(IconInstance, MAKEINTRESOURCEW(IconID), 16 ,16, primary_monitor_dpi, TRUE); +} - TT_NOTIFYICONDATAW_V2 *p = &ni->notify_icon; +static void CreateNotifyIconData(NotifyIcon *ni, TT_NOTIFYICONDATAW_V2 *p) +{ + assert(ni->parent_wnd != NULL); + memset(p, 0, sizeof(*p)); p->cbSize = sizeof(*p); - p->hWnd = hWnd; + p->hWnd = ni->parent_wnd; p->uID = 1; - p->uFlags = NIF_ICON | NIF_MESSAGE; - p->uCallbackMessage = msg; - p->hIcon = icon; + p->uCallbackMessage = ni->callback_msg; + p->hIcon = LoadIcon(ni); - Shell_NotifyIconW(NIM_ADD, p); - - ni->NotifyIconShowCount = 0; - - return ni; + p->uFlags = + ((p->uCallbackMessage != 0) ? NIF_MESSAGE : 0) | + ((p->hIcon != NULL) ? NIF_ICON : 0); } -static void NotifyDelete(NotifyIcon *ni) -{ - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - Shell_NotifyIconW(NIM_DELETE, NotifyIcon); - ni->NotifyIconShowCount = 0; -} - -static void NotifyShowIcon(NotifyIcon *ni) -{ - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uFlags = NIF_STATE; - NotifyIcon->dwState = 0; - NotifyIcon->dwStateMask = NIS_HIDDEN; - Shell_NotifyIconW(NIM_MODIFY, NotifyIcon); - ni->NotifyIconShowCount += 1; -} - static void NotifyHide(NotifyIcon *ni) { if (ni->NotifyIconShowCount > 1) { @@ -113,130 +112,150 @@ ni->NotifyIconShowCount -= 1; } else { - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uFlags = NIF_STATE; - NotifyIcon->dwState = NIS_HIDDEN; - NotifyIcon->dwStateMask = NIS_HIDDEN; - Shell_NotifyIconW(NIM_MODIFY, NotifyIcon); + TT_NOTIFYICONDATAW_V2 notify_icon; + CreateNotifyIconData(ni, ¬ify_icon); + notify_icon.uFlags |= NIF_STATE; + notify_icon.dwState = NIS_HIDDEN; + notify_icon.dwStateMask = NIS_HIDDEN; + Shell_NotifyIconW(NIM_MODIFY, ¬ify_icon); ni->NotifyIconShowCount = 0; + DestroyIcon(notify_icon.hIcon); } } -static void NotifySetVersion(NotifyIcon *ni, unsigned int ver) -{ - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uVersion = ver; - Shell_NotifyIconW(NIM_SETVERSION, NotifyIcon); -} - +/** + * + * @param flag NOTIFYICONDATA.dwInfoFlags + * 1 information icon + * 2 warning icon + * 3 error icon + */ static void NotifySetMessageW(NotifyIcon *ni, const wchar_t *msg, const wchar_t *title, DWORD flag) { - if (msg == NULL) { + if (!ni->enable || msg == NULL) { return; } - - if (! HasBalloonTipSupport()) { + if (ni->parent_wnd == NULL) { + // \x82܂\xBE\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x83Z\x83b\x83g\x82\xB5\x82Ă\xA2\x82Ȃ\xA2 return; } + if (title == NULL) { + flag = NIIF_NONE; + } - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uFlags = NIF_INFO | NIF_STATE; - NotifyIcon->dwState = 0; - NotifyIcon->dwStateMask = NIS_HIDDEN; + if (ni->no_sound) { + flag |= NIIF_NOSOUND; + } + TT_NOTIFYICONDATAW_V2 notify_icon; + CreateNotifyIconData(ni, ¬ify_icon); + notify_icon.uFlags |= NIF_INFO; + notify_icon.uFlags |= NIF_STATE; + notify_icon.dwState = 0; + notify_icon.dwStateMask = NIS_HIDDEN; + if (title) { - NotifyIcon->dwInfoFlags = flag; - wcsncpy_s(NotifyIcon->szInfoTitle, _countof(NotifyIcon->szInfoTitle), title, _TRUNCATE); + wcsncpy_s(notify_icon.szInfoTitle, _countof(notify_icon.szInfoTitle), title, _TRUNCATE); } else { - NotifyIcon->dwInfoFlags = NIIF_NONE; - NotifyIcon->szInfoTitle[0] = 0; + notify_icon.szInfoTitle[0] = 0; } + notify_icon.dwInfoFlags = flag; - wcsncpy_s(NotifyIcon->szInfo, _countof(NotifyIcon->szInfo), msg, _TRUNCATE); + wcsncpy_s(notify_icon.szInfo, _countof(notify_icon.szInfo), msg, _TRUNCATE); - Shell_NotifyIconW(NIM_MODIFY, NotifyIcon); + if (!ni->created) { + if (Shell_NotifyIconW(NIM_ADD, ¬ify_icon) != FALSE) { + ni->created = TRUE; + } + } + else { + Shell_NotifyIconW(NIM_MODIFY, ¬ify_icon); + } + // \x92ʒm\x83A\x83C\x83R\x83\x93\x82͓n\x82\xB5\x82\xBD\x82\xE7\x83R\x83s\x81[\x82\xB3\x82\xEA\x82\xE9\x82̂ŕێ\x9D\x82\xB5\x82Ȃ\xAD\x82Ă悢 + // \x82\xB7\x82\xAE\x82ɔj\x8A\xFC\x82\xB5\x82\xC4ok + // https://docs.microsoft.com/ja-jp/windows/win32/shell/taskbar + // https://stackoverflow.com/questions/23897103/how-to-properly-update-tray-notification-icon + DestroyIcon(notify_icon.hIcon); ni->NotifyIconShowCount += 1; } -/* - * EXPORT API - */ -static HICON CustomIcon = NULL; - -static NotifyIcon *GetNotifyData(PComVar cv) +static void NotifySetIconID(NotifyIcon *ni, HINSTANCE hInstance, WORD IconID) { - NotifyIcon *p = (NotifyIcon *)cv->NotifyIcon; - return p; + ni->CustomIconInstance = hInstance; + ni->CustomIconID = IconID; } -void WINAPI SetCustomNotifyIcon(HICON icon) +static NotifyIcon *NotifyInitialize(void) { - CustomIcon = icon; + NotifyIcon *ni = (NotifyIcon *)calloc(sizeof(NotifyIcon) ,1); + return ni; } -HICON WINAPI GetCustomNotifyIcon() +/** + * \x90e\x83E\x83B\x83\x93\x83h\x83E\x82ƒʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9 + * \x82\xB1\x82\xCCAPI\x82\xF0\x83R\x81[\x83\x8B\x82\xB7\x82\xE9\x82ƒʒm\x97̈悪\x8Eg\x82\xA6\x82\xE9\x82悤\x82ɂȂ\xE9 + * + * @param hWnd \x92ʒm\x97̈\xE6\x82Ɋ֘A\x95t\x82\xAF\x82\xE9\x83E\x83B\x83\x93\x83h\x83E(\x82\xB1\x82\xB1\x82ł͐e\x83E\x83B\x83\x93\x83h\x83E\x82ƌĂ\xD4) + */ +static void NotifySetWindow(NotifyIcon *ni, HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID) { - return CustomIcon; -} - -void WINAPI CreateNotifyIcon(PComVar cv) -{ - NotifyIcon *ni = GetNotifyData(cv); - if (ni != NULL) { + assert(hWnd != NULL); + if (! HasBalloonTipSupport()) { + ni->enable = FALSE; return; } - HICON icon = CustomIcon; - if (icon == NULL) { - icon = (HICON)SendMessage(cv->HWin, WM_GETICON, ICON_SMALL, 0); - } - - ni = NotifyCreate(cv->HWin, icon, WM_USER_NOTIFYICON); - cv->NotifyIcon = ni; + ni->enable = TRUE; + ni->parent_wnd = hWnd; + ni->callback_msg = msg; + ni->no_sound = FALSE; + ni->IconInstance = hInstance; + ni->IconID = IconID; } -void WINAPI DeleteNotifyIcon(PComVar cv) +/** + * \x90e\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9\x91O\x82ɒʒm\x97̈\xE6\x82̃A\x83C\x83R\x83\x93\x82\xF0\x8D폜\x82\xB7\x82\xE9 + * \x82\xB1\x82\xCCAPI\x82\xF0\x83R\x81[\x83\x8B\x82\xB7\x82\xE9\x82ƒʒm\x97̈\xE6\x82͎g\x82\xA6\x82Ȃ\xAD\x82Ȃ\xE9 + */ +static void NotifyUnsetWindow(NotifyIcon *ni) { - NotifyIcon* ni = GetNotifyData(cv); - if (ni == NULL) { - return; + if (ni->enable && ni->created) { + TT_NOTIFYICONDATAW_V2 notify_icon; + CreateNotifyIconData(ni, ¬ify_icon); + Shell_NotifyIconW(NIM_DELETE, ¬ify_icon); + DestroyIcon(notify_icon.hIcon); + ni->created = FALSE; + ni->enable = FALSE; } - NotifyDelete(ni); } -void WINAPI ShowNotifyIcon(PComVar cv) +static void NotifyUninitialize(NotifyIcon *ni) { - NotifyIcon* ni = GetNotifyData(cv); - if (ni == NULL) { - CreateNotifyIcon(cv); - ni = GetNotifyData(cv); - } - - NotifyShowIcon(ni); + NotifyUnsetWindow(ni); + free(ni); } -void WINAPI HideNotifyIcon(PComVar cv) +static NotifyIcon *GetNotifyData(PComVar cv) { - NotifyIcon *ni = GetNotifyData(cv); - NotifyHide(ni); + assert(cv != NULL); + NotifyIcon *p = (NotifyIcon *)cv->NotifyIcon; + assert(p != NULL); + return p; } -// \x8Eg\x82\xED\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 -void WINAPI SetVerNotifyIcon(PComVar cv, unsigned int ver) +/* + * EXPORT API + */ +void WINAPI NotifyHideIcon(PComVar cv) { NotifyIcon *ni = GetNotifyData(cv); - NotifySetVersion(ni, ver); + NotifyHide(ni); } void WINAPI NotifyMessageW(PComVar cv, const wchar_t *msg, const wchar_t *title, DWORD flag) { NotifyIcon *ni = GetNotifyData(cv); - if (ni == NULL) { - CreateNotifyIcon(cv); - ni = GetNotifyData(cv); - } - NotifySetMessageW(ni, msg, title, flag); } @@ -248,3 +267,82 @@ free(titleW); free(msgW); } + +/** + * \x92ʒm\x97̈揉\x8A\xFA\x89\xBB + * + * @param hWnd \x92ʒm\x97̈\xE6\x82̐e\x83E\x83B\x83\x93\x83h\x83E + * @param msg \x90e\x83E\x83B\x83\x93\x83h\x83E\x82֑\x97\x82\xE7\x82\xEA\x82郁\x83b\x83Z\x81[\x83WID + * @param hInstance \x83A\x83C\x83R\x83\x93\x82\xF0\x8E\x9D\x82\x82\x83W\x83\x85\x81[\x83\x8B\x82\xCCinstance + * @param IconID \x83A\x83C\x83R\x83\x93\x82̃\x8A\x83\\x81[\x83XID + */ +void WINAPI NotifyInitialize(PComVar cv) +{ + assert(cv->NotifyIcon == NULL); // 2\x8Fd\x8F\x89\x8A\xFA\x89\xBB + NotifyIcon *ni = NotifyInitialize(); + cv->NotifyIcon = ni; +} + +/** + * \x92ʒm\x97̈抮\x97\xB9 + */ +void WINAPI NotifyUninitialize(PComVar cv) +{ + NotifyIcon *ni = GetNotifyData(cv); + NotifyUninitialize(ni); + cv->NotifyIcon = NULL; +} + +/** + * \x83E\x83B\x83\x93\x83h\x83E\x82ƃA\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9 + * + * @param hWnd \x92ʒm\x97̈\xE6\x82̐e\x83E\x83B\x83\x93\x83h\x83E + * @param msg \x90e\x83E\x83B\x83\x93\x83h\x83E\x82֑\x97\x82\xE7\x82\xEA\x82郁\x83b\x83Z\x81[\x83WID + * @param hInstance \x83A\x83C\x83R\x83\x93\x82\xF0\x8E\x9D\x82\x82\x83W\x83\x85\x81[\x83\x8B\x82\xCCinstance + * @param IconID \x83A\x83C\x83R\x83\x93\x82̃\x8A\x83\\x81[\x83XID + * + * \x82\xB1\x82\xB1\x82ŃZ\x83b\x83g\x82\xB5\x82\xBD\x83A\x83C\x83R\x83\x93\x82\xAA\x83f\x83t\x83H\x83\x8B\x83g\x82̃A\x83C\x83R\x83\x93\x82ƂȂ\xE9 + */ +void WINAPI NotifySetWindow(PComVar cv, HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID) +{ + NotifyIcon *ni = GetNotifyData(cv); + NotifySetWindow(ni, hWnd, msg, hInstance, IconID); +} + +/** + * \x92ʒm\x97̈\xE6\x82̐e\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9\x91O\x82ɃR\x81[\x83\x8B\x82\xB7\x82\xE9 + * \x82\xB1\x82\xCCAPI\x82\xF0\x83R\x81[\x83\x8B\x82\xB7\x82\xE9\x82ƒʒm\x97̈\xE6\x82͎g\x82\xA6\x82Ȃ\xAD\x82Ȃ\xE9 + */ +void WINAPI NotifyUnsetWindow(PComVar cv) +{ + NotifyIcon *ni = GetNotifyData(cv); + NotifyUnsetWindow(ni); +} + +/** + * \x92ʒm\x97̈\xE6\x82Ŏg\x97p\x82\xB7\x82\xE9\x83A\x83C\x83R\x83\x93\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9 + * + * @param hInstance \x83A\x83C\x83R\x83\x93\x82\xF0\x8E\x9D\x82\x82\x83W\x83\x85\x81[\x83\x8B\x82\xCCinstance + * @param IconID \x83A\x83C\x83R\x83\x93\x82̃\x8A\x83\\x81[\x83XID + * + * \x8Ae\x81X\x82\xF0NULL, 0 \x82ɂ\xB7\x82\xE9\x82\xC6 NotifySetWindow() \x82Őݒ肵\x82\xBD\x83f\x83t\x83H\x83\x8B\x83g\x82̃A\x83C\x83R\x83\x93\x82ɖ߂\xE9 + */ +void WINAPI NotifySetIconID(PComVar cv, HINSTANCE hInstance, WORD IconID) +{ + NotifyIcon *ni = GetNotifyData(cv); + NotifySetIconID(ni, hInstance, IconID); +} + +/** + * Tera Term\x82̒ʒm\x97̈\xE6\x82̎g\x82\xA2\x95\xFB + * - \x92ʒm\x82\xB7\x82\xE9\x82Ƃ\xAB\x82ɁA\x83A\x83C\x83R\x83\x93\x82ƃo\x83\x8B\x81[\x83\x93\x82\xF0\x95\\x8E\xA6 + * - \x8F\x89\x82߂Ă̒ʒm\x8E\x9E\x82ɁA\x92ʒm\x83A\x83C\x83R\x83\x93\x8D쐬 + * - \x92ʒm\x83^\x83C\x83\x80\x83A\x83E\x83g + * - \x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x89B\x82\xB7 + * - vtwin.cpp \x82\xCC CVTWindow::OnNotifyIcon() \x82\xF0\x8EQ\x8F\xC6 + * - \x92ʒm\x82\xF0\x83N\x83\x8A\x83b\x83N + * - \x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x89B\x82\xB7 + vtwin\x82\xCCZ\x83I\x81[\x83_\x81[\x82\xF0\x8DőO\x96ʂ\xC9 + * - vtwin.cpp \x82\xCC CVTWindow::OnNotifyIcon() \x82\xF0\x8EQ\x8F\xC6 + * - \x8FI\x97\xB9\x8E\x9E + * - \x83A\x83C\x83R\x83\x93\x82\xF0\x8D폜 + */ Copied: trunk/teraterm/ttpcmn/ttcmn_notify.h (from rev 10005, branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.h) =================================================================== --- trunk/teraterm/ttpcmn/ttcmn_notify.h (rev 0) +++ trunk/teraterm/ttpcmn/ttcmn_notify.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2022- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <windows.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(DllExport) +#define DllExport __declspec(dllimport) +#endif + +// ttermpro.exe \x93\xE0\x95\x94\x82Ŏg\x97p(Tera Term plugin\x82\xA9\x82\xE7\x82͗\x98\x97p\x82\xB5\x82Ȃ\xA2) +#if defined(TTCMN_NOTIFY_INTERNAL) +DllExport void WINAPI NotifyInitialize(PComVar cv); +DllExport void WINAPI NotifyUninitialize(PComVar cv); +DllExport void WINAPI NotifySetWindow(PComVar cv, HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID); +DllExport void WINAPI NotifyUnsetWindow(PComVar cv); +DllExport void WINAPI NotifyHideIcon(PComVar cv); +#endif + +// plugin \x82\xA9\x82\xE7\x82\xE0\x8Eg\x97p\x89\\x82\xC8IF +DllExport void WINAPI NotifyMessageW(PComVar cv, const wchar_t *message, const wchar_t *title, DWORD flag); +DllExport void WINAPI NotifyMessage(PComVar cv, const char *message, const char *title, DWORD flag); +DllExport void WINAPI NotifySetIconID(PComVar cv, HINSTANCE hInstance, WORD IconID); + +#define NotifyInfoMessage(cv, msg, title) NotifyMessage(cv, msg, title, 1) +#define NotifyWarnMessage(cv, msg, title) NotifyMessage(cv, msg, title, 2) +#define NotifyErrorMessage(cv, msg, title) NotifyMessage(cv, msg, title, 3) +#define NotifyInfoMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 1) +#define NotifyWarnMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 2) +#define NotifyErrorMessageW(cv, msg, title) NotifyMessageW(cv, msg, title, 3) + +#ifdef __cplusplus +} +#endif Modified: trunk/teraterm/ttpcmn/ttpcmn.def =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.def 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttpcmn.def 2022-06-23 23:59:07 UTC (rev 10009) @@ -26,14 +26,12 @@ replaceInvalidFileNameChar @74 b64encode @75 b64decode @76 - CreateNotifyIcon @77 - DeleteNotifyIcon @78 - ShowNotifyIcon @80 - HideNotifyIcon @81 - SetVerNotifyIcon @82 + + NotifyHideIcon @81 NotifyMessage @79 - SetCustomNotifyIcon @85 - GetCustomNotifyIcon @86 + NotifyMessageW + NotifySetIconID + SetVTIconID SJIS2JIS @30 SJIS2EUC @31 @@ -59,6 +57,8 @@ BroadcastClosingMessage @59 UndoAllWin @60 + OpenHelpW + OpenHelpCV OpenHelp @61 GetParam @62 Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2022-06-23 23:59:07 UTC (rev 10009) @@ -139,6 +139,7 @@ <ClCompile Include="ttcmn.c" /> <ClCompile Include="ttcmn_cominfo.c" /> <ClCompile Include="ttcmn_dup.cpp" /> + <ClCompile Include="ttcmn_lib.cpp" /> <ClCompile Include="ttcmn_notify.cpp" /> </ItemGroup> <ItemGroup> @@ -152,6 +153,8 @@ <ClInclude Include="language.h" /> <ClInclude Include="ttcmn_cominfo.h" /> <ClInclude Include="ttcmn_dup.h" /> + <ClInclude Include="ttcmn_lib.h" /> + <ClInclude Include="ttcmn_notify.h" /> </ItemGroup> <ItemGroup> <None Include="ttpcmn.def" /> Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2022-06-23 23:59:07 UTC (rev 10009) @@ -46,6 +46,9 @@ <ClCompile Include="..\teraterm\unicode.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="ttcmn_lib.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\common\i18n.h"> @@ -78,6 +81,12 @@ <ClInclude Include="..\teraterm\unicode.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="ttcmn_notify.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="ttcmn_lib.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="ttpcmn.def"> Modified: trunk/teraterm/ttpcmn/ttpcmn.v8.vcproj =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v8.vcproj 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpcmn/ttpcmn.v8.vcproj 2022-06-23 23:59:07 UTC (rev 10009) @@ -235,6 +235,10 @@ > </File> <File + RelativePath=".\ttcmn_lib.cpp" + > + </File> + <File RelativePath=".\ttcmn_notify.cpp" > </File> @@ -284,6 +288,14 @@ > </File> <File + RelativePath=".\ttcmn_lib.h" + > + </File> + <File + RelativePath=".\ttcmn_notify.h" + > + </File> + <File RelativePath="..\common\ttlib.h" > </File> Modified: trunk/teraterm/ttpmacro/ttmacro.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttmacro.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpmacro/ttmacro.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -139,6 +139,13 @@ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif + // DPI Aware (\x8D\x82DPI\x91Ή\x9E) + if (pIsValidDpiAwarenessContext != NULL && pSetThreadDpiAwarenessContext != NULL) { + if (pIsValidDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) == TRUE) { + pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + } + // InitCommonControls(); init(); Modified: trunk/teraterm/ttpmacro/ttmmain.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttmmain.cpp 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpmacro/ttmmain.cpp 2022-06-23 23:59:07 UTC (rev 10009) @@ -33,6 +33,7 @@ #include <commctrl.h> #include <stdio.h> +#include "compat_win.h" #include "teraterm.h" #include "ttm_res.h" #include "ttmdlg.h" @@ -252,7 +253,6 @@ }; BOOL IOption, VOption; int CmdShow; - int fuLoad = LR_DEFAULTCOLOR; RECT rc_dlg, rc_filename, rc_lineno; LONG dlg_len, len; @@ -260,17 +260,7 @@ Pause = FALSE; - if (IsWindowsNT4()) { - fuLoad = LR_VGACOLOR; - } - ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(m_hInst, - MAKEINTRESOURCE(IDI_TTMACRO), - IMAGE_ICON,16,16,fuLoad)); - ::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(m_hInst, - MAKEINTRESOURCE(IDI_TTMACRO), - IMAGE_ICON,0,0,fuLoad)); + TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTMACRO), 0); ParseParam(&IOption,&VOption); @@ -387,21 +377,16 @@ EndTTL(); EndDDE(); + + // \x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x8FI\x97\xB9\x8E\x9E\x82ɃA\x83C\x83R\x83\x93\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9\x82ƁA\x83E\x83B\x83\x93\x83h\x83E\x82\xAA\x8F\xC1\x82\xA6\x82\xE9\x91O\x82\xC9 + // \x83^\x83C\x83g\x83\x8B\x83o\x81[\x82̃A\x83C\x83R\x83\x93\x82\xAA "Windows \x82̎\xC0\x8Ds\x83t\x83@\x83C\x83\x8B\x82̃A\x83C\x83R\x83\x93" \x82ɕς\xED\x82\xE9 + // \x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x82̂Ŕj\x8A\xFC\x82\xB5\x82Ȃ\xA2 + // TTSetIcon(m_hInst, m_hWnd, NULL, 0); + ::DestroyWindow(m_hStatus); } // for icon drawing in Win NT 3.5 -BOOL CCtrlWindow::OnEraseBkgnd(HDC DC) -{ - if (::IsIconic(m_hWnd)) { - return TRUE; - } - else { - return FALSE; - } -} - -// for icon drawing in Win NT 3.5 void CCtrlWindow::OnPaint() { PAINTSTRUCT ps; @@ -418,14 +403,6 @@ _snprintf_s(buf, sizeof(buf), _TRUNCATE, ":%d:%s", GetLineNo(), GetLineBuffer()); SetDlgItemText(IDC_LINENO, buf); - if (::IsIconic(m_hWnd)) { - int OldMapMode = GetMapMode(dc); - SetMapMode(dc, MM_TEXT); - SendMessage(WM_ICONERASEBKGND,(WPARAM)dc, 0); // TODO - DrawIcon(dc, 0, 0, m_hIcon); - SetMapMode(dc, OldMapMode); - } - EndPaint(&ps); } @@ -485,12 +462,6 @@ #endif } -// for icon drawing in Win NT 3.5 -HCURSOR CCtrlWindow::OnQueryDragIcon() -{ - return m_hIcon; -} - void CCtrlWindow::OnTimer(UINT_PTR nIDEvent) { BOOL TimeOut; @@ -693,6 +664,13 @@ return 0; } +LRESULT CCtrlWindow::OnDpiChanged(WPARAM wp, LPARAM) +{ + const UINT new_dpi = LOWORD(wp); + TTSetIcon(m_hInst, m_hWnd, MAKEINTRESOURCEW(IDI_TTMACRO), new_dpi); + return TRUE; +} + LRESULT CCtrlWindow::DlgProc(UINT msg, WPARAM wp, LPARAM lp) { switch(msg) @@ -701,9 +679,6 @@ OnDestroy(); PostQuitMessage(0); break; - case WM_ERASEBKGND: - OnEraseBkgnd((HDC)wp); - break; case WM_PAINT: OnPaint(); break; @@ -731,6 +706,9 @@ case WM_USER_DDEEND: OnDdeEnd(wp, lp); break; + case WM_DPICHANGED: + OnDpiChanged(wp, lp); + break; } return FALSE; } Modified: trunk/teraterm/ttpmacro/ttmmain.h =================================================================== --- trunk/teraterm/ttpmacro/ttmmain.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/teraterm/ttpmacro/ttmmain.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -62,11 +62,9 @@ BOOL OnClose(); void OnDestroy(); - BOOL OnEraseBkgnd(HDC DC); void OnPaint(); void OnSize(UINT nType, int cx, int cy); void OnGetMinMaxInfo(MINMAXINFO* lpMMI); - HCURSOR OnQueryDragIcon(); void OnSysColorChange(); void OnTimer(UINT_PTR nIDEvent); LRESULT OnDdeCmndEnd(WPARAM wParam, LPARAM lParam); @@ -74,5 +72,5 @@ LRESULT OnDdeReady(WPARAM wParam, LPARAM lParam); LRESULT OnDdeEnd(WPARAM wParam, LPARAM lParam); LRESULT OnMacroBringup(WPARAM wParam, LPARAM lParam); + LRESULT OnDpiChanged(WPARAM wp, LPARAM lp); }; - Modified: trunk/ttssh2/ttxssh/fwd.c =================================================================== --- trunk/ttssh2/ttxssh/fwd.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/ttssh2/ttxssh/fwd.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -1953,7 +1953,10 @@ UTIL_get_lang_msg("MSG_FWD_AGENT_NOTIFY_TITLE", pvar, "Agent Forwarding"); strncpy_s(title, sizeof(title), pvar->ts->UIMsg, _TRUNCATE); UTIL_get_lang_msg("MSG_FWD_AGENT_NOTIFY", pvar, "Remote host access to agent"); + + NotifySetIconID(pvar->cv, hInst, pvar->settings.IconID); NotifyInfoMessage(pvar->cv, pvar->ts->UIMsg, title); + NotifySetIconID(pvar->cv, NULL, 0); } if (pvar->session_settings.ForwardAgentConfirm) { Modified: trunk/ttssh2/ttxssh/fwdui.c =================================================================== --- trunk/ttssh2/ttxssh/fwdui.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/ttssh2/ttxssh/fwdui.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -933,8 +933,7 @@ return TRUE; } -static UINT_PTR CALLBACK fwd_edit_dlg_proc(HWND dlg, UINT msg, WPARAM wParam, - LPARAM lParam) +static INT_PTR CALLBACK fwd_edit_dlg_proc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { FWDEditClosure *closure; PTInstVar pvar; @@ -1059,8 +1058,7 @@ } } -static UINT_PTR CALLBACK fwd_dlg_proc(HWND dlg, UINT msg, WPARAM wParam, - LPARAM lParam) +static INT_PTR CALLBACK fwd_dlg_proc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { PTInstVar pvar; BOOL ret; Modified: trunk/ttssh2/ttxssh/ssh.c =================================================================== --- trunk/ttssh2/ttxssh/ssh.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/ttssh2/ttxssh/ssh.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -7229,7 +7229,9 @@ case 3: msgW = ToWcharU8(msg); if (msgW) { + NotifySetIconID(pvar->cv, hInst, pvar->settings.IconID); NotifyInfoMessageW(pvar->cv, msgW, L"Authentication Banner"); + NotifySetIconID(pvar->cv, NULL, 0); free(msgW); } break; @@ -9492,7 +9494,10 @@ strncpy_s(title, sizeof(title), pvar->ts->UIMsg, _TRUNCATE); UTIL_get_lang_msg("MSG_SSH_AGENTERROR_TOOLARGE", pvar, "Agent request size is too large, ignore it."); + + NotifySetIconID(pvar->cv, hInst, pvar->settings.IconID); NotifyInfoMessage(pvar->cv, pvar->ts->UIMsg, title); + NotifySetIconID(pvar->cv, NULL, 0); } goto error; Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/ttssh2/ttxssh/ttxssh.c 2022-06-23 23:59:07 UTC (rev 10009) @@ -115,11 +115,6 @@ HANDLE hInst; /* Instance handle of TTXSSH.DLL */ -static HICON SecureLargeIcon = NULL; -static HICON SecureSmallIcon = NULL; -static HICON SecureNotifyIcon = NULL; -static HICON OldNotifyIcon = NULL; - static TInstVar *pvar; typedef struct { @@ -187,19 +182,8 @@ FWD_end(pvar); FWDUI_end(pvar); - if (pvar->OldLargeIcon != NULL) { - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_BIG, - (LPARAM) pvar->OldLargeIcon); - pvar->OldLargeIcon = NULL; - } - if (pvar->OldSmallIcon != NULL) { - PostMessage(pvar->NotificationWindow, WM_SETICON, ICON_SMALL, - (LPARAM) pvar->OldSmallIcon); - pvar->OldSmallIcon = NULL; - } - if (OldNotifyIcon) { - SetCustomNotifyIcon(OldNotifyIcon); - } + // VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93 + SetVTIconID(pvar->cv, NULL, 0); ssh_heartbeat_lock_finalize(); @@ -676,46 +660,9 @@ void notify_established_secure_connection(PTInstVar pvar) { - int fuLoad = LR_DEFAULTCOLOR; + // VT \x83E\x83B\x83\x93\x83h\x83E\x82̃A\x83C\x83R\x83\x93 + SetVTIconID(pvar->cv, 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 +4868,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; Modified: trunk/ttssh2/ttxssh/ttxssh.h =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.h 2022-06-23 23:55:17 UTC (rev 10008) +++ trunk/ttssh2/ttxssh/ttxssh.h 2022-06-23 23:59:07 UTC (rev 10009) @@ -238,8 +238,8 @@ HWND NotificationWindow; unsigned int notification_msg; long notification_events; - HICON OldSmallIcon; - HICON OldLargeIcon; + HICON OldSmallIcon; // \x8Eg\x97p\x82\xB5\x82Ȃ\xA2 + HICON OldLargeIcon; // \x8Eg\x97p\x82\xB5\x82Ȃ\xA2 BOOL hostdlg_activated; BOOL hostdlg_Enabled;