2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for SetProp
5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
10 #include <user32testhelpers.h>
12 static ATOM Atom1
, Atom2
, Atom3
;
19 _In_ PCWSTR lpszString
,
22 if (HIWORD(lpszString
))
23 ok(0, "Unexpected EnumFunc call: %p, '%ls', %p\n", hWnd
, lpszString
, hData
);
25 ok(0, "Unexpected EnumFunc call: %p, 0x%04x, %p\n", hWnd
, (USHORT
)(ULONG_PTR
)lpszString
, hData
);
34 _In_ PWSTR lpszString
,
36 _In_ ULONG_PTR dwData
)
40 if (HIWORD(lpszString
))
41 ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd
, lpszString
, hData
);
43 ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd
, (USHORT
)(ULONG_PTR
)lpszString
, hData
);
47 if (HIWORD(lpszString
))
49 if (!wcscmp(lpszString
, L
"PropTestAtom1"))
50 ok(hData
== &Atom1
, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd
, lpszString
, hData
, &Atom1
);
51 else if (!wcscmp(lpszString
, L
"PropTestAtom2"))
52 ok(hData
== &Atom2
, "EnumFuncEx: %p, '%ls', %p; expected %p\n", hWnd
, lpszString
, hData
, &Atom2
);
54 ok(0, "Unexpected EnumFuncEx call: %p, '%ls', %p\n", hWnd
, lpszString
, hData
);
57 ok(0, "Unexpected EnumFuncEx call: %p, 0x%04x, %p\n", hWnd
, (USHORT
)(ULONG_PTR
)lpszString
, hData
);
74 Atom1
= GlobalAddAtomW(L
"PropTestAtom1");
75 ok(Atom1
!= 0, "PropTestAtom1 is 0x%04x\n", Atom1
);
76 ok(Atom1
>= 0xc000, "PropTestAtom1 is 0x%04x\n", Atom1
);
77 ok(Atom1
>= 0xc018, "PropTestAtom1 is 0x%04x\n", Atom1
);
79 /* These are not in the global atom table */
80 Atom
= GlobalFindAtomW(L
"SysIC");
81 ok(Atom
== 0, "SysIC atom is 0x%04x\n", Atom
);
82 Atom
= GlobalFindAtomW(L
"SysICS");
83 ok(Atom
== 0, "SysICS atom is 0x%04x\n", Atom
);
87 RegisterSimpleClass(DefWindowProcW
, L
"PropTest");
89 hWnd
= CreateWindowExW(0, L
"PropTest", NULL
, 0, 10, 10, 20, 20, NULL
, NULL
, 0, NULL
);
91 Result
= EnumPropsW(hWnd
, EnumFunc
);
92 if (0) // Windows returns an uninitialized value here
93 ok(Result
== TRUE
, "EnumProps returned %Iu\n", Result
);
94 Result
= EnumPropsExW(hWnd
, EnumFuncEx
, 0);
95 if (0) // Windows returns an uninitialized value here
96 ok(Result
== TRUE
, "EnumPropsEx returned %Iu\n", Result
);
98 Atom2
= GlobalAddAtomW(L
"PropTestAtom2");
99 ok(Atom2
!= 0, "PropTestAtom2 is 0x%04x\n", Atom2
);
100 ok(Atom2
>= 0xc000, "PropTestAtom2 is 0x%04x\n", Atom2
);
101 ok(Atom2
>= 0xc018, "PropTestAtom2 is 0x%04x\n", Atom2
);
103 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
104 DispatchMessageA(&msg
);
106 Result
= EnumPropsExW(hWnd
, EnumFuncEx
, 0);
107 if (0) // Windows returns an uninitialized value here
108 ok(Result
== TRUE
, "EnumPropsEx returned %Iu\n", Result
);
110 Result
= SetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom1
), &Atom1
);
111 ok(Result
== TRUE
, "SetProp returned %Iu\n", Result
);
112 Result
= SetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom2
), &Atom3
);
113 ok(Result
== TRUE
, "SetProp returned %Iu\n", Result
);
114 Prop
= GetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom2
));
115 ok(Prop
== &Atom3
, "GetProp returned %p, expected %p\n", Prop
, &Atom3
);
116 Result
= SetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom2
), &Atom2
);
117 ok(Result
== TRUE
, "SetProp returned %Iu\n", Result
);
118 Prop
= GetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom2
));
119 ok(Prop
== &Atom2
, "GetProp returned %p, expected %p\n", Prop
, &Atom2
);
120 Prop
= GetPropW(hWnd
, L
"PropTestAtom2");
121 ok(Prop
== &Atom2
, "GetProp returned %p, expected %p\n", Prop
, &Atom2
);
122 Prop
= GetPropA(hWnd
, "PropTestAtom2");
123 ok(Prop
== &Atom2
, "GetProp returned %p, expected %p\n", Prop
, &Atom2
);
125 Result
= EnumPropsExW(hWnd
, EnumFuncEx
, 1);
126 ok(Result
== TRUE
, "EnumPropsEx returned %Iu\n", Result
);
128 hIcon
= LoadImageW(NULL
, (PCWSTR
)MAKEINTRESOURCE(OIC_NOTE
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
| LR_SHARED
);
129 ok(hIcon
!= NULL
, "LoadImage failed with %lu\n", GetLastError());
130 /* Should not have any icon */
131 hIcon2
= (HICON
)SendMessageW(hWnd
, WM_GETICON
, ICON_BIG
, 0);
132 ok(hIcon2
== NULL
, "WM_GETICON returned %p, expected NULL\n", hIcon2
);
133 hIcon2
= (HICON
)SendMessageW(hWnd
, WM_GETICON
, ICON_SMALL
, 0);
134 ok(hIcon2
== NULL
, "WM_GETICON returned %p, expected NULL\n", hIcon2
);
136 /* Set big icon, should also set small icon */
137 Result
= SendMessageW(hWnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
138 ok(Result
== 0, "WM_SETICON returned 0x%Ix\n", Result
);
140 hIcon2
= (HICON
)SendMessageW(hWnd
, WM_GETICON
, ICON_BIG
, 0);
141 ok(hIcon2
== hIcon
, "WM_GETICON returned %p, expected %p\n", hIcon2
, hIcon
);
142 hIcon2
= (HICON
)SendMessageW(hWnd
, WM_GETICON
, ICON_SMALL
, 0);
143 ok(hIcon2
!= hIcon
&& hIcon
!= NULL
, "WM_GETICON returned %p, expected not %p and not NULL\n", hIcon2
, hIcon
);
145 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
146 DispatchMessageA(&msg
);
148 /* We should have only the props that we explicitly set */
149 for (Atom
= 0x0000; Atom
<= 0xffff; Atom
++)
151 Prop
= GetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(Atom
));
153 ok(Prop
== &Atom1
, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd
, Atom
, Prop
, &Atom1
);
154 else if (Atom
== Atom2
)
155 ok(Prop
== &Atom2
, "Window %p Prop 0x%04x = %p, expected %p\n", hWnd
, Atom
, Prop
, &Atom2
);
157 ok(Prop
== NULL
, "Window %p Prop 0x%04x = %p\n", hWnd
, Atom
, Prop
);
160 /* In particular we shouldn't see these from WM_SETICON */
161 SysICAtom
= RegisterWindowMessageW(L
"SysIC");
162 Prop
= GetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(SysICAtom
));
163 ok(Prop
== NULL
, "SysIC prop (0x%04x) is %p\n", SysICAtom
, Prop
);
165 SysICSAtom
= RegisterWindowMessageW(L
"SysICS");
166 Prop
= GetPropW(hWnd
, (PCWSTR
)MAKEINTATOM(SysICSAtom
));
167 ok(Prop
== NULL
, "SysICS prop (0x%04x) is %p\n", SysICSAtom
, Prop
);
169 GlobalDeleteAtom(Atom1
);
170 GlobalDeleteAtom(Atom2
);
174 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
175 DispatchMessageA(&msg
);