mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
replace WINE specifiy system tray implementation by a WIN32 compatible implementation
svn path=/trunk/; revision=8762
This commit is contained in:
parent
c20093e554
commit
5c6819aaae
6 changed files with 110 additions and 404 deletions
|
@ -47,7 +47,7 @@ C_SRCS = \
|
|||
shpolicy.c \
|
||||
shv_bg_cmenu.c \
|
||||
shv_item_cmenu.c \
|
||||
systray.c \
|
||||
ros-systray.c \
|
||||
shlcpanel.c
|
||||
|
||||
RC_SRCS = shres.rc version.rc
|
||||
|
|
97
reactos/lib/shell32/ros-systray.c
Normal file
97
reactos/lib/shell32/ros-systray.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright 2004 Martin Fuchs
|
||||
*
|
||||
* Pass on icon notification messages to the systray implementation
|
||||
* in the currently running shell.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "shellapi.h"
|
||||
|
||||
|
||||
/* copy data structure for tray notifications */
|
||||
typedef struct TrayNotifyCDSA {
|
||||
DWORD cookie;
|
||||
DWORD notify_code;
|
||||
NOTIFYICONDATAA nicon_data;
|
||||
} TrayNotifyCDSA;
|
||||
|
||||
typedef struct TrayNotifyCDSW {
|
||||
DWORD cookie;
|
||||
DWORD notify_code;
|
||||
NOTIFYICONDATAW nicon_data;
|
||||
} TrayNotifyCDSW;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Shell_NotifyIcon [SHELL32.296]
|
||||
* Shell_NotifyIconA [SHELL32.297]
|
||||
*/
|
||||
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
|
||||
{
|
||||
HWND hwnd;
|
||||
COPYDATASTRUCT data;
|
||||
TrayNotifyCDSA notify_data;
|
||||
|
||||
BOOL ret = FALSE;
|
||||
|
||||
notify_data.cookie = 1;
|
||||
notify_data.notify_code = dwMessage;
|
||||
memcpy(¬ify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAA));
|
||||
|
||||
data.dwData = 1;
|
||||
data.cbData = sizeof(notify_data);
|
||||
data.lpData = ¬ify_data;
|
||||
|
||||
for(hwnd=0; hwnd=FindWindowExA(0, hwnd, "Shell_TrayWnd", NULL); ) {
|
||||
if (SendMessageA(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Shell_NotifyIconW [SHELL32.298]
|
||||
*/
|
||||
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
|
||||
{
|
||||
HWND hwnd;
|
||||
COPYDATASTRUCT data;
|
||||
TrayNotifyCDSW notify_data;
|
||||
|
||||
BOOL ret = FALSE;
|
||||
|
||||
notify_data.cookie = 1;
|
||||
notify_data.notify_code = dwMessage;
|
||||
memcpy(¬ify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAW));
|
||||
|
||||
data.dwData = 1;
|
||||
data.cbData = sizeof(notify_data);
|
||||
data.lpData = ¬ify_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;
|
||||
}
|
|
@ -921,7 +921,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
|||
InitCommonControlsEx(NULL);
|
||||
|
||||
SIC_Initialize();
|
||||
#ifndef __REACTOS__
|
||||
SYSTRAY_Init();
|
||||
#endif
|
||||
InitChangeNotifications();
|
||||
break;
|
||||
|
||||
|
|
|
@ -134,8 +134,10 @@ HRESULT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uI
|
|||
(((kst) & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY):\
|
||||
DROPEFFECT_MOVE)
|
||||
|
||||
#ifndef __REACTOS__
|
||||
/* Systray */
|
||||
BOOL SYSTRAY_Init(void);
|
||||
#endif
|
||||
|
||||
/* OLE32 */
|
||||
extern HINSTANCE hShellOle32;
|
||||
|
|
|
@ -938,6 +938,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
WCHAR buffer[1024];
|
||||
const WCHAR* ext;
|
||||
|
||||
/* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */
|
||||
memcpy(&sei_tmp, psei, sizeof(sei_tmp));
|
||||
|
||||
TRACE("mask=0x%08lx hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
|
||||
|
@ -948,6 +949,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
|
||||
psei->hProcess = NULL;
|
||||
|
||||
/* make copies of all path/command strings */
|
||||
if (sei_tmp.lpFile)
|
||||
strcpyW(wszApplicationName, sei_tmp.lpFile);
|
||||
else
|
||||
|
@ -963,6 +965,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
else
|
||||
*wszDir = '\0';
|
||||
|
||||
/* adjust string pointers to point to the new buffers */
|
||||
sei_tmp.lpFile = wszApplicationName;
|
||||
sei_tmp.lpParameters = wszParameters;
|
||||
sei_tmp.lpDirectory = wszDir;
|
||||
|
@ -1030,9 +1033,6 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Else, try to execute the filename */
|
||||
TRACE("execute:'%s','%s'\n", debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters));
|
||||
|
||||
|
||||
/* resolve shell shortcuts */
|
||||
ext = PathFindExtensionW(sei_tmp.lpFile);
|
||||
|
@ -1043,7 +1043,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
sei_tmp.hwnd, sei_tmp.lpVerb?sei_tmp.lpVerb:wszEmpty, &sei_tmp.nShow, (LPITEMIDLIST*)&sei_tmp.lpIDList);
|
||||
|
||||
if (psei->lpIDList)
|
||||
psei->fMask |= SEE_MASK_IDLIST;
|
||||
psei->fMask |= SEE_MASK_IDLIST; //@@ nicht sei_tmp.fMask ?!
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -1103,6 +1103,9 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
if (ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buffer, MAX_PATH))
|
||||
lstrcpyW(wszDir/*sei_tmp.lpDirectory*/, buffer);
|
||||
|
||||
/* Else, try to execute the filename */
|
||||
TRACE("execute:'%s','%s','%s'\n", debugstr_w(wszApplicationName), debugstr_w(wszCommandline), debugstr_w(wszDir));
|
||||
|
||||
|
||||
/* separate out command line arguments from executable file name */
|
||||
if (!*sei_tmp.lpParameters) {
|
||||
|
@ -1181,7 +1184,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW psei, SHELL_ExecuteW32 execfu
|
|||
if (sei_tmp.lpIDList!=psei->lpIDList && sei_tmp.lpIDList)
|
||||
SHFree(sei_tmp.lpIDList);
|
||||
|
||||
TRACE("execfunc: retval=%d psei->hInstApp=%p\n", retval, psei->hInstApp);
|
||||
TRACE("execfunc: retval=%d sei_tmp.hInstApp=%p\n", retval, sei_tmp.hInstApp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,398 +0,0 @@
|
|||
/*
|
||||
* Systray
|
||||
*
|
||||
* Copyright 1999 Kai Morich <kai.morich@bigfoot.de>
|
||||
*
|
||||
* Manage the systray window. That it actually appears in the docking
|
||||
* area of KDE is handled in dlls/x11drv/window.c,
|
||||
* X11DRV_set_wm_hints using KWM_DOCKWINDOW.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "shlobj.h"
|
||||
#include "shellapi.h"
|
||||
#include "shell32_main.h"
|
||||
#include "commctrl.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||
|
||||
typedef struct SystrayItem {
|
||||
HWND hWnd;
|
||||
HWND hWndToolTip;
|
||||
NOTIFYICONDATAA notifyIcon;
|
||||
struct SystrayItem *nextTrayItem;
|
||||
} SystrayItem;
|
||||
|
||||
static SystrayItem *systray=NULL;
|
||||
static int firstSystray=TRUE; /* defer creation of window class until first systray item is created */
|
||||
|
||||
static BOOL SYSTRAY_Delete(PNOTIFYICONDATAA pnid);
|
||||
|
||||
|
||||
#define ICON_SIZE GetSystemMetrics(SM_CXSMICON)
|
||||
/* space around icon (forces icon to center of KDE systray area) */
|
||||
#define ICON_BORDER 4
|
||||
|
||||
|
||||
|
||||
static BOOL SYSTRAY_ItemIsEqual(PNOTIFYICONDATAA pnid1, PNOTIFYICONDATAA pnid2)
|
||||
{
|
||||
if (pnid1->hWnd != pnid2->hWnd) return FALSE;
|
||||
if (pnid1->uID != pnid2->uID) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK SYSTRAY_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
switch (message) {
|
||||
case WM_PAINT:
|
||||
{
|
||||
RECT rc;
|
||||
SystrayItem *ptrayItem = systray;
|
||||
|
||||
while (ptrayItem) {
|
||||
if (ptrayItem->hWnd==hWnd) {
|
||||
if (ptrayItem->notifyIcon.hIcon) {
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rc);
|
||||
if (!DrawIconEx(hdc, rc.left+ICON_BORDER, rc.top+ICON_BORDER, ptrayItem->notifyIcon.hIcon,
|
||||
ICON_SIZE, ICON_SIZE, 0, 0, DI_DEFAULTSIZE|DI_NORMAL)) {
|
||||
ERR("Paint(SystrayWindow %p) failed -> removing SystrayItem %p\n", hWnd, ptrayItem);
|
||||
SYSTRAY_Delete(&ptrayItem->notifyIcon);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
ptrayItem = ptrayItem->nextTrayItem;
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
{
|
||||
MSG msg;
|
||||
SystrayItem *ptrayItem = systray;
|
||||
|
||||
while ( ptrayItem ) {
|
||||
if (ptrayItem->hWnd == hWnd) {
|
||||
msg.hwnd=hWnd;
|
||||
msg.message=message;
|
||||
msg.wParam=wParam;
|
||||
msg.lParam=lParam;
|
||||
msg.time = GetMessageTime ();
|
||||
msg.pt.x = LOWORD(GetMessagePos ());
|
||||
msg.pt.y = HIWORD(GetMessagePos ());
|
||||
|
||||
SendMessageA(ptrayItem->hWndToolTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
|
||||
}
|
||||
ptrayItem = ptrayItem->nextTrayItem;
|
||||
}
|
||||
}
|
||||
/* fall through */
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
{
|
||||
SystrayItem *ptrayItem = systray;
|
||||
|
||||
while (ptrayItem) {
|
||||
if (ptrayItem->hWnd == hWnd) {
|
||||
if (ptrayItem->notifyIcon.hWnd && ptrayItem->notifyIcon.uCallbackMessage) {
|
||||
if (!PostMessageA(ptrayItem->notifyIcon.hWnd, ptrayItem->notifyIcon.uCallbackMessage,
|
||||
(WPARAM)ptrayItem->notifyIcon.uID, (LPARAM)message)) {
|
||||
ERR("PostMessage(SystrayWindow %p) failed -> removing SystrayItem %p\n", hWnd, ptrayItem);
|
||||
SYSTRAY_Delete(&ptrayItem->notifyIcon);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
ptrayItem = ptrayItem->nextTrayItem;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return (DefWindowProcA(hWnd, message, wParam, lParam));
|
||||
}
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL SYSTRAY_RegisterClass(void)
|
||||
{
|
||||
WNDCLASSA wc;
|
||||
|
||||
wc.style = CS_SAVEBITS|CS_DBLCLKS;
|
||||
wc.lpfnWndProc = (WNDPROC)SYSTRAY_WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = 0;
|
||||
wc.hIcon = 0;
|
||||
wc.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "WineSystray";
|
||||
|
||||
if (!RegisterClassA(&wc)) {
|
||||
ERR("RegisterClass(WineSystray) failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL SYSTRAY_ItemInit(SystrayItem *ptrayItem)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
/* Register the class if this is our first tray item. */
|
||||
if ( firstSystray ) {
|
||||
firstSystray = FALSE;
|
||||
if ( !SYSTRAY_RegisterClass() ) {
|
||||
ERR( "RegisterClass(WineSystray) failed\n" );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the window size. */
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = ICON_SIZE+2*ICON_BORDER;
|
||||
rect.bottom = ICON_SIZE+2*ICON_BORDER;
|
||||
|
||||
ZeroMemory( ptrayItem, sizeof(SystrayItem) );
|
||||
/* Create tray window for icon. */
|
||||
ptrayItem->hWnd = CreateWindowExA( WS_EX_TRAYWINDOW,
|
||||
"WineSystray", "Wine-Systray",
|
||||
WS_VISIBLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
rect.right-rect.left, rect.bottom-rect.top,
|
||||
0, 0, 0, 0 );
|
||||
if ( !ptrayItem->hWnd ) {
|
||||
ERR( "CreateWindow(WineSystray) failed\n" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create tooltip for icon. */
|
||||
ptrayItem->hWndToolTip = CreateWindowA( TOOLTIPS_CLASSA,NULL,TTS_ALWAYSTIP,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
ptrayItem->hWnd, 0, 0, 0 );
|
||||
if ( !ptrayItem->hWndToolTip ) {
|
||||
ERR( "CreateWindow(TOOLTIP) failed\n" );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void SYSTRAY_ItemTerm(SystrayItem *ptrayItem)
|
||||
{
|
||||
if(ptrayItem->notifyIcon.hIcon)
|
||||
DestroyIcon(ptrayItem->notifyIcon.hIcon);
|
||||
if(ptrayItem->hWndToolTip)
|
||||
DestroyWindow(ptrayItem->hWndToolTip);
|
||||
if(ptrayItem->hWnd)
|
||||
DestroyWindow(ptrayItem->hWnd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void SYSTRAY_ItemSetMessage(SystrayItem *ptrayItem, UINT uCallbackMessage)
|
||||
{
|
||||
ptrayItem->notifyIcon.uCallbackMessage = uCallbackMessage;
|
||||
}
|
||||
|
||||
|
||||
void SYSTRAY_ItemSetIcon(SystrayItem *ptrayItem, HICON hIcon)
|
||||
{
|
||||
if(ptrayItem->notifyIcon.hIcon)
|
||||
DestroyIcon(ptrayItem->notifyIcon.hIcon);
|
||||
ptrayItem->notifyIcon.hIcon = CopyIcon(hIcon);
|
||||
InvalidateRect(ptrayItem->hWnd, NULL, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void SYSTRAY_ItemSetTip(SystrayItem *ptrayItem, CHAR* szTip, int modify)
|
||||
{
|
||||
TTTOOLINFOA ti;
|
||||
|
||||
strncpy(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));
|
||||
ptrayItem->notifyIcon.szTip[sizeof(ptrayItem->notifyIcon.szTip)-1]=0;
|
||||
|
||||
ti.cbSize = sizeof(TTTOOLINFOA);
|
||||
ti.uFlags = 0;
|
||||
ti.hwnd = ptrayItem->hWnd;
|
||||
ti.hinst = 0;
|
||||
ti.uId = 0;
|
||||
ti.lpszText = ptrayItem->notifyIcon.szTip;
|
||||
ti.rect.left = 0;
|
||||
ti.rect.top = 0;
|
||||
ti.rect.right = ICON_SIZE+2*ICON_BORDER;
|
||||
ti.rect.bottom = ICON_SIZE+2*ICON_BORDER;
|
||||
|
||||
if(modify)
|
||||
SendMessageA(ptrayItem->hWndToolTip, TTM_UPDATETIPTEXTA, 0, (LPARAM)&ti);
|
||||
else
|
||||
SendMessageA(ptrayItem->hWndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
|
||||
}
|
||||
|
||||
|
||||
static BOOL SYSTRAY_Add(PNOTIFYICONDATAA pnid)
|
||||
{
|
||||
SystrayItem **ptrayItem = &systray;
|
||||
|
||||
/* Find last element. */
|
||||
while( *ptrayItem ) {
|
||||
if ( SYSTRAY_ItemIsEqual(pnid, &(*ptrayItem)->notifyIcon) )
|
||||
return FALSE;
|
||||
ptrayItem = &((*ptrayItem)->nextTrayItem);
|
||||
}
|
||||
/* Allocate SystrayItem for element and add to end of list. */
|
||||
(*ptrayItem) = ( SystrayItem *)malloc( sizeof(SystrayItem) );
|
||||
|
||||
/* Initialize and set data for the tray element. */
|
||||
SYSTRAY_ItemInit( (*ptrayItem) );
|
||||
(*ptrayItem)->notifyIcon.uID = pnid->uID; /* only needed for callback message */
|
||||
(*ptrayItem)->notifyIcon.hWnd = pnid->hWnd; /* only needed for callback message */
|
||||
SYSTRAY_ItemSetIcon (*ptrayItem, (pnid->uFlags&NIF_ICON) ?pnid->hIcon :0);
|
||||
SYSTRAY_ItemSetMessage(*ptrayItem, (pnid->uFlags&NIF_MESSAGE)?pnid->uCallbackMessage:0);
|
||||
SYSTRAY_ItemSetTip (*ptrayItem, (pnid->uFlags&NIF_TIP) ?pnid->szTip :"", FALSE);
|
||||
|
||||
TRACE("%p: %p %s\n", (*ptrayItem), (*ptrayItem)->notifyIcon.hWnd,
|
||||
(*ptrayItem)->notifyIcon.szTip);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static BOOL SYSTRAY_Modify(PNOTIFYICONDATAA pnid)
|
||||
{
|
||||
SystrayItem *ptrayItem = systray;
|
||||
|
||||
while ( ptrayItem ) {
|
||||
if ( SYSTRAY_ItemIsEqual(pnid, &ptrayItem->notifyIcon) ) {
|
||||
if (pnid->uFlags & NIF_ICON)
|
||||
SYSTRAY_ItemSetIcon(ptrayItem, pnid->hIcon);
|
||||
if (pnid->uFlags & NIF_MESSAGE)
|
||||
SYSTRAY_ItemSetMessage(ptrayItem, pnid->uCallbackMessage);
|
||||
if (pnid->uFlags & NIF_TIP)
|
||||
SYSTRAY_ItemSetTip(ptrayItem, pnid->szTip, TRUE);
|
||||
|
||||
TRACE("%p: %p %s\n", ptrayItem, ptrayItem->notifyIcon.hWnd, ptrayItem->notifyIcon.szTip);
|
||||
return TRUE;
|
||||
}
|
||||
ptrayItem = ptrayItem->nextTrayItem;
|
||||
}
|
||||
return FALSE; /* not found */
|
||||
}
|
||||
|
||||
|
||||
static BOOL SYSTRAY_Delete(PNOTIFYICONDATAA pnid)
|
||||
{
|
||||
SystrayItem **ptrayItem = &systray;
|
||||
|
||||
while (*ptrayItem) {
|
||||
if (SYSTRAY_ItemIsEqual(pnid, &(*ptrayItem)->notifyIcon)) {
|
||||
SystrayItem *next = (*ptrayItem)->nextTrayItem;
|
||||
TRACE("%p: %p %s\n", *ptrayItem, (*ptrayItem)->notifyIcon.hWnd, (*ptrayItem)->notifyIcon.szTip);
|
||||
SYSTRAY_ItemTerm(*ptrayItem);
|
||||
|
||||
free(*ptrayItem);
|
||||
*ptrayItem = next;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
ptrayItem = &((*ptrayItem)->nextTrayItem);
|
||||
}
|
||||
|
||||
return FALSE; /* not found */
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
*/
|
||||
BOOL SYSTRAY_Init(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Shell_NotifyIcon [SHELL32.296]
|
||||
* Shell_NotifyIconA [SHELL32.297]
|
||||
*/
|
||||
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid )
|
||||
{
|
||||
BOOL flag=FALSE;
|
||||
TRACE("enter %p %d %ld\n", pnid->hWnd, pnid->uID, dwMessage);
|
||||
switch(dwMessage) {
|
||||
case NIM_ADD:
|
||||
flag = SYSTRAY_Add(pnid);
|
||||
break;
|
||||
case NIM_MODIFY:
|
||||
flag = SYSTRAY_Modify(pnid);
|
||||
break;
|
||||
case NIM_DELETE:
|
||||
flag = SYSTRAY_Delete(pnid);
|
||||
break;
|
||||
}
|
||||
TRACE("leave %p %d %ld=%d\n", pnid->hWnd, pnid->uID, dwMessage, flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Shell_NotifyIconW [SHELL32.298]
|
||||
*/
|
||||
BOOL WINAPI Shell_NotifyIconW (DWORD dwMessage, PNOTIFYICONDATAW pnid )
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
PNOTIFYICONDATAA p = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFYICONDATAA));
|
||||
memcpy(p, pnid, sizeof(NOTIFYICONDATAA));
|
||||
WideCharToMultiByte( CP_ACP, 0, pnid->szTip, -1, p->szTip, sizeof(p->szTip), NULL, NULL );
|
||||
p->szTip[sizeof(p->szTip)-1] = 0;
|
||||
|
||||
ret = Shell_NotifyIconA(dwMessage, p );
|
||||
|
||||
HeapFree(GetProcessHeap(),0,p);
|
||||
return ret;
|
||||
}
|
Loading…
Reference in a new issue