1999-12-12 00:54:59 +01:00
|
|
|
/*
|
|
|
|
* Systray
|
|
|
|
*
|
|
|
|
* Copyright 1999 Kai Morich <kai.morich@bigfoot.de>
|
|
|
|
*
|
|
|
|
* Manage the systray window. That it actually appears in the docking
|
2004-01-02 21:12:51 +01:00
|
|
|
* area of KDE is handled in dlls/x11drv/window.c,
|
|
|
|
* X11DRV_set_wm_hints using KWM_DOCKWINDOW.
|
1999-12-12 00:54:59 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* 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
|
1999-12-12 00:54:59 +01:00
|
|
|
*/
|
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-12-12 00:54:59 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winbase.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "shlobj.h"
|
1999-12-12 00:54:59 +01:00
|
|
|
#include "shellapi.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "commctrl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-12-12 00:54:59 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-12-12 00:54:59 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
typedef struct SystrayItem {
|
2000-02-07 17:02:41 +01:00
|
|
|
HWND hWnd;
|
|
|
|
HWND hWndToolTip;
|
|
|
|
NOTIFYICONDATAA notifyIcon;
|
2000-08-20 20:48:37 +02:00
|
|
|
struct SystrayItem *nextTrayItem;
|
|
|
|
} SystrayItem;
|
1999-12-12 00:54:59 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
static SystrayItem *systray=NULL;
|
|
|
|
static int firstSystray=TRUE; /* defer creation of window class until first systray item is created */
|
1999-12-12 00:54:59 +01:00
|
|
|
|
|
|
|
static BOOL SYSTRAY_Delete(PNOTIFYICONDATAA pnid);
|
|
|
|
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
#define ICON_SIZE GetSystemMetrics(SM_CXSMICON)
|
|
|
|
/* space around icon (forces icon to center of KDE systray area) */
|
|
|
|
#define ICON_BORDER 4
|
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
static BOOL SYSTRAY_ItemIsEqual(PNOTIFYICONDATAA pnid1, PNOTIFYICONDATAA pnid2)
|
|
|
|
{
|
|
|
|
if (pnid1->hWnd != pnid2->hWnd) return FALSE;
|
|
|
|
if (pnid1->uID != pnid2->uID) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-12-12 00:54:59 +01:00
|
|
|
|
|
|
|
static LRESULT CALLBACK SYSTRAY_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
RECT rc;
|
2000-08-20 20:48:37 +02:00
|
|
|
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)) {
|
2002-11-22 00:56:42 +01:00
|
|
|
ERR("Paint(SystrayWindow %p) failed -> removing SystrayItem %p\n", hWnd, ptrayItem);
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_Delete(&ptrayItem->notifyIcon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2000-02-07 17:02:41 +01:00
|
|
|
}
|
|
|
|
ptrayItem = ptrayItem->nextTrayItem;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
EndPaint(hWnd, &ps);
|
2000-02-07 17:02:41 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
{
|
|
|
|
MSG msg;
|
2000-08-20 20:48:37 +02:00
|
|
|
SystrayItem *ptrayItem = systray;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
while ( ptrayItem ) {
|
|
|
|
if (ptrayItem->hWnd == hWnd) {
|
2000-02-07 17:02:41 +01:00
|
|
|
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;
|
|
|
|
}
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
2001-08-21 19:07:17 +02:00
|
|
|
/* fall through */
|
2000-02-07 17:02:41 +01:00
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
{
|
2000-08-20 20:48:37 +02:00
|
|
|
SystrayItem *ptrayItem = systray;
|
|
|
|
|
|
|
|
while (ptrayItem) {
|
|
|
|
if (ptrayItem->hWnd == hWnd) {
|
|
|
|
if (ptrayItem->notifyIcon.hWnd && ptrayItem->notifyIcon.uCallbackMessage) {
|
2000-02-07 17:02:41 +01:00
|
|
|
if (!PostMessageA(ptrayItem->notifyIcon.hWnd, ptrayItem->notifyIcon.uCallbackMessage,
|
2000-08-20 20:48:37 +02:00
|
|
|
(WPARAM)ptrayItem->notifyIcon.uID, (LPARAM)message)) {
|
2002-11-22 00:56:42 +01:00
|
|
|
ERR("PostMessage(SystrayWindow %p) failed -> removing SystrayItem %p\n", hWnd, ptrayItem);
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_Delete(&ptrayItem->notifyIcon);
|
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
}
|
2000-08-20 20:48:37 +02:00
|
|
|
break;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
ptrayItem = ptrayItem->nextTrayItem;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
default:
|
|
|
|
return (DefWindowProcA(hWnd, message, wParam, lParam));
|
2000-02-07 17:02:41 +01:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
BOOL SYSTRAY_RegisterClass(void)
|
1999-12-12 00:54:59 +01:00
|
|
|
{
|
|
|
|
WNDCLASSA wc;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2002-11-24 23:16:29 +01:00
|
|
|
wc.style = CS_SAVEBITS|CS_DBLCLKS;
|
1999-12-12 00:54:59 +01:00
|
|
|
wc.lpfnWndProc = (WNDPROC)SYSTRAY_WndProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = 0;
|
2000-08-20 20:48:37 +02:00
|
|
|
wc.hIcon = 0;
|
2003-09-10 05:56:47 +02:00
|
|
|
wc.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
|
2003-10-24 06:23:37 +02:00
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
1999-12-12 00:54:59 +01:00
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = "WineSystray";
|
2000-02-07 17:02:41 +01:00
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
if (!RegisterClassA(&wc)) {
|
|
|
|
ERR("RegisterClass(WineSystray) failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
BOOL SYSTRAY_ItemInit(SystrayItem *ptrayItem)
|
2000-02-07 17:02:41 +01:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
/* Register the class if this is our first tray item. */
|
2000-08-20 20:48:37 +02:00
|
|
|
if ( firstSystray ) {
|
|
|
|
firstSystray = FALSE;
|
|
|
|
if ( !SYSTRAY_RegisterClass() ) {
|
2000-02-07 17:02:41 +01:00
|
|
|
ERR( "RegisterClass(WineSystray) failed\n" );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the window size. */
|
1999-12-12 00:54:59 +01:00
|
|
|
rect.left = 0;
|
|
|
|
rect.top = 0;
|
2000-08-20 20:48:37 +02:00
|
|
|
rect.right = ICON_SIZE+2*ICON_BORDER;
|
|
|
|
rect.bottom = ICON_SIZE+2*ICON_BORDER;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
ZeroMemory( ptrayItem, sizeof(SystrayItem) );
|
2000-02-07 17:02:41 +01:00
|
|
|
/* 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 );
|
2000-08-20 20:48:37 +02:00
|
|
|
if ( !ptrayItem->hWnd ) {
|
2000-02-07 17:02:41 +01:00
|
|
|
ERR( "CreateWindow(WineSystray) failed\n" );
|
1999-12-12 00:54:59 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
|
|
|
|
/* 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 );
|
2000-08-20 20:48:37 +02:00
|
|
|
if ( !ptrayItem->hWndToolTip ) {
|
2000-02-07 17:02:41 +01:00
|
|
|
ERR( "CreateWindow(TOOLTIP) failed\n" );
|
1999-12-12 00:54:59 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
static void SYSTRAY_ItemTerm(SystrayItem *ptrayItem)
|
1999-12-12 00:54:59 +01:00
|
|
|
{
|
2000-09-06 21:40:44 +02:00
|
|
|
if(ptrayItem->notifyIcon.hIcon)
|
2002-06-01 01:06:46 +02:00
|
|
|
DestroyIcon(ptrayItem->notifyIcon.hIcon);
|
2000-08-20 20:48:37 +02:00
|
|
|
if(ptrayItem->hWndToolTip)
|
|
|
|
DestroyWindow(ptrayItem->hWndToolTip);
|
|
|
|
if(ptrayItem->hWnd)
|
|
|
|
DestroyWindow(ptrayItem->hWnd);
|
|
|
|
return;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
void SYSTRAY_ItemSetMessage(SystrayItem *ptrayItem, UINT uCallbackMessage)
|
1999-12-12 00:54:59 +01:00
|
|
|
{
|
2000-08-20 20:48:37 +02:00
|
|
|
ptrayItem->notifyIcon.uCallbackMessage = uCallbackMessage;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
void SYSTRAY_ItemSetIcon(SystrayItem *ptrayItem, HICON hIcon)
|
|
|
|
{
|
2004-02-27 22:30:16 +01:00
|
|
|
if(ptrayItem->notifyIcon.hIcon)
|
|
|
|
DestroyIcon(ptrayItem->notifyIcon.hIcon);
|
2000-09-06 21:40:44 +02:00
|
|
|
ptrayItem->notifyIcon.hIcon = CopyIcon(hIcon);
|
2000-08-20 20:48:37 +02:00
|
|
|
InvalidateRect(ptrayItem->hWnd, NULL, TRUE);
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
|
|
|
|
void SYSTRAY_ItemSetTip(SystrayItem *ptrayItem, CHAR* szTip, int modify)
|
1999-12-12 00:54:59 +01:00
|
|
|
{
|
2000-02-07 17:02:41 +01:00
|
|
|
TTTOOLINFOA ti;
|
|
|
|
|
|
|
|
strncpy(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));
|
|
|
|
ptrayItem->notifyIcon.szTip[sizeof(ptrayItem->notifyIcon.szTip)-1]=0;
|
1999-12-12 00:54:59 +01:00
|
|
|
|
|
|
|
ti.cbSize = sizeof(TTTOOLINFOA);
|
2000-02-07 17:02:41 +01:00
|
|
|
ti.uFlags = 0;
|
|
|
|
ti.hwnd = ptrayItem->hWnd;
|
|
|
|
ti.hinst = 0;
|
2000-08-20 20:48:37 +02:00
|
|
|
ti.uId = 0;
|
2000-02-07 17:02:41 +01:00
|
|
|
ti.lpszText = ptrayItem->notifyIcon.szTip;
|
|
|
|
ti.rect.left = 0;
|
|
|
|
ti.rect.top = 0;
|
2000-08-20 20:48:37 +02:00
|
|
|
ti.rect.right = ICON_SIZE+2*ICON_BORDER;
|
|
|
|
ti.rect.bottom = ICON_SIZE+2*ICON_BORDER;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
if(modify)
|
|
|
|
SendMessageA(ptrayItem->hWndToolTip, TTM_UPDATETIPTEXTA, 0, (LPARAM)&ti);
|
|
|
|
else
|
|
|
|
SendMessageA(ptrayItem->hWndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
2000-02-07 17:02:41 +01:00
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
static BOOL SYSTRAY_Add(PNOTIFYICONDATAA pnid)
|
|
|
|
{
|
2000-08-20 20:48:37 +02:00
|
|
|
SystrayItem **ptrayItem = &systray;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
/* Find last element. */
|
|
|
|
while( *ptrayItem ) {
|
|
|
|
if ( SYSTRAY_ItemIsEqual(pnid, &(*ptrayItem)->notifyIcon) )
|
1999-12-12 00:54:59 +01:00
|
|
|
return FALSE;
|
2000-02-07 17:02:41 +01:00
|
|
|
ptrayItem = &((*ptrayItem)->nextTrayItem);
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
2000-08-20 20:48:37 +02:00
|
|
|
/* Allocate SystrayItem for element and add to end of list. */
|
2004-08-09 21:46:47 +02:00
|
|
|
(*ptrayItem) = HeapAlloc(GetProcessHeap(),0,sizeof(SystrayItem));
|
2000-02-07 17:02:41 +01:00
|
|
|
|
|
|
|
/* Initialize and set data for the tray element. */
|
2000-08-20 20:48:37 +02:00
|
|
|
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);
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p: %p %s\n", (*ptrayItem), (*ptrayItem)->notifyIcon.hWnd,
|
2000-08-20 20:48:37 +02:00
|
|
|
(*ptrayItem)->notifyIcon.szTip);
|
1999-12-12 00:54:59 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
static BOOL SYSTRAY_Modify(PNOTIFYICONDATAA pnid)
|
|
|
|
{
|
2000-08-20 20:48:37 +02:00
|
|
|
SystrayItem *ptrayItem = systray;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
while ( ptrayItem ) {
|
|
|
|
if ( SYSTRAY_ItemIsEqual(pnid, &ptrayItem->notifyIcon) ) {
|
1999-12-12 00:54:59 +01:00
|
|
|
if (pnid->uFlags & NIF_ICON)
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_ItemSetIcon(ptrayItem, pnid->hIcon);
|
1999-12-12 00:54:59 +01:00
|
|
|
if (pnid->uFlags & NIF_MESSAGE)
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_ItemSetMessage(ptrayItem, pnid->uCallbackMessage);
|
1999-12-12 00:54:59 +01:00
|
|
|
if (pnid->uFlags & NIF_TIP)
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_ItemSetTip(ptrayItem, pnid->szTip, TRUE);
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p: %p %s\n", ptrayItem, ptrayItem->notifyIcon.hWnd, ptrayItem->notifyIcon.szTip);
|
1999-12-12 00:54:59 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
ptrayItem = ptrayItem->nextTrayItem;
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
return FALSE; /* not found */
|
|
|
|
}
|
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
static BOOL SYSTRAY_Delete(PNOTIFYICONDATAA pnid)
|
|
|
|
{
|
2000-08-20 20:48:37 +02:00
|
|
|
SystrayItem **ptrayItem = &systray;
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2000-08-20 20:48:37 +02:00
|
|
|
while (*ptrayItem) {
|
|
|
|
if (SYSTRAY_ItemIsEqual(pnid, &(*ptrayItem)->notifyIcon)) {
|
|
|
|
SystrayItem *next = (*ptrayItem)->nextTrayItem;
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p: %p %s\n", *ptrayItem, (*ptrayItem)->notifyIcon.hWnd, (*ptrayItem)->notifyIcon.szTip);
|
2000-08-20 20:48:37 +02:00
|
|
|
SYSTRAY_ItemTerm(*ptrayItem);
|
2000-02-07 17:02:41 +01:00
|
|
|
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,*ptrayItem);
|
2000-02-07 17:02:41 +01:00
|
|
|
*ptrayItem = next;
|
|
|
|
|
1999-12-12 00:54:59 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2000-02-07 17:02:41 +01:00
|
|
|
ptrayItem = &((*ptrayItem)->nextTrayItem);
|
1999-12-12 00:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; /* not found */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL SYSTRAY_Init(void)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* Shell_NotifyIcon [SHELL32.296]
|
|
|
|
* Shell_NotifyIconA [SHELL32.297]
|
1999-12-12 00:54:59 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid )
|
|
|
|
{
|
|
|
|
BOOL flag=FALSE;
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("enter %p %d %ld\n", pnid->hWnd, pnid->uID, dwMessage);
|
1999-12-12 00:54:59 +01:00
|
|
|
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;
|
|
|
|
}
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("leave %p %d %ld=%d\n", pnid->hWnd, pnid->uID, dwMessage, flag);
|
1999-12-12 00:54:59 +01:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:33:56 +01:00
|
|
|
/*************************************************************************
|
2000-09-19 04:43:00 +02:00
|
|
|
* Shell_NotifyIconW [SHELL32.298]
|
2000-01-04 01:33:56 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI Shell_NotifyIconW (DWORD dwMessage, PNOTIFYICONDATAW pnid )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
PNOTIFYICONDATAA p = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFYICONDATAA));
|
|
|
|
memcpy(p, pnid, sizeof(NOTIFYICONDATAA));
|
2000-11-28 23:40:56 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, pnid->szTip, -1, p->szTip, sizeof(p->szTip), NULL, NULL );
|
|
|
|
p->szTip[sizeof(p->szTip)-1] = 0;
|
2000-01-04 01:33:56 +01:00
|
|
|
|
|
|
|
ret = Shell_NotifyIconA(dwMessage, p );
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,p);
|
|
|
|
return ret;
|
|
|
|
}
|