Commit in reactos/lib/shell32 on MAIN
ros-systray.c+19-351.2 -> 1.3
simplify Shell_NotifyIcon implementation

reactos/lib/shell32
ros-systray.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- ros-systray.c	16 Mar 2004 22:49:29 -0000	1.2
+++ ros-systray.c	16 Mar 2004 23:18:10 -0000	1.3
@@ -35,62 +35,46 @@
 	DWORD	nicon_data[1];	// placeholder for NOTIFYICONDATA structure
 } TrayNotifyCDS_Dummy;
 
-
-/*************************************************************************
- * Shell_NotifyIcon			[SHELL32.296]
- * Shell_NotifyIconA			[SHELL32.297]
- */
-BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
+ /* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */
+static BOOL SHELL_NotifyIcon(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode)
 {
 	HWND hwnd;
 	COPYDATASTRUCT data;
-	TrayNotifyCDS_Dummy* pnotify_data;
 
 	BOOL ret = FALSE;
+	int len = sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+nid_size;
 
-	pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
+	TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len);
 
 	pnotify_data->cookie = 1;
 	pnotify_data->notify_code = dwMessage;
-	memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
+	memcpy(&pnotify_data->nicon_data, pnid, nid_size);
 
 	data.dwData = 1;
-	data.cbData = pnid->cbSize;
+	data.cbData = len;
 	data.lpData = pnotify_data;
 
-	for(hwnd=0; hwnd=FindWindowExA(0, hwnd, "Shell_TrayWnd", NULL); ) {
-		if (SendMessageA(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
+	for(hwnd=0; hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL); )
+		if ((unicode?SendMessageW:SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data))
 			ret = TRUE;
-	}
 
 	return ret;
 }
 
+
+/*************************************************************************
+ * Shell_NotifyIcon			[SHELL32.296]
+ * Shell_NotifyIconA			[SHELL32.297]
+ */
+BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
+{
+	return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
+}
+
 /*************************************************************************
  * Shell_NotifyIconW			[SHELL32.298]
  */
 BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
 {
-	HWND hwnd;
-	COPYDATASTRUCT data;
-	TrayNotifyCDS_Dummy* pnotify_data;
-
-	BOOL ret = FALSE;
-
-	pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
-
-	pnotify_data->cookie = 1;
-	pnotify_data->notify_code = dwMessage;
-	memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
-
-	data.dwData = 1;
-	data.cbData = pnid->cbSize;
-	data.lpData = pnotify_data;
-
-	for(hwnd=0; hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL); ) {
-		if (SendMessageW(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
-			ret = TRUE;
-	}
-
-	return ret;
+	return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, TRUE);
 }
CVSspam 0.2.8