shell32: Move SHAppBarMessage implementation from shell32 to explorer.
[wine/multimedia.git] / programs / explorer / appbar.c
blob17c0b0a635caee012f80cd6659fe815a51d32da5
1 /*
2 * SHAppBarMessage implementation
4 * Copyright 2008 Vincent Povirk for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/unicode.h"
23 #include <windows.h>
24 #include <wine/debug.h>
25 #include "explorer_private.h"
27 #include "wine/list.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(appbar);
31 struct appbar_cmd
33 HANDLE return_map;
34 DWORD return_process;
35 APPBARDATA abd;
38 struct appbar_response
40 UINT_PTR result;
41 RECT rc;
44 static HWND appbarmsg_window = NULL;
46 static UINT_PTR handle_appbarmessage(DWORD msg, PAPPBARDATA abd)
48 switch (msg)
50 case ABM_NEW:
51 WINE_FIXME("SHAppBarMessage(ABM_NEW, hwnd=%p, callback=%x): stub\n", abd->hWnd, abd->uCallbackMessage);
52 return TRUE;
53 case ABM_REMOVE:
54 WINE_FIXME("SHAppBarMessage(ABM_REMOVE, hwnd=%p): stub\n", abd->hWnd);
55 return TRUE;
56 case ABM_QUERYPOS:
57 WINE_FIXME("SHAppBarMessage(ABM_QUERYPOS, hwnd=%p, edge=%x, rc=%s): stub\n", abd->hWnd, abd->uEdge, wine_dbgstr_rect(&abd->rc));
58 return TRUE;
59 case ABM_SETPOS:
60 WINE_FIXME("SHAppBarMessage(ABM_SETPOS, hwnd=%p, edge=%x, rc=%s): stub\n", abd->hWnd, abd->uEdge, wine_dbgstr_rect(&abd->rc));
61 return TRUE;
62 case ABM_GETSTATE:
63 WINE_FIXME("SHAppBarMessage(ABM_GETSTATE): stub\n");
64 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
65 case ABM_GETTASKBARPOS:
66 WINE_FIXME("SHAppBarMessage(ABM_GETTASKBARPOS, hwnd=%p): stub\n", abd->hWnd);
67 return FALSE;
68 case ABM_ACTIVATE:
69 WINE_FIXME("SHAppBarMessage(ABM_ACTIVATE, hwnd=%p, lparam=%lx): stub\n", abd->hWnd, abd->lParam);
70 return TRUE;
71 case ABM_GETAUTOHIDEBAR:
72 WINE_FIXME("SHAppBarMessage(ABM_GETAUTOHIDEBAR, hwnd=%p, edge=%x): stub\n", abd->hWnd, abd->uEdge);
73 return 0;
74 case ABM_SETAUTOHIDEBAR:
75 WINE_FIXME("SHAppBarMessage(ABM_SETAUTOHIDEBAR, hwnd=%p, edge=%x, lparam=%lx): stub\n", abd->hWnd, abd->uEdge, abd->lParam);
76 return TRUE;
77 case ABM_WINDOWPOSCHANGED:
78 WINE_FIXME("SHAppBarMessage(ABM_WINDOWPOSCHANGED, hwnd=%p): stub\n", abd->hWnd);
79 return TRUE;
80 default:
81 WINE_FIXME("SHAppBarMessage(%x) unimplemented\n", msg);
82 return FALSE;
86 LRESULT CALLBACK appbar_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
88 switch (msg)
90 case WM_COPYDATA:
92 COPYDATASTRUCT* cds;
93 struct appbar_cmd cmd;
94 UINT_PTR result;
95 HANDLE return_hproc;
96 HANDLE return_map;
97 LPVOID return_view;
98 struct appbar_response* response;
100 cds = (COPYDATASTRUCT*)lparam;
101 if (cds->cbData != sizeof(struct appbar_cmd))
102 return TRUE;
103 CopyMemory(&cmd, cds->lpData, cds->cbData);
105 result = handle_appbarmessage(cds->dwData, &cmd.abd);
107 return_hproc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, cmd.return_process);
108 if (return_hproc == NULL)
110 WINE_ERR("couldn't open calling process\n");
111 return TRUE;
114 if (!DuplicateHandle(return_hproc, cmd.return_map, GetCurrentProcess(), &return_map, 0, FALSE, DUPLICATE_SAME_ACCESS))
116 WINE_ERR("couldn't duplicate handle\n");
117 CloseHandle(return_hproc);
118 return TRUE;
120 CloseHandle(return_hproc);
122 return_view = MapViewOfFile(return_map, FILE_MAP_WRITE, 0, 0, sizeof(struct appbar_response));
124 if (return_view)
126 response = (struct appbar_response*)return_view;
127 response->result = result;
128 response->rc = cmd.abd.rc;
130 UnmapViewOfFile(return_view);
132 else
133 WINE_ERR("couldn't map view of file\n");
135 CloseHandle(return_map);
136 return TRUE;
138 default:
139 break;
142 return DefWindowProcW(hwnd, msg, wparam, lparam);
145 void initialize_appbar(void)
147 WNDCLASSEXW class;
148 static const WCHAR classname[] = {'W','i','n','e','A','p','p','B','a','r',0};
150 /* register the appbar window class */
151 ZeroMemory(&class, sizeof(class));
152 class.cbSize = sizeof(class);
153 class.lpfnWndProc = appbar_wndproc;
154 class.hInstance = NULL;
155 class.lpszClassName = classname;
157 if (!RegisterClassExW(&class))
159 WINE_ERR("Could not register appbar message window class\n");
160 return;
163 appbarmsg_window = CreateWindowW(classname, classname, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
164 if (!appbarmsg_window)
166 WINE_ERR("Could not create appbar message window\n");
167 return;