mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
comctl32-LoadIconMetric: Update patchset and fix loading of ico files.
This commit is contained in:
parent
1928fdacbe
commit
2a080a1262
@ -0,0 +1,65 @@
|
||||
From a8bbc313edc840beb43636d634354f8d281ddd0f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 7 Aug 2014 01:41:25 +0200
|
||||
Subject: comctl32: Add semi-stub implementation for LoadIconWithScaleDown.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Michael Müller <michael@fds-team.de>
|
||||
---
|
||||
dlls/comctl32/commctrl.c | 18 +++++++++++++++---
|
||||
include/commctrl.h | 2 +-
|
||||
2 files changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
|
||||
index e18c27d..97656a5 100644
|
||||
--- a/dlls/comctl32/commctrl.c
|
||||
+++ b/dlls/comctl32/commctrl.c
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright 1997 Dimitrie O. Paun
|
||||
* Copyright 1998,2000 Eric Kohl
|
||||
+ * Copyright 2014-2015 Michael Müller
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -1641,8 +1642,19 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnBu
|
||||
/***********************************************************************
|
||||
* LoadIconWithScaleDown [COMCTL32.@]
|
||||
*/
|
||||
-HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, PCWSTR name, int cx, int cy, HICON *icon)
|
||||
+HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, const WCHAR *name, int cx, int cy, HICON *icon)
|
||||
{
|
||||
- FIXME("stub: %p %s %d %d %p\n", hinst, wine_dbgstr_w(name), cx, cy, icon);
|
||||
- return E_NOTIMPL;
|
||||
+ TRACE("(%p, %s, %d, %d, %p)\n", hinst, debugstr_w(name), cx, cy, icon);
|
||||
+
|
||||
+ *icon = NULL;
|
||||
+
|
||||
+ if (!name)
|
||||
+ return E_INVALIDARG;
|
||||
+
|
||||
+ *icon = LoadImageW(hinst, name, IMAGE_ICON, cx, cy,
|
||||
+ (hinst || IS_INTRESOURCE(name)) ? 0 : LR_LOADFROMFILE);
|
||||
+ if (!*icon)
|
||||
+ return HRESULT_FROM_WIN32(GetLastError());
|
||||
+
|
||||
+ return S_OK;
|
||||
}
|
||||
diff --git a/include/commctrl.h b/include/commctrl.h
|
||||
index 0bcaeb6..0ed0997 100644
|
||||
--- a/include/commctrl.h
|
||||
+++ b/include/commctrl.h
|
||||
@@ -42,7 +42,7 @@ BOOL WINAPI InitCommonControlsEx (const INITCOMMONCONTROLSEX*);
|
||||
LANGID WINAPI GetMUILanguage (VOID);
|
||||
VOID WINAPI InitMUILanguage (LANGID uiLang);
|
||||
|
||||
-HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE, PCWSTR, int, int, HICON *);
|
||||
+HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE, const WCHAR *, int, int, HICON *);
|
||||
|
||||
#define COMCTL32_VERSION 5 /* dll version */
|
||||
|
||||
--
|
||||
2.5.1
|
||||
|
@ -1,103 +0,0 @@
|
||||
From 74254e3904454c5d088bf400d3d58107aa2b138b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 7 Aug 2014 01:41:25 +0200
|
||||
Subject: comctl32: Implement LoadIconMetric function.
|
||||
|
||||
Changes by Alistair Leslie-Hughes:
|
||||
* Moved LoadIconMetric to commctrl.c
|
||||
* Changed INT, PCWSTR type
|
||||
* Added function to include/commctrl.h
|
||||
---
|
||||
dlls/comctl32/comctl32.spec | 1 +
|
||||
dlls/comctl32/commctrl.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
||||
include/commctrl.h | 7 +++++++
|
||||
3 files changed, 48 insertions(+)
|
||||
|
||||
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
|
||||
index 1e92e5f..e61dfbf 100644
|
||||
--- a/dlls/comctl32/comctl32.spec
|
||||
+++ b/dlls/comctl32/comctl32.spec
|
||||
@@ -88,6 +88,7 @@
|
||||
375 stdcall -noname -private StrCSpnIW(wstr wstr)
|
||||
376 stdcall -noname -private IntlStrEqWorkerA(long str str long)
|
||||
377 stdcall -noname -private IntlStrEqWorkerW(long wstr wstr long)
|
||||
+380 stdcall LoadIconMetric(ptr wstr long ptr)
|
||||
381 stdcall -ordinal LoadIconWithScaleDown(ptr wstr long long ptr)
|
||||
382 stdcall -noname SmoothScrollWindow(ptr)
|
||||
383 stub -noname DoReaderMode
|
||||
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
|
||||
index e18c27d..462ecf8 100644
|
||||
--- a/dlls/comctl32/commctrl.c
|
||||
+++ b/dlls/comctl32/commctrl.c
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright 1997 Dimitrie O. Paun
|
||||
* Copyright 1998,2000 Eric Kohl
|
||||
+ * Copyright 2014 Michael Müller
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -1646,3 +1647,42 @@ HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, PCWSTR name, int cx, int c
|
||||
FIXME("stub: %p %s %d %d %p\n", hinst, wine_dbgstr_w(name), cx, cy, icon);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * LoadIconMetric [COMCTL32.@]
|
||||
+ */
|
||||
+HRESULT WINAPI LoadIconMetric(HINSTANCE hinst, const WCHAR *name, int size, HICON *icon)
|
||||
+{
|
||||
+ int width, height;
|
||||
+
|
||||
+ TRACE("(%p %s %d %p)\n", hinst, debugstr_w(name), size, icon);
|
||||
+
|
||||
+ if (!icon)
|
||||
+ return E_INVALIDARG;
|
||||
+
|
||||
+ /* Windows sets it to zero in a case of failure. */
|
||||
+ *icon = NULL;
|
||||
+
|
||||
+ if (!name)
|
||||
+ return E_INVALIDARG;
|
||||
+
|
||||
+ if (size == LIM_SMALL)
|
||||
+ {
|
||||
+ width = GetSystemMetrics(SM_CXSMICON);
|
||||
+ height = GetSystemMetrics(SM_CYSMICON);
|
||||
+ }
|
||||
+ else if (size == LIM_LARGE)
|
||||
+ {
|
||||
+ width = GetSystemMetrics(SM_CXICON);
|
||||
+ height = GetSystemMetrics(SM_CYICON);
|
||||
+ }
|
||||
+ else
|
||||
+ return E_INVALIDARG;
|
||||
+
|
||||
+ /* FIXME: This doesn't seem to work properly yet with file names. */
|
||||
+ *icon = LoadImageW(hinst, name, IMAGE_ICON, width, height, 0);
|
||||
+ if (*icon)
|
||||
+ return S_OK;
|
||||
+
|
||||
+ return HRESULT_FROM_WIN32(GetLastError());
|
||||
+}
|
||||
diff --git a/include/commctrl.h b/include/commctrl.h
|
||||
index 0bcaeb6..662dca1 100644
|
||||
--- a/include/commctrl.h
|
||||
+++ b/include/commctrl.h
|
||||
@@ -42,6 +42,13 @@ BOOL WINAPI InitCommonControlsEx (const INITCOMMONCONTROLSEX*);
|
||||
LANGID WINAPI GetMUILanguage (VOID);
|
||||
VOID WINAPI InitMUILanguage (LANGID uiLang);
|
||||
|
||||
+enum _LI_METRIC
|
||||
+{
|
||||
+ LIM_SMALL,
|
||||
+ LIM_LARGE
|
||||
+};
|
||||
+
|
||||
+HRESULT WINAPI LoadIconMetric(HINSTANCE, const WCHAR *, int, HICON *);
|
||||
HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE, PCWSTR, int, int, HICON *);
|
||||
|
||||
#define COMCTL32_VERSION 5 /* dll version */
|
||||
--
|
||||
2.4.5
|
||||
|
@ -0,0 +1,82 @@
|
||||
From 2994442796e915f6b6704f904ea36430257fb977 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 1 Oct 2015 22:52:22 +0200
|
||||
Subject: comctl32: Add implementation for LoadIconMetric.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Michael Müller <michael@fds-team.de>
|
||||
---
|
||||
dlls/comctl32/comctl32.spec | 1 +
|
||||
dlls/comctl32/commctrl.c | 25 +++++++++++++++++++++++++
|
||||
include/commctrl.h | 7 +++++++
|
||||
3 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/dlls/comctl32/comctl32.spec b/dlls/comctl32/comctl32.spec
|
||||
index 1e92e5f..1a5ab57 100644
|
||||
--- a/dlls/comctl32/comctl32.spec
|
||||
+++ b/dlls/comctl32/comctl32.spec
|
||||
@@ -88,6 +88,7 @@
|
||||
375 stdcall -noname -private StrCSpnIW(wstr wstr)
|
||||
376 stdcall -noname -private IntlStrEqWorkerA(long str str long)
|
||||
377 stdcall -noname -private IntlStrEqWorkerW(long wstr wstr long)
|
||||
+380 stdcall -ordinal LoadIconMetric(ptr wstr long ptr)
|
||||
381 stdcall -ordinal LoadIconWithScaleDown(ptr wstr long long ptr)
|
||||
382 stdcall -noname SmoothScrollWindow(ptr)
|
||||
383 stub -noname DoReaderMode
|
||||
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
|
||||
index 97656a5..22281e1 100644
|
||||
--- a/dlls/comctl32/commctrl.c
|
||||
+++ b/dlls/comctl32/commctrl.c
|
||||
@@ -1658,3 +1658,28 @@ HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, const WCHAR *name, int cx,
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
+
|
||||
+/***********************************************************************
|
||||
+ * LoadIconMetric [COMCTL32.@]
|
||||
+ */
|
||||
+HRESULT WINAPI LoadIconMetric(HINSTANCE hinst, const WCHAR *name, int size, HICON *icon)
|
||||
+{
|
||||
+ int cx, cy;
|
||||
+
|
||||
+ TRACE("(%p, %s, %d, %p)\n", hinst, debugstr_w(name), size, icon);
|
||||
+
|
||||
+ if (size == LIM_SMALL)
|
||||
+ {
|
||||
+ cx = GetSystemMetrics(SM_CXSMICON);
|
||||
+ cy = GetSystemMetrics(SM_CYSMICON);
|
||||
+ }
|
||||
+ else if (size == LIM_LARGE)
|
||||
+ {
|
||||
+ cx = GetSystemMetrics(SM_CXICON);
|
||||
+ cy = GetSystemMetrics(SM_CYICON);
|
||||
+ }
|
||||
+ else
|
||||
+ return E_INVALIDARG;
|
||||
+
|
||||
+ return LoadIconWithScaleDown(hinst, name, cx, cy, icon);
|
||||
+}
|
||||
diff --git a/include/commctrl.h b/include/commctrl.h
|
||||
index 0ed0997..5029e77 100644
|
||||
--- a/include/commctrl.h
|
||||
+++ b/include/commctrl.h
|
||||
@@ -42,7 +42,14 @@ BOOL WINAPI InitCommonControlsEx (const INITCOMMONCONTROLSEX*);
|
||||
LANGID WINAPI GetMUILanguage (VOID);
|
||||
VOID WINAPI InitMUILanguage (LANGID uiLang);
|
||||
|
||||
+enum _LI_METRIC
|
||||
+{
|
||||
+ LIM_SMALL,
|
||||
+ LIM_LARGE
|
||||
+};
|
||||
+
|
||||
HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE, const WCHAR *, int, int, HICON *);
|
||||
+HRESULT WINAPI LoadIconMetric(HINSTANCE, const WCHAR *, int, HICON *);
|
||||
|
||||
#define COMCTL32_VERSION 5 /* dll version */
|
||||
|
||||
--
|
||||
2.5.1
|
||||
|
@ -1,108 +0,0 @@
|
||||
From 54e59f6203fc4e8ce1a3855f51de9ba179bf7ef5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 7 Aug 2014 01:54:28 +0200
|
||||
Subject: comctl32/tests: Add tests for LoadIconMetric function.
|
||||
|
||||
Changes by Alistair Leslie-Hughes:
|
||||
* Changed PCWSTR, CHAR, INT
|
||||
* Changed LoadIconMetric to pLoadIconMetric
|
||||
(caused a compile error since it's in the header).
|
||||
---
|
||||
dlls/comctl32/tests/misc.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 60 insertions(+)
|
||||
|
||||
diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c
|
||||
index 280b46c..3d2231e 100644
|
||||
--- a/dlls/comctl32/tests/misc.c
|
||||
+++ b/dlls/comctl32/tests/misc.c
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
+#include <commctrl.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "v6util.h"
|
||||
@@ -34,6 +35,8 @@ static BOOL (WINAPI * pStr_SetPtrA)(LPSTR, LPCSTR);
|
||||
static INT (WINAPI * pStr_GetPtrW)(LPCWSTR, LPWSTR, INT);
|
||||
static BOOL (WINAPI * pStr_SetPtrW)(LPWSTR, LPCWSTR);
|
||||
|
||||
+static HRESULT (WINAPI * pLoadIconMetric)(HINSTANCE, const WCHAR *, int, HICON *);
|
||||
+
|
||||
static HMODULE hComctl32 = 0;
|
||||
|
||||
#define COMCTL32_GET_PROC(ordinal, func) \
|
||||
@@ -205,6 +208,62 @@ static void test_TaskDialogIndirect(void)
|
||||
ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr);
|
||||
}
|
||||
|
||||
+static void test_LoadIconMetric(void)
|
||||
+{
|
||||
+ static const WCHAR non_existing_fileW[] = {'n','o','n','e','x','i','s','t','i','n','g','.','i','c','o','\0'};
|
||||
+ HRESULT result;
|
||||
+ ICONINFO info;
|
||||
+ HICON icon;
|
||||
+ BITMAP bmp;
|
||||
+ void *ptr;
|
||||
+ int bytes;
|
||||
+ BOOL res;
|
||||
+
|
||||
+ pLoadIconMetric = (void *)GetProcAddress(hComctl32, "LoadIconMetric");
|
||||
+ if (!pLoadIconMetric)
|
||||
+ {
|
||||
+ win_skip("LoadIconMetric not exported by name\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ptr = GetProcAddress(hComctl32, (const char *)380);
|
||||
+ ok(ptr == pLoadIconMetric, "got wrong pointer for ordinal 380, %p expected %p\n",
|
||||
+ ptr, pLoadIconMetric);
|
||||
+
|
||||
+ result = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), 0x100, &icon);
|
||||
+ ok(result == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", result);
|
||||
+
|
||||
+ icon = (HICON)0x1234;
|
||||
+ result = pLoadIconMetric(NULL, NULL, LIM_LARGE, &icon);
|
||||
+ ok(result == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", result);
|
||||
+ ok(icon == NULL, "Expected NULL, got %p\n", icon);
|
||||
+
|
||||
+ result = pLoadIconMetric(NULL, non_existing_fileW, LIM_LARGE, &icon);
|
||||
+ ok(result == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
|
||||
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", result);
|
||||
+
|
||||
+ result = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), LIM_SMALL, &icon);
|
||||
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %d\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXSMICON), "Wrong icon width\n");
|
||||
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYSMICON), "Wrong icon height\n");
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ result = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), LIM_LARGE, &icon);
|
||||
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %d\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXICON), "Wrong icon width\n");
|
||||
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYICON), "Wrong icon height\n");
|
||||
+ DestroyIcon(icon);
|
||||
+}
|
||||
+
|
||||
+
|
||||
START_TEST(misc)
|
||||
{
|
||||
ULONG_PTR ctx_cookie;
|
||||
@@ -220,6 +279,7 @@ START_TEST(misc)
|
||||
return;
|
||||
|
||||
test_TaskDialogIndirect();
|
||||
+ test_LoadIconMetric();
|
||||
|
||||
unload_v6_module(ctx_cookie, hCtx);
|
||||
}
|
||||
--
|
||||
2.4.5
|
||||
|
@ -0,0 +1,198 @@
|
||||
From 7c5c210415b7506d2c9328561ceda0cf8b821c1f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 7 Aug 2014 01:54:28 +0200
|
||||
Subject: comctl32/tests: Add tests for LoadIconMetric function.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Michael Müller <michael@fds-team.de>
|
||||
---
|
||||
dlls/comctl32/tests/misc.c | 150 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 150 insertions(+)
|
||||
|
||||
diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c
|
||||
index 280b46c..ea2181d 100644
|
||||
--- a/dlls/comctl32/tests/misc.c
|
||||
+++ b/dlls/comctl32/tests/misc.c
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
+#include <commctrl.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "v6util.h"
|
||||
@@ -36,6 +37,18 @@ static BOOL (WINAPI * pStr_SetPtrW)(LPWSTR, LPCWSTR);
|
||||
|
||||
static HMODULE hComctl32 = 0;
|
||||
|
||||
+static char testicon_data[] =
|
||||
+{
|
||||
+ 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00,
|
||||
+ 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00,
|
||||
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x12, 0x0b,
|
||||
+ 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0xde, 0xde, 0xde, 0xff, 0xde, 0xde, 0xde, 0xff, 0xde, 0xde,
|
||||
+ 0xde, 0xff, 0xde, 0xde, 0xde, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00
|
||||
+};
|
||||
+
|
||||
#define COMCTL32_GET_PROC(ordinal, func) \
|
||||
p ## func = (void*)GetProcAddress(hComctl32, (LPSTR)ordinal); \
|
||||
if(!p ## func) { \
|
||||
@@ -205,6 +218,142 @@ static void test_TaskDialogIndirect(void)
|
||||
ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr);
|
||||
}
|
||||
|
||||
+static void test_LoadIconWithScaleDown(void)
|
||||
+{
|
||||
+ static const WCHAR nonexisting_fileW[] = {'n','o','n','e','x','i','s','t','i','n','g','.','i','c','o',0};
|
||||
+ static const WCHAR nonexisting_resourceW[] = {'N','o','n','e','x','i','s','t','i','n','g',0};
|
||||
+ static const WCHAR prefixW[] = {'I','C','O',0};
|
||||
+ HRESULT (WINAPI *pLoadIconMetric)(HINSTANCE, const WCHAR *, int, HICON *);
|
||||
+ HRESULT (WINAPI *pLoadIconWithScaleDown)(HINSTANCE, const WCHAR *, int, int, HICON *);
|
||||
+ WCHAR tmp_path[MAX_PATH], icon_path[MAX_PATH];
|
||||
+ ICONINFO info;
|
||||
+ HMODULE hinst;
|
||||
+ HANDLE handle;
|
||||
+ DWORD written;
|
||||
+ HRESULT hr;
|
||||
+ BITMAP bmp;
|
||||
+ HICON icon;
|
||||
+ void *ptr;
|
||||
+ int bytes;
|
||||
+ BOOL res;
|
||||
+
|
||||
+ hinst = LoadLibraryA("comctl32.dll");
|
||||
+ pLoadIconMetric = (void *)GetProcAddress(hinst, "LoadIconMetric");
|
||||
+ pLoadIconWithScaleDown = (void *)GetProcAddress(hinst, "LoadIconWithScaleDown");
|
||||
+ if (!pLoadIconMetric || !pLoadIconWithScaleDown)
|
||||
+ {
|
||||
+ win_skip("LoadIconMetric or pLoadIconWithScaleDown not exported by name\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ GetTempPathW(MAX_PATH, tmp_path);
|
||||
+ GetTempFileNameW(tmp_path, prefixW, 0, icon_path);
|
||||
+ handle = CreateFileW(icon_path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
+ FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
+ ok(handle != INVALID_HANDLE_VALUE, "CreateFileW failed with error %u\n", GetLastError());
|
||||
+ res = WriteFile(handle, testicon_data, sizeof(testicon_data), &written, NULL);
|
||||
+ ok(res && written == sizeof(testicon_data), "Failed to write icon file\n");
|
||||
+ CloseHandle(handle);
|
||||
+
|
||||
+ /* test ordinals */
|
||||
+ ptr = GetProcAddress(hinst, (const char *)380);
|
||||
+ ok(ptr == pLoadIconMetric,
|
||||
+ "got wrong pointer for ordinal 380, %p expected %p\n", ptr, pLoadIconMetric);
|
||||
+
|
||||
+ ptr = GetProcAddress(hinst, (const char *)381);
|
||||
+ ok(ptr == pLoadIconWithScaleDown,
|
||||
+ "got wrong pointer for ordinal 381, %p expected %p\n", ptr, pLoadIconWithScaleDown);
|
||||
+
|
||||
+ /* invalid arguments */
|
||||
+ hr = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), 0x100, &icon);
|
||||
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);
|
||||
+
|
||||
+ icon = (HICON)0x1234;
|
||||
+ hr = pLoadIconMetric(NULL, NULL, LIM_LARGE, &icon);
|
||||
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);
|
||||
+ ok(icon == NULL, "Expected NULL, got %p\n", icon);
|
||||
+
|
||||
+ icon = (HICON)0x1234;
|
||||
+ hr = pLoadIconWithScaleDown(NULL, NULL, 32, 32, &icon);
|
||||
+ ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);
|
||||
+ ok(icon == NULL, "Expected NULL, got %p\n", icon);
|
||||
+
|
||||
+ /* non-existing filename */
|
||||
+ hr = pLoadIconMetric(NULL, nonexisting_fileW, LIM_LARGE, &icon);
|
||||
+ todo_wine
|
||||
+ ok(hr == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
|
||||
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", hr);
|
||||
+
|
||||
+ hr = pLoadIconWithScaleDown(NULL, nonexisting_fileW, 32, 32, &icon);
|
||||
+ todo_wine
|
||||
+ ok(hr == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
|
||||
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", hr);
|
||||
+
|
||||
+ /* non-existing resource name */
|
||||
+ hr = pLoadIconMetric(hinst, nonexisting_resourceW, LIM_LARGE, &icon);
|
||||
+ ok(hr == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
|
||||
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", hr);
|
||||
+
|
||||
+ hr = pLoadIconWithScaleDown(hinst, nonexisting_resourceW, 32, 32, &icon);
|
||||
+ ok(hr == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
|
||||
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", hr);
|
||||
+
|
||||
+ /* load icon using predefined identifier */
|
||||
+ hr = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), LIM_SMALL, &icon);
|
||||
+ ok(hr == S_OK, "Expected S_OK, got %x\n", hr);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %u\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXSMICON), "Wrong icon width %d\n", bmp.bmWidth);
|
||||
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYSMICON), "Wrong icon height %d\n", bmp.bmHeight);
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ hr = pLoadIconMetric(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), LIM_LARGE, &icon);
|
||||
+ ok(hr == S_OK, "Expected S_OK, got %x\n", hr);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %u\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXICON), "Wrong icon width %d\n", bmp.bmWidth);
|
||||
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYICON), "Wrong icon height %d\n", bmp.bmHeight);
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ hr = pLoadIconWithScaleDown(NULL, MAKEINTRESOURCEW(IDI_APPLICATION), 42, 42, &icon);
|
||||
+ ok(hr == S_OK, "Expected S_OK, got %x\n", hr);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %u\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == 42, "Wrong icon width %d\n", bmp.bmWidth);
|
||||
+ ok(bmp.bmHeight == 42, "Wrong icon height %d\n", bmp.bmHeight);
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ /* load icon from file */
|
||||
+ hr = pLoadIconMetric(NULL, icon_path, LIM_SMALL, &icon);
|
||||
+ ok(hr == S_OK, "Expected S_OK, got %x\n", hr);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %u\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXSMICON), "Wrong icon width %d\n", bmp.bmWidth);
|
||||
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYSMICON), "Wrong icon height %d\n", bmp.bmHeight);
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ hr = pLoadIconWithScaleDown(NULL, icon_path, 42, 42, &icon);
|
||||
+ ok(hr == S_OK, "Expected S_OK, got %x\n", hr);
|
||||
+ res = GetIconInfo(icon, &info);
|
||||
+ ok(res, "Failed to get icon info, error %u\n", GetLastError());
|
||||
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
|
||||
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
|
||||
+ ok(bmp.bmWidth == 42, "Wrong icon width %d\n", bmp.bmWidth);
|
||||
+ ok(bmp.bmHeight == 42, "Wrong icon height %d\n", bmp.bmHeight);
|
||||
+ DestroyIcon(icon);
|
||||
+
|
||||
+ DeleteFileW(icon_path);
|
||||
+ FreeLibrary(hinst);
|
||||
+}
|
||||
+
|
||||
START_TEST(misc)
|
||||
{
|
||||
ULONG_PTR ctx_cookie;
|
||||
@@ -220,6 +369,7 @@ START_TEST(misc)
|
||||
return;
|
||||
|
||||
test_TaskDialogIndirect();
|
||||
+ test_LoadIconWithScaleDown();
|
||||
|
||||
unload_v6_module(ctx_cookie, hCtx);
|
||||
}
|
||||
--
|
||||
2.5.1
|
||||
|
@ -2367,10 +2367,12 @@ fi
|
||||
# | * dlls/comctl32/comctl32.spec, dlls/comctl32/commctrl.c, dlls/comctl32/tests/misc.c, include/commctrl.h
|
||||
# |
|
||||
if test "$enable_comctl32_LoadIconMetric" -eq 1; then
|
||||
patch_apply comctl32-LoadIconMetric/0001-comctl32-Implement-LoadIconMetric-function.patch
|
||||
patch_apply comctl32-LoadIconMetric/0002-comctl32-tests-Add-tests-for-LoadIconMetric-function.patch
|
||||
patch_apply comctl32-LoadIconMetric/0001-comctl32-Add-semi-stub-implementation-for-LoadIconWi.patch
|
||||
patch_apply comctl32-LoadIconMetric/0002-comctl32-Add-implementation-for-LoadIconMetric.patch
|
||||
patch_apply comctl32-LoadIconMetric/0003-comctl32-tests-Add-tests-for-LoadIconMetric-function.patch
|
||||
(
|
||||
echo '+ { "Michael Müller", "comctl32: Implement LoadIconMetric function.", 1 },';
|
||||
echo '+ { "Michael Müller", "comctl32: Add semi-stub implementation for LoadIconWithScaleDown.", 1 },';
|
||||
echo '+ { "Michael Müller", "comctl32: Add implementation for LoadIconMetric.", 1 },';
|
||||
echo '+ { "Michael Müller", "comctl32/tests: Add tests for LoadIconMetric function.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user