4 * Copyright 1999 Kai Morich <kai.morich@bigfoot.de>
5 * Copyright 2004 Mike Hearn, for CodeWeavers
6 * Copyright 2005 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(systray);
39 const static WCHAR classname[] = /* Shell_TrayWnd */ {'S','h','e','l','l','_','T','r','a','y','W','n','d','\0'};
41 /*************************************************************************
42 * Shell_NotifyIcon [SHELL32.296]
43 * Shell_NotifyIconA [SHELL32.297]
45 BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
49 nidW.cbSize = sizeof(nidW);
50 nidW.hWnd = pnid->hWnd;
52 nidW.uFlags = pnid->uFlags;
53 nidW.uCallbackMessage = pnid->uCallbackMessage;
54 nidW.hIcon = pnid->hIcon;
57 MultiByteToWideChar(CP_ACP, 0, pnid->szTip, sizeof(pnid->szTip), nidW.szTip, sizeof(nidW.szTip));
59 nidW.dwState = pnid->dwState;
60 nidW.dwStateMask = pnid->dwStateMask;
63 MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, sizeof(pnid->szInfo), nidW.szInfo, sizeof(nidW.szInfo));
65 nidW.u.uTimeout = pnid->u.uTimeout;
68 MultiByteToWideChar(CP_ACP, 0, pnid->szInfoTitle, sizeof(pnid->szInfoTitle), nidW.szInfoTitle, sizeof(nidW.szInfoTitle));
70 nidW.dwInfoFlags = pnid->dwInfoFlags;
72 return Shell_NotifyIconW(dwMessage, &nidW);
75 /*************************************************************************
76 * Shell_NotifyIconW [SHELL32.298]
78 BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
83 TRACE("dwMessage = %ld\n", dwMessage);
85 tray = FindWindowExW(0, NULL, classname, NULL);
86 if (!tray) return FALSE;
88 cds.dwData = dwMessage;
90 /* FIXME: if statement only needed because we don't support interprocess
92 if (nid->uFlags & NIF_ICON)
101 if (!GetIconInfo(nid->hIcon, &iconinfo))
104 if (!GetObjectW(iconinfo.hbmMask, sizeof(bmMask), &bmMask) ||
105 !GetObjectW(iconinfo.hbmColor, sizeof(bmColour), &bmColour))
107 DeleteObject(iconinfo.hbmMask);
108 DeleteObject(iconinfo.hbmColor);
112 cbMaskBits = (bmMask.bmPlanes * bmMask.bmWidth * bmMask.bmHeight * bmMask.bmBitsPixel) / 8;
113 cbColourBits = (bmColour.bmPlanes * bmColour.bmWidth * bmColour.bmHeight * bmColour.bmBitsPixel) / 8;
114 cds.cbData = sizeof(*nid) + 2*sizeof(BITMAP) + cbMaskBits + cbColourBits;
115 buffer = HeapAlloc(GetProcessHeap(), 0, cds.cbData);
118 DeleteObject(iconinfo.hbmMask);
119 DeleteObject(iconinfo.hbmColor);
124 memcpy(buffer, nid, sizeof(*nid));
125 buffer += sizeof(*nid);
126 memcpy(buffer, &bmMask, sizeof(bmMask));
127 buffer += sizeof(bmMask);
128 memcpy(buffer, &bmColour, sizeof(bmColour));
129 buffer += sizeof(bmColour);
130 GetBitmapBits(iconinfo.hbmMask, cbMaskBits, buffer);
131 buffer += cbMaskBits;
132 GetBitmapBits(iconinfo.hbmColor, cbColourBits, buffer);
133 buffer += cbColourBits;
135 DeleteObject(iconinfo.hbmMask);
136 DeleteObject(iconinfo.hbmColor);
141 cds.cbData = sizeof(*nid);
145 SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
147 /* FIXME: if statement only needed because we don't support interprocess
149 if (nid->uFlags & NIF_ICON)
150 HeapFree(GetProcessHeap(), 0, cds.lpData);