Revision: 9969 https://osdn.net/projects/ttssh2/scm/svn/commits/9969 Author: zmatsuo Date: 2022-05-28 03:08:06 +0900 (Sat, 28 May 2022) Log Message: ----------- 通知アイコン(ttcmn_notify.cpp, h, def)修正 - ttcmn_notify.h を追加、通知アイコン関連を ttcommon.h から移動 - 初期化時にアイコンの情報を渡す - 表示時に適切なDPIのアイコンを使用 - 未使用APIを削除 - API名をNotify...() に統一 Modified Paths: -------------- branches/adjust_icon/teraterm/common/ttcommon.h branches/adjust_icon/teraterm/teraterm/vtwin.cpp branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.cpp branches/adjust_icon/teraterm/ttpcmn/ttpcmn.def branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj branches/adjust_icon/ttssh2/ttxssh/ttxssh.c Added Paths: ----------- branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.h -------------- next part -------------- Modified: branches/adjust_icon/teraterm/common/ttcommon.h =================================================================== --- branches/adjust_icon/teraterm/common/ttcommon.h 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/common/ttcommon.h 2022-05-27 18:08:06 UTC (rev 9969) @@ -73,24 +73,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); -DllExport void PASCAL SetCustomNotifyIconID(HINSTANCE hInstance, WORD IconID, BOOL plugin); - -#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 @@ -97,3 +79,4 @@ #include "../ttpcmn/language.h" #include "../ttpcmn/ttcmn_cominfo.h" +#include "../ttpcmn/ttcmn_notify.h" Modified: branches/adjust_icon/teraterm/teraterm/vtwin.cpp =================================================================== --- branches/adjust_icon/teraterm/teraterm/vtwin.cpp 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/teraterm/vtwin.cpp 2022-05-27 18:08:06 UTC (rev 9969) @@ -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" @@ -254,6 +255,7 @@ (ts->VTIcon != IdIconDefault) ? ts->VTIcon : IDI_VT; TTSetIcon(inst, HVTWin, MAKEINTRESOURCEW(icon_id), 0); + NotifySetIconID(&cv, inst, icon_id); } ///////////////////////////////////////////////////////////////////////////// @@ -444,14 +446,12 @@ : IDI_VT; TTSetIcon(inst, 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炤 - // Windows 2000 \x88ȊO\x82\xCD VT \x83E\x83B\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x8E擾\x82\xB3\x82\xEA\x82\xE9\x82̂łȂɂ\xE0\x82\xB5\x82Ȃ\xA2 + // \x92ʒm\x97̈揉\x8A\xFA\x89\xBB if (IsWindows2000()) { - icon_id = (ts.VTIcon != IdIconDefault) ? ts.VTIcon : IDI_VT; + // Windows 2000 \x82̃^\x83X\x83N\x83g\x83\x8C\x83C\x83A\x83C\x83R\x83\x93\x82\xCD 4bit \x82̂ݑΉ\x9E icon_id = IDI_VT_CLASSIC; - SetCustomNotifyIconID(inst, icon_id, FALSE); } + NotifyInitialize(&cv, m_hWnd, WM_USER_NOTIFYICON, hInstance, icon_id); } MainMenu = NULL; @@ -1420,7 +1420,7 @@ DestroyWindow(); TTSetIcon(m_hInst, m_hWnd, NULL, 0); - DeleteNotifyIcon(&cv); + NotifyUninitialize(&cv); } // \x91STera Term\x82̏I\x97\xB9\x82\xF0\x8Ew\x8E\xA6\x82\xB7\x82\xE9 Modified: branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.cpp =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.cpp 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.cpp 2022-05-27 18:08:06 UTC (rev 9969) @@ -42,20 +42,32 @@ #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; int NotifyIconShowCount; - HICON CustomIcon; // \x96\xA2\x8Eg\x97p + HWND parent_wnd; + BOOL created; + UINT callback_msg; + BOOL no_sound; + HINSTANCE IconInstance; + WORD IconID; + HINSTANCE CustomIconInstance; + WORD CustomIconID; } NotifyIcon; +// https://nyaruru.hatenablog.com/entry/20071008/p3 + /** * Shell_NotifyIconW() wrapper * - TT_NOTIFYICONDATAW_V2 \x82\xCD Windows 2000 \x88ȍ~\x82Ŏg\x97p\x89\ @@ -68,56 +80,38 @@ */ static BOOL Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData) { - return Shell_NotifyIconW(dwMessage, (NOTIFYICONDATAW*)lpData); + BOOL r = Shell_NotifyIconW(dwMessage, (NOTIFYICONDATAW*)lpData); +#if _DEBUG + DWORD e = GetLastError(); + assert(r != FALSE && e == 0); +#endif + 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); + //const int primary_monitor_dpi = 96; + 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 NotifyUpdateIcon(NotifyIcon *ni, HICON icon) -{ - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uFlags = NIF_ICON; - NotifyIcon->uID = 1; - NotifyIcon->hIcon = icon; - Shell_NotifyIconW(NIM_MODIFY, NotifyIcon); -} - -static void NotifyDelete(NotifyIcon *ni) -{ - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - Shell_NotifyIconW(NIM_DELETE, NotifyIcon); - ni->NotifyIconShowCount = 0; - free(ni); -} - -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) { @@ -124,196 +118,125 @@ 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) { return; } + if (title == NULL) { + flag = NIIF_NONE; + } - if (! HasBalloonTipSupport()) { - return; + if (ni->no_sound) { + flag |= NIIF_NOSOUND; } - TT_NOTIFYICONDATAW_V2 *NotifyIcon = &ni->notify_icon; - NotifyIcon->uFlags = NIF_INFO | NIF_STATE; - NotifyIcon->dwState = 0; - NotifyIcon->dwStateMask = NIS_HIDDEN; + 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); - - ni->NotifyIconShowCount += 1; -} - -static NotifyIcon *GetNotifyData(PComVar cv) -{ - NotifyIcon *p = (NotifyIcon *)cv->NotifyIcon; - return p; -} - -/* - * EXPORT API - */ - -// SetCustomNotifyIcon(), GetCustomNotifyIcon() \x82ő\x80\x8D\xEC\x82ł\xAB\x82邪\x81A\x93\xE0\x95\x94\x82\xA9\x82\xE7\x82͎g\x97p\x82\xB3\x82\xEA\x82Ȃ\xA2 -static HICON CustomIcon = NULL; - -// \x93\xAE\x8D삷\x82邪 CustomIcon \x82͎g\x97p\x82\xB3\x82\xEA\x82Ȃ\xA2 -void WINAPI SetCustomNotifyIcon(HICON icon) -{ - CustomIcon = icon; -} - -// \x93\xAE\x8D삷\x82邪 CustomIcon \x82͎g\x97p\x82\xB3\x82\xEA\x82Ȃ\xA2 -HICON WINAPI GetCustomNotifyIcon() -{ - return CustomIcon; -} - -static HINSTANCE TTCustomIconInstance = NULL; -static WORD TTCustomIconID = 0; -static HINSTANCE CustomIconInstance = NULL; -static WORD CustomIconID = 0; - -void WINAPI SetCustomNotifyIconID(HINSTANCE hInstance, WORD IconID, BOOL plugin) -{ - if (!plugin) { - CustomIconInstance = hInstance; - CustomIconID = IconID; - - // \x82\xA0\x82ƂŊO\x95\x94\x82\xA9\x82\xE7\x83J\x83X\x83^\x83\x80\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x8F\xC1\x8B\x8E\x82\xB3\x82\xEA\x82\xE9\x82Ƃ\xAB\x82̂\xBD\x82߂\xC9 - // Tera Term \x96{\x91̂\xA9\x82\xE7\x90ݒ肳\x82ꂽ\x83J\x83X\x83^\x83\x80\x92ʒm\x83A\x83C\x83R\x83\x93\x82\xF0\x95ێ\x9D\x82\xB5\x82Ă\xA8\x82\xAD - TTCustomIconInstance = hInstance; - TTCustomIconID = IconID; - } - else { - if (hInstance == NULL) { - CustomIconInstance = TTCustomIconInstance; + if (!ni->created) { + if (Shell_NotifyIconW(NIM_ADD, ¬ify_icon) != FALSE) { + ni->created = TRUE; } - else { - CustomIconInstance = hInstance; - } - if (IconID == 0) { - CustomIconID = TTCustomIconID; - } - else { - CustomIconID = IconID; - } } -} - -void WINAPI CreateNotifyIcon(PComVar cv) -{ - NotifyIcon *ni = GetNotifyData(cv); - HICON icon = NULL; - - // \x83E\x83B\x83\x93\x83h\x83E\x83n\x83\x93\x83h\x83\x8B\x82\xAA\x95K\x97v\x82ɂȂ\xE9\x82̂ŁA\x90ڑ\xB1\x92\x86\x82łȂ\xA2\x82ƃA\x83C\x83R\x83\x93\x82͍쐬\x82ł\xAB\x82Ȃ\xA2 - if (cv->HWin == NULL) { - return; - } - - if (CustomIconInstance != NULL && CustomIconID != 0) { - const int dpi = GetMonitorDpiFromWindow(cv->HWin); - icon = TTLoadIcon(CustomIconInstance, MAKEINTRESOURCEW(CustomIconID), 16 ,16, dpi, TRUE); - } else { - icon = (HICON)SendMessage(cv->HWin, WM_GETICON, ICON_SMALL, 0); + Shell_NotifyIconW(NIM_MODIFY, ¬ify_icon); } - if (ni == NULL) { - ni = NotifyCreate(cv->HWin, icon, WM_USER_NOTIFYICON); - } - else { - NotifyUpdateIcon(ni, icon); - } - cv->NotifyIcon = ni; - // \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\xB7\x82\xE9 + // \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 - if (CustomIconInstance != NULL && CustomIconID != 0 && - icon != NULL) { - DestroyIcon(icon); - } + DestroyIcon(notify_icon.hIcon); + ni->NotifyIconShowCount += 1; } -void WINAPI DeleteNotifyIcon(PComVar cv) +static void NotifySetIconID(NotifyIcon *ni, HINSTANCE hInstance, WORD IconID) { - NotifyIcon* ni = GetNotifyData(cv); - if (ni == NULL) { - return; + ni->CustomIconInstance = hInstance; + ni->CustomIconID = IconID; +} + +static NotifyIcon *NotifyInitialize(HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID) +{ + NotifyIcon *ni = (NotifyIcon *)calloc(sizeof(NotifyIcon) ,1); + assert(hWnd != NULL); + if (! HasBalloonTipSupport()) { + ni->enable = FALSE; + return ni; } - NotifyDelete(ni); + ni->enable = TRUE; + ni->parent_wnd = hWnd; + ni->callback_msg = msg; + ni->no_sound = FALSE; + ni->IconInstance = hInstance; + ni->IconID = IconID; + return ni; } -void WINAPI ShowNotifyIcon(PComVar cv) +static void NotifyUninitialize(NotifyIcon *ni) { - NotifyIcon* ni; - - CreateNotifyIcon(cv); - 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); } + free(ni); +} - NotifyShowIcon(ni); +static NotifyIcon *GetNotifyData(PComVar cv) +{ + assert(cv != NULL); + NotifyIcon *p = (NotifyIcon *)cv->NotifyIcon; + assert(p != NULL); + return p; } +/* + * EXPORT API + */ void WINAPI HideNotifyIcon(PComVar cv) { NotifyIcon *ni = GetNotifyData(cv); - if (ni == NULL) { - return; - } NotifyHide(ni); } -void WINAPI SetVerNotifyIcon(PComVar cv, unsigned int ver) +void WINAPI NotifyMessageW(PComVar cv, const wchar_t *msg, const wchar_t *title, DWORD flag) { NotifyIcon *ni = GetNotifyData(cv); - if (ni == NULL) { - return; - } - NotifySetVersion(ni, ver); -} - -void WINAPI NotifyMessageW(PComVar cv, const wchar_t *msg, const wchar_t *title, DWORD flag) -{ - NotifyIcon *ni; - - CreateNotifyIcon(cv); - ni = GetNotifyData(cv); - if (ni == NULL) { - return; - } - NotifySetMessageW(ni, msg, title, flag); } @@ -325,3 +248,56 @@ 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, HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID) +{ + assert (cv->NotifyIcon == NULL); // 2\x8Fd\x8F\x89\x8A\xFA\x89\xBB + NotifyIcon *ni = NotifyInitialize(hWnd, msg, hInstance, IconID); + cv->NotifyIcon = ni; +} + +/** + * \x92ʒm\x97̈抮\x97\xB9 + */ +void WINAPI NotifyUninitialize(PComVar cv) +{ + NotifyIcon *ni = GetNotifyData(cv); + NotifyUninitialize(ni); + cv->NotifyIcon = NULL; +} + +/** + * \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 NotifyInitialize() \x82Őݒ肵\x82\xBD\x83A\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폜 + */ Added: branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.h =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.h (rev 0) +++ branches/adjust_icon/teraterm/ttpcmn/ttcmn_notify.h 2022-05-27 18:08:06 UTC (rev 9969) @@ -0,0 +1,62 @@ +/* + * 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, HWND hWnd, UINT msg, HINSTANCE hInstance, WORD IconID); +DllExport void WINAPI NotifyUninitialize(PComVar cv); +DllExport void WINAPI HideNotifyIcon(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: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.def =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.def 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.def 2022-05-27 18:08:06 UTC (rev 9969) @@ -26,15 +26,9 @@ replaceInvalidFileNameChar @74 b64encode @75 b64decode @76 - CreateNotifyIcon @77 - DeleteNotifyIcon @78 - ShowNotifyIcon @80 + HideNotifyIcon @81 - SetVerNotifyIcon @82 NotifyMessage @79 - SetCustomNotifyIcon @85 - GetCustomNotifyIcon @86 - SetCustomNotifyIconID @94 SJIS2JIS @30 SJIS2EUC @31 Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2022-05-27 18:08:06 UTC (rev 9969) @@ -152,6 +152,7 @@ <ClInclude Include="language.h" /> <ClInclude Include="ttcmn_cominfo.h" /> <ClInclude Include="ttcmn_dup.h" /> + <ClInclude Include="ttcmn_notify.h" /> </ItemGroup> <ItemGroup> <None Include="ttpcmn.def" /> Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2022-05-27 18:08:06 UTC (rev 9969) @@ -78,6 +78,9 @@ <ClInclude Include="..\teraterm\unicode.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="ttcmn_notify.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="ttpcmn.def"> Modified: branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj =================================================================== --- branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/teraterm/ttpcmn/ttpcmn.v8.vcproj 2022-05-27 18:08:06 UTC (rev 9969) @@ -284,6 +284,10 @@ > </File> <File + RelativePath=".\ttcmn_notify.h" + > + </File> + <File RelativePath="..\common\ttlib.h" > </File> Modified: branches/adjust_icon/ttssh2/ttxssh/ttxssh.c =================================================================== --- branches/adjust_icon/ttssh2/ttxssh/ttxssh.c 2022-05-27 18:07:54 UTC (rev 9968) +++ branches/adjust_icon/ttssh2/ttxssh/ttxssh.c 2022-05-27 18:08:06 UTC (rev 9969) @@ -184,7 +184,7 @@ pvar->ts->SetVTIconID(pvar->ts, NULL, 0); if (IsWindows2000()) { - SetCustomNotifyIconID(NULL, 0, TRUE); + NotifySetIconID(NULL, 0, TRUE); } ssh_heartbeat_lock_finalize(); @@ -668,7 +668,7 @@ // 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炤 // Windows 2000 \x88ȊO\x82\xCD VT \x83E\x83B\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x8E擾\x82\xB3\x82\xEA\x82\xE9\x82̂łȂɂ\xE0\x82\xB5\x82Ȃ\xA2 if (IsWindows2000()) { - SetCustomNotifyIconID(hInst, pvar->settings.IconID, TRUE); + NotifySetIconID(hInst, pvar->settings.IconID, TRUE); } logputs(LOG_LEVEL_VERBOSE, "Entering secure mode");