[PSDK] Add missing TB_SETBOUNDINGSIZE.
[reactos.git] / reactos / dll / win32 / comctl32 / icon.c
1 /*
2 * Comctl32 Icon functions
3 *
4 * Copyright 2014 Michael Müller
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "comctl32.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
24
25 HRESULT WINAPI
26 LoadIconMetric (HINSTANCE hinst, PCWSTR name, INT size, HICON *icon)
27 {
28 INT width, height;
29
30 TRACE("(%p %s %d %p)\n", hinst, debugstr_w(name), size, icon);
31
32 if (!icon)
33 return E_INVALIDARG;
34
35 /* windows sets it to zero in a case of failure */
36 *icon = NULL;
37
38 if (!name)
39 return E_INVALIDARG;
40
41 if (size == LIM_SMALL)
42 {
43 width = GetSystemMetrics( SM_CXSMICON );
44 height = GetSystemMetrics( SM_CYSMICON );
45 }
46 else if (size == LIM_LARGE)
47 {
48 width = GetSystemMetrics( SM_CXICON );
49 height = GetSystemMetrics( SM_CYICON );
50 }
51 else
52 return E_INVALIDARG;
53
54 *icon = LoadImageW( hinst, name, IMAGE_ICON, width, height, LR_SHARED );
55 if (*icon)
56 return S_OK;
57
58 return HRESULT_FROM_WIN32(GetLastError());
59 }