* Addendum to r58214.
[reactos.git] / rostests / apitests / user32 / LoadImage.c
1 #include <stdio.h>
2 #include <wine/test.h>
3 #include <wingdi.h>
4 #include <winuser.h>
5
6 START_TEST(LoadImage)
7 {
8 char path[MAX_PATH];
9 PROCESS_INFORMATION pi;
10 STARTUPINFO si;
11 HANDLE handle;
12
13 char **test_argv;
14 int argc = winetest_get_mainargs( &test_argv );
15
16 /* Now check its behaviour regarding Shared icons/cursors */
17 handle = LoadImageW( GetModuleHandle(NULL), L"TESTCURSOR", IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE );
18 ok(handle != 0, "\n");
19
20 if (argc >= 3)
21 {
22 HANDLE arg;
23 HICON hCopy;
24 HBITMAP hbmp;
25 HDC hdc, hdcScreen;
26 ICONINFO ii;
27
28 sscanf (test_argv[2], "%lu", (ULONG_PTR*) &arg);
29
30 ok(handle != arg, "Got same handles\n");
31
32 /* Try copying it */
33 hCopy = CopyIcon(arg);
34 ok(hCopy != NULL, "\n");
35 ok(DestroyIcon(hCopy), "\n");
36
37 hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, 0);
38 ok(hCopy != NULL, "\n");
39 ok(DestroyIcon(hCopy), "\n");
40
41 hCopy = CopyImage(arg, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE);
42 ok(hCopy != NULL, "\n");
43 ok(DestroyIcon(hCopy), "\n");
44
45 /* Try various usual functions */
46 hdcScreen = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
47 ok(hdcScreen != NULL, "\n");
48 hdc = CreateCompatibleDC(hdcScreen);
49 ok(hdc != NULL, "\n");
50 hbmp = CreateCompatibleBitmap(hdcScreen, 64, 64);
51 ok(hbmp != NULL, "\n");
52 hbmp = SelectObject(hdc, hbmp);
53 ok(hbmp != NULL, "\n");
54
55 ok(DrawIcon(hdc, 0, 0, arg), "\n");
56 hbmp = SelectObject(hdc, hbmp);
57 DeleteObject(hbmp);
58 DeleteDC(hdc);
59 DeleteDC(hdcScreen);
60
61 ok(GetIconInfo(arg, &ii), "\n");
62 ok(ii.hbmMask != NULL, "\n");
63 DeleteObject(ii.hbmMask);
64 if(ii.hbmColor) DeleteObject(ii.hbmColor);
65
66 return;
67 }
68
69 /* Start child process */
70 sprintf( path, "%s LoadImage %lu", test_argv[0], (ULONG_PTR)handle );
71 memset( &si, 0, sizeof(si) );
72 si.cb = sizeof(si);
73 CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi );
74 WaitForSingleObject (pi.hProcess, INFINITE);
75 }