[Ttssh2-commit] [8543] layer_for_unicode に pShell_NotifyIconW() を追加

scmno****@osdn***** scmno****@osdn*****
2020年 2月 18日 (火) 00:27:35 JST


Revision: 8543
          https://osdn.net/projects/ttssh2/scm/svn/commits/8543
Author:   zmatsuo
Date:     2020-02-18 00:27:34 +0900 (Tue, 18 Feb 2020)
Log Message:
-----------
layer_for_unicode に pShell_NotifyIconW() を追加

Modified Paths:
--------------
    trunk/teraterm/common/compat_win.cpp
    trunk/teraterm/common/compat_win.h
    trunk/teraterm/common/layer_for_unicode.cpp
    trunk/teraterm/common/layer_for_unicode.h

-------------- next part --------------
Modified: trunk/teraterm/common/compat_win.cpp
===================================================================
--- trunk/teraterm/common/compat_win.cpp	2020-02-16 14:55:30 UTC (rev 8542)
+++ trunk/teraterm/common/compat_win.cpp	2020-02-17 15:27:34 UTC (rev 8543)
@@ -50,7 +50,6 @@
 int(WINAPI *pGetMenuStringW)(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int cchMax, UINT flags);
 BOOL(WINAPI *pSetWindowTextW)(HWND hWnd, LPCWSTR lpString);
 DWORD (WINAPI *pGetPrivateProfileStringW)(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName);
-UINT (WINAPI *pDragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
 DWORD (WINAPI *pGetFileAttributesW)(LPCWSTR lpFileName);
 BOOL (WINAPI *pSetDlgItemTextW)(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
 BOOL (WINAPI *pGetDlgItemTextW)(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax);
@@ -87,6 +86,10 @@
 int (WINAPI *pGetWindowTextW)(HWND hWnd, LPWSTR lpString, int nMaxCount);
 int (WINAPI *pGetWindowTextLengthW)(HWND hWnd);
 
+// shell32
+UINT (WINAPI *pDragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
+BOOL (WINAPI *pShell_NotifyIconW)(DWORD dwMessage, NOTIFYICONDATAW *lpData);
+
 /**
  *	GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9
  *	 https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd
@@ -191,6 +194,7 @@
 static const APIInfo Lists_shell32[] = {
 #ifndef UNICODE_API_DISABLE
 	{ "DragQueryFileW", (void **)&pDragQueryFileW },
+	{ "Shell_NotifyIconW", (void **)&pShell_NotifyIconW },
 #endif
 	{},
 };
@@ -247,6 +251,7 @@
 		pSendDlgItemMessageW = NULL;
 		pGetWindowTextW = NULL;
 		pGetWindowTextLengthW = NULL;
+		pShell_NotifyIconW = NULL;
 	}
 
 	// GetConsoleWindow\x93\xC1\x95ʏ\x88\x97\x9D

Modified: trunk/teraterm/common/compat_win.h
===================================================================
--- trunk/teraterm/common/compat_win.h	2020-02-16 14:55:30 UTC (rev 8542)
+++ trunk/teraterm/common/compat_win.h	2020-02-17 15:27:34 UTC (rev 8543)
@@ -110,8 +110,8 @@
 extern LRESULT (WINAPI *pSendMessageW)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 extern int (WINAPI *pGetWindowTextW)(HWND hWnd, LPWSTR lpString, int nMaxCount);
 extern int (WINAPI *pGetWindowTextLengthW)(HWND hWnd);
+extern BOOL (WINAPI *pShell_NotifyIconW)(DWORD dwMessage, NOTIFYICONDATAW *lpData);
 
-
 void WinCompatInit();
 
 #ifdef __cplusplus

Modified: trunk/teraterm/common/layer_for_unicode.cpp
===================================================================
--- trunk/teraterm/common/layer_for_unicode.cpp	2020-02-16 14:55:30 UTC (rev 8542)
+++ trunk/teraterm/common/layer_for_unicode.cpp	2020-02-17 15:27:34 UTC (rev 8543)
@@ -458,3 +458,44 @@
 	free(filenameA);
 	return result;
 }
+
+/*
+ * lpData.cbSize == 952\x82̂Ƃ\xAB\x82̂\xDD ANSI\x8A֐\x94\x82ŏ\x88\x97\x9D\x82\xB7\x82\xE9
+ */
+BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData)
+{
+	if (pShell_NotifyIconW != NULL) {
+		return pShell_NotifyIconW(dwMessage, (PNOTIFYICONDATAW)lpData);
+	}
+
+	const TT_NOTIFYICONDATAW_V2 *w = lpData;
+	if (w->cbSize != sizeof(TT_NOTIFYICONDATAW_V2)) {
+		return FALSE;
+	}
+
+	TT_NOTIFYICONDATAA_V2 nid;
+	TT_NOTIFYICONDATAA_V2 *p = &nid;
+	p->cbSize = sizeof(nid);
+	p->hWnd = w->hWnd;
+	p->uID = w->uID;
+	p->uFlags = w->uFlags;
+	p->uCallbackMessage = w->uCallbackMessage;
+	p->hIcon = w->hIcon;
+	p->dwState = w->dwState;
+	p->dwStateMask = w->dwStateMask;
+	p->uTimeout = w->uTimeout;
+	p->dwInfoFlags = w->dwInfoFlags;
+
+	char *strA = ToCharW(w->szTip);
+	strcpy_s(p->szTip, strA);
+	free(strA);
+	strA = ToCharW(w->szInfoTitle);
+	strcpy_s(p->szInfoTitle, strA);
+	free(strA);
+	strA = ToCharW(w->szInfo);
+	strcpy_s(p->szInfo, strA);
+	free(strA);
+
+	BOOL r = Shell_NotifyIconA(dwMessage, (PNOTIFYICONDATAA)p);
+	return r;
+}

Modified: trunk/teraterm/common/layer_for_unicode.h
===================================================================
--- trunk/teraterm/common/layer_for_unicode.h	2020-02-16 14:55:30 UTC (rev 8542)
+++ trunk/teraterm/common/layer_for_unicode.h	2020-02-17 15:27:34 UTC (rev 8543)
@@ -40,11 +40,61 @@
 extern "C" {
 #endif
 
+/**
+ *	NOTIFYICONDATA \x82\xCD define \x82ŃT\x83C\x83Y\x82\xAA\x95ω\xBB\x82\xB7\x82\xE9
+ *	\x82ǂ\xF1\x82Ȋ‹\xAB\x82ł\xE0\x95ω\xBB\x82\xB5\x82Ȃ\xA2\x82悤\x92\xE8\x8B`
+ *
+ * Shlwapi.dll 5.0
+ * 	Win98+,2000+
+ */
+/*  size 504 bytes */
+typedef struct {
+	DWORD cbSize;
+	HWND hWnd;
+	UINT uID;
+	UINT uFlags;
+	UINT uCallbackMessage;
+	HICON hIcon;
+	char   szTip[128];
+	DWORD dwState;
+	DWORD dwStateMask;
+	char   szInfo[256];
+	union {
+		UINT  uTimeout;
+		UINT  uVersion;	 // used with NIM_SETVERSION, values 0, 3 and 4
+	} DUMMYUNIONNAME;
+	char   szInfoTitle[64];
+	DWORD dwInfoFlags;
+	//GUID guidItem;		// XP+
+	//HICON hBalloonIcon;	// Vista+
+} TT_NOTIFYICONDATAA_V2;
+
+/*  size 952 bytes */
+typedef struct {
+	DWORD cbSize;
+	HWND hWnd;
+	UINT uID;
+	UINT uFlags;
+	UINT uCallbackMessage;
+	HICON hIcon;
+	wchar_t	 szTip[128];
+	DWORD dwState;
+	DWORD dwStateMask;
+	wchar_t	 szInfo[256];
+	union {
+		UINT  uTimeout;
+		UINT  uVersion;	 // used with NIM_SETVERSION, values 0, 3 and 4
+	} DUMMYUNIONNAME;
+	wchar_t	 szInfoTitle[64];
+	DWORD dwInfoFlags;
+	//GUID guidItem;		// XP+
+	//HICON hBalloonIcon;	// Vista+
+} TT_NOTIFYICONDATAW_V2;
+
 BOOL _SetWindowTextW(HWND hWnd, LPCWSTR lpString);
 BOOL _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
 UINT _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax);
 DWORD _GetFileAttributesW(LPCWSTR lpFileName);
-UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
 LRESULT _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
 LRESULT _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 HWND _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y,
@@ -70,6 +120,10 @@
 INT_PTR _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer);
 //INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer);
 
+// shell32.lib
+UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
+BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData);
+
 #ifdef __cplusplus
 }
 #endif


Ttssh2-commit メーリングリストの案内