wined3d: Spelling fixes and downgrade a FIXME to a TRACE.
[wine/wine-kai.git] / dlls / shell32 / systray.c
blob32213cb9874cc38681870a241a8623131987bad6
1 /*
2 * Systray handling
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winnls.h"
32 #include "winuser.h"
33 #include "shellapi.h"
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)
47 NOTIFYICONDATAW nidW;
49 nidW.cbSize = sizeof(nidW);
50 nidW.hWnd = pnid->hWnd;
51 nidW.uID = pnid->uID;
52 nidW.uFlags = pnid->uFlags;
53 nidW.uCallbackMessage = pnid->uCallbackMessage;
54 nidW.hIcon = pnid->hIcon;
56 /* szTip */
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;
62 /* szInfo */
63 MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, sizeof(pnid->szInfo), nidW.szInfo, sizeof(nidW.szInfo));
65 nidW.u.uTimeout = pnid->u.uTimeout;
67 /* szInfoTitle */
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)
80 HWND tray;
81 COPYDATASTRUCT cds;
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
91 * icon handles */
92 if (nid->uFlags & NIF_ICON)
94 ICONINFO iconinfo;
95 char *buffer;
96 BITMAP bmMask;
97 BITMAP bmColour;
98 LONG cbMaskBits;
99 LONG cbColourBits;
101 if (!GetIconInfo(nid->hIcon, &iconinfo))
102 goto noicon;
104 if (!GetObjectW(iconinfo.hbmMask, sizeof(bmMask), &bmMask) ||
105 !GetObjectW(iconinfo.hbmColor, sizeof(bmColour), &bmColour))
107 DeleteObject(iconinfo.hbmMask);
108 DeleteObject(iconinfo.hbmColor);
109 goto noicon;
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);
116 if (!buffer)
118 DeleteObject(iconinfo.hbmMask);
119 DeleteObject(iconinfo.hbmColor);
120 return FALSE;
122 cds.lpData = buffer;
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);
138 else
140 noicon:
141 cds.cbData = sizeof(*nid);
142 cds.lpData = nid;
145 SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
147 /* FIXME: if statement only needed because we don't support interprocess
148 * icon handles */
149 if (nid->uFlags & NIF_ICON)
150 HeapFree(GetProcessHeap(), 0, cds.lpData);
152 return TRUE;