2013-09-22 18:17:54 +00:00
|
|
|
|
|
|
|
#include <apitest.h>
|
|
|
|
|
2012-10-30 13:29:11 +00:00
|
|
|
#include <stdio.h>
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2012-10-30 13:29:11 +00:00
|
|
|
|
|
|
|
START_TEST(LoadImage)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFO si;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
char **test_argv;
|
|
|
|
int argc = winetest_get_mainargs( &test_argv );
|
|
|
|
|
|
|
|
/* Now check its behaviour regarding Shared icons/cursors */
|
|
|
|
handle = LoadImageW( GetModuleHandle(NULL), L"TESTCURSOR", IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE );
|
|
|
|
ok(handle != 0, "\n");
|
|
|
|
|
|
|
|
if (argc >= 3)
|
|
|
|
{
|
|
|
|
HANDLE arg;
|
2012-11-06 14:27:03 +00:00
|
|
|
HICON hCopy;
|
|
|
|
HBITMAP hbmp;
|
|
|
|
HDC hdc, hdcScreen;
|
|
|
|
ICONINFO ii;
|
2012-10-30 13:29:11 +00:00
|
|
|
|
|
|
|
sscanf (test_argv[2], "%lu", (ULONG_PTR*) &arg);
|
|
|
|
|
|
|
|
ok(handle != arg, "Got same handles\n");
|
2012-11-06 14:27:03 +00:00
|
|
|
|
|
|
|
/* Try copying it */
|
|
|
|
hCopy = CopyIcon(arg);
|
|
|
|
ok(hCopy != NULL, "\n");
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
2013-11-14 23:11:23 +00:00
|
|
|
|
2012-11-06 14:27:03 +00:00
|
|
|
hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, 0);
|
|
|
|
ok(hCopy != NULL, "\n");
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
2014-10-23 11:19:21 +00:00
|
|
|
/* Unlike the original, this one is not shared */
|
|
|
|
ok(!DestroyIcon(hCopy), "\n");
|
2012-11-06 14:27:03 +00:00
|
|
|
|
|
|
|
hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE);
|
|
|
|
ok(hCopy != NULL, "\n");
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
2014-10-23 11:19:21 +00:00
|
|
|
/* Unlike the original, this one is not shared */
|
|
|
|
ok(!DestroyIcon(hCopy), "\n");
|
|
|
|
|
|
|
|
hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE | LR_SHARED);
|
|
|
|
ok(hCopy != NULL, "\n");
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
|
|
|
/* This one is shared */
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
2012-11-06 14:27:03 +00:00
|
|
|
|
2014-10-23 11:19:21 +00:00
|
|
|
hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, LR_SHARED);
|
|
|
|
ok(hCopy != NULL, "\n");
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
|
|
|
/* This one is shared */
|
|
|
|
ok(DestroyIcon(hCopy), "\n");
|
|
|
|
|
2012-11-06 14:27:03 +00:00
|
|
|
/* Try various usual functions */
|
|
|
|
hdcScreen = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
|
|
|
|
ok(hdcScreen != NULL, "\n");
|
|
|
|
hdc = CreateCompatibleDC(hdcScreen);
|
|
|
|
ok(hdc != NULL, "\n");
|
|
|
|
hbmp = CreateCompatibleBitmap(hdcScreen, 64, 64);
|
|
|
|
ok(hbmp != NULL, "\n");
|
|
|
|
hbmp = SelectObject(hdc, hbmp);
|
|
|
|
ok(hbmp != NULL, "\n");
|
|
|
|
|
|
|
|
ok(DrawIcon(hdc, 0, 0, arg), "\n");
|
|
|
|
hbmp = SelectObject(hdc, hbmp);
|
|
|
|
DeleteObject(hbmp);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
DeleteDC(hdcScreen);
|
|
|
|
|
|
|
|
ok(GetIconInfo(arg, &ii), "\n");
|
|
|
|
ok(ii.hbmMask != NULL, "\n");
|
|
|
|
DeleteObject(ii.hbmMask);
|
|
|
|
if(ii.hbmColor) DeleteObject(ii.hbmColor);
|
2012-10-30 13:29:11 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start child process */
|
|
|
|
sprintf( path, "%s LoadImage %lu", test_argv[0], (ULONG_PTR)handle );
|
|
|
|
memset( &si, 0, sizeof(si) );
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi );
|
|
|
|
WaitForSingleObject (pi.hProcess, INFINITE);
|
2012-11-06 14:27:03 +00:00
|
|
|
}
|