1 /* Unit test suite for window classes.
3 * Copyright 2002 Mike McCormack
4 * Copyright 2003 Alexandre Julliard
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.
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.
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
21 /* To get CS_DROPSHADOW with the MSVC headers */
22 #define _WIN32_WINNT 0x0501
29 #include "wine/test.h"
36 /* we don't want to include commctrl.h: */
37 static const CHAR WC_EDITA
[] = "Edit";
38 static const WCHAR WC_EDITW
[] = {'E','d','i','t',0};
40 #define NUMCLASSWORDS 4
42 #define IS_WNDPROC_HANDLE(x) (((ULONG_PTR)(x) >> 16) == (~((ULONG_PTR)0) >> 16))
44 static LRESULT WINAPI
ClassTest_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
46 return DefWindowProcW (hWnd
, msg
, wParam
, lParam
);
49 static LRESULT WINAPI
ClassTest_WndProc2 (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
51 return DefWindowProcA (hWnd
, msg
, wParam
, lParam
);
54 /***********************************************************************
56 static void ClassTest(HINSTANCE hInstance
, BOOL global
)
59 static const WCHAR className
[] = {'T','e','s','t','C','l','a','s','s',0};
60 static const WCHAR winName
[] = {'W','i','n','C','l','a','s','s','T','e','s','t',0};
67 cls
.style
= CS_HREDRAW
| CS_VREDRAW
| (global
?CS_GLOBALCLASS
:0);
68 cls
.lpfnWndProc
= ClassTest_WndProc
;
69 cls
.cbClsExtra
= NUMCLASSWORDS
*sizeof(DWORD
);
71 cls
.hInstance
= hInstance
;
72 cls
.hIcon
= LoadIconW (0, (LPWSTR
)IDI_APPLICATION
);
73 cls
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
74 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
76 cls
.lpszClassName
= className
;
78 classatom
=RegisterClassW(&cls
);
79 if (!classatom
&& GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
81 ok(classatom
, "failed to register class\n");
83 ok(!RegisterClassW (&cls
),
84 "RegisterClass of the same class should fail for the second time\n");
87 hTestWnd
= CreateWindowW (className
, winName
,
88 WS_OVERLAPPEDWINDOW
+ WS_HSCROLL
+ WS_VSCROLL
,
89 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
92 ok(hTestWnd
!=0, "Failed to create window\n");
94 /* test initial values of valid classwords */
95 for(i
=0; i
<NUMCLASSWORDS
; i
++)
98 ok(!GetClassLongW(hTestWnd
,i
*sizeof (DWORD
)),
99 "GetClassLongW initial value nonzero!\n");
101 "GetClassLongW failed!\n");
107 * GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD))
108 * does not fail on Win 98, though MSDN says it should
111 GetClassLongW(hTestWnd
, NUMCLASSWORDS
*sizeof(DWORD
));
113 "GetClassLongW() with invalid offset did not fail\n");
116 /* set values of valid class words */
117 for(i
=0; i
<NUMCLASSWORDS
; i
++)
120 ok(!SetClassLongW(hTestWnd
,i
*sizeof(DWORD
),i
+1),
121 "GetClassLongW(%d) initial value nonzero!\n",i
);
123 "SetClassLongW(%d) failed!\n",i
);
126 /* test values of valid classwords that we set */
127 for(i
=0; i
<NUMCLASSWORDS
; i
++)
130 ok( (i
+1) == GetClassLongW(hTestWnd
,i
*sizeof (DWORD
)),
131 "GetClassLongW value doesn't match what was set!\n");
133 "GetClassLongW failed!\n");
136 /* check GetClassName */
137 i
= GetClassNameW(hTestWnd
, str
, sizeof(str
)/sizeof(str
[0]));
138 ok(i
== lstrlenW(className
),
139 "GetClassName returned incorrect length\n");
140 ok(!lstrcmpW(className
,str
),
141 "GetClassName returned incorrect name for this window's class\n");
143 /* check GetClassInfo with our hInstance */
144 if((test_atom
= GetClassInfoW(hInstance
, str
, &wc
)))
146 ok(test_atom
== classatom
,
147 "class atom did not match\n");
148 ok(wc
.cbClsExtra
== cls
.cbClsExtra
,
149 "cbClsExtra did not match\n");
150 ok(wc
.cbWndExtra
== cls
.cbWndExtra
,
151 "cbWndExtra did not match\n");
152 ok(wc
.hbrBackground
== cls
.hbrBackground
,
153 "hbrBackground did not match\n");
154 ok(wc
.hCursor
== cls
.hCursor
,
155 "hCursor did not match\n");
156 ok(wc
.hInstance
== cls
.hInstance
,
157 "hInstance did not match\n");
160 ok(FALSE
,"GetClassInfo (hinstance) failed!\n");
162 /* check GetClassInfo with zero hInstance */
165 if((test_atom
= GetClassInfoW(0, str
, &wc
)))
167 ok(test_atom
== classatom
,
168 "class atom did not match %x != %x\n", test_atom
, classatom
);
169 ok(wc
.cbClsExtra
== cls
.cbClsExtra
,
170 "cbClsExtra did not match %x!=%x\n",wc
.cbClsExtra
,cls
.cbClsExtra
);
171 ok(wc
.cbWndExtra
== cls
.cbWndExtra
,
172 "cbWndExtra did not match %x!=%x\n",wc
.cbWndExtra
,cls
.cbWndExtra
);
173 ok(wc
.hbrBackground
== cls
.hbrBackground
,
174 "hbrBackground did not match %p!=%p\n",wc
.hbrBackground
,cls
.hbrBackground
);
175 ok(wc
.hCursor
== cls
.hCursor
,
176 "hCursor did not match %p!=%p\n",wc
.hCursor
,cls
.hCursor
);
178 "hInstance not zero for global class %p\n",wc
.hInstance
);
181 ok(FALSE
,"GetClassInfo (0) failed for global class!\n");
185 ok(!GetClassInfoW(0, str
, &wc
),
186 "GetClassInfo (0) succeeded for local class!\n");
189 ok(!UnregisterClassW(className
, hInstance
),
190 "Unregister class succeeded with window existing\n");
192 ok(DestroyWindow(hTestWnd
),
193 "DestroyWindow() failed!\n");
195 ok(UnregisterClassW(className
, hInstance
),
196 "UnregisterClass() failed\n");
201 static void check_style( const char *name
, int must_exist
, UINT style
, UINT ignore
)
205 if (GetClassInfo( 0, name
, &wc
))
207 ok( !(~wc
.style
& style
& ~ignore
), "System class %s is missing bits %x (%08x/%08x)\n",
208 name
, ~wc
.style
& style
, wc
.style
, style
);
209 ok( !(wc
.style
& ~style
), "System class %s has extra bits %x (%08x/%08x)\n",
210 name
, wc
.style
& ~style
, wc
.style
, style
);
213 ok( !must_exist
, "System class %s does not exist\n", name
);
216 /* test styles of system classes */
217 static void test_styles(void)
219 /* check style bits */
220 check_style( "Button", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
221 check_style( "ComboBox", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
222 check_style( "Edit", 1, CS_PARENTDC
| CS_DBLCLKS
, 0 );
223 check_style( "ListBox", 1, CS_PARENTDC
| CS_DBLCLKS
, CS_PARENTDC
/*FIXME*/ );
224 check_style( "MDIClient", 1, 0, 0 );
225 check_style( "ScrollBar", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
226 check_style( "Static", 1, CS_PARENTDC
| CS_DBLCLKS
, 0 );
227 check_style( "ComboLBox", 1, CS_SAVEBITS
| CS_DBLCLKS
, 0 );
228 check_style( "DDEMLEvent", 0, 0, 0 );
229 check_style( "Message", 0, 0, 0 );
230 check_style( "#32768", 1, CS_DROPSHADOW
| CS_SAVEBITS
| CS_DBLCLKS
, CS_DROPSHADOW
); /* menu */
231 check_style( "#32769", 1, CS_DBLCLKS
, 0 ); /* desktop */
232 check_style( "#32770", 1, CS_SAVEBITS
| CS_DBLCLKS
, 0 ); /* dialog */
233 todo_wine
{ check_style( "#32771", 1, CS_SAVEBITS
| CS_HREDRAW
| CS_VREDRAW
, 0 ); } /* task switch */
234 check_style( "#32772", 1, 0, 0 ); /* icon title */
237 static void check_class(HINSTANCE inst
, const char *name
, const char *menu_name
)
240 UINT atom
= GetClassInfo(inst
,name
,&wc
);
241 ok( atom
, "Class %s %p not found\n", name
, inst
);
244 if (wc
.lpszMenuName
&& menu_name
)
245 ok( !strcmp( menu_name
, wc
.lpszMenuName
), "Wrong name %s/%s for class %s %p\n",
246 wc
.lpszMenuName
, menu_name
, name
, inst
);
248 ok( !menu_name
== !wc
.lpszMenuName
, "Wrong name %p/%p for class %s %p\n",
249 wc
.lpszMenuName
, menu_name
, name
, inst
);
253 static void check_instance( const char *name
, HINSTANCE inst
, HINSTANCE info_inst
, HINSTANCE gcl_inst
)
258 ok( GetClassInfo( inst
, name
, &wc
), "Couldn't find class %s inst %p\n", name
, inst
);
259 ok( wc
.hInstance
== info_inst
, "Wrong info instance %p/%p for class %s\n",
260 wc
.hInstance
, info_inst
, name
);
261 hwnd
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, inst
, 0 );
262 ok( hwnd
!= NULL
, "Couldn't create window for class %s inst %p\n", name
, inst
);
263 ok( (HINSTANCE
)GetClassLongPtrA( hwnd
, GCLP_HMODULE
) == gcl_inst
,
264 "Wrong GCL instance %p/%p for class %s\n",
265 (HINSTANCE
)GetClassLongPtrA( hwnd
, GCLP_HMODULE
), gcl_inst
, name
);
266 ok( (HINSTANCE
)GetWindowLongPtrA( hwnd
, GWLP_HINSTANCE
) == inst
,
267 "Wrong GWL instance %p/%p for window %s\n",
268 (HINSTANCE
)GetWindowLongPtrA( hwnd
, GWLP_HINSTANCE
), inst
, name
);
269 ok(!UnregisterClassA(name
, inst
), "UnregisterClassA should fail while exists a class window\n");
270 ok(GetLastError() == ERROR_CLASS_HAS_WINDOWS
, "GetLastError() should be set to ERROR_CLASS_HAS_WINDOWS not %d\n", GetLastError());
277 HINSTANCE inst
, info_inst
, gcl_inst
;
280 static DWORD WINAPI
thread_proc(void *param
)
282 struct class_info
*class_info
= (struct class_info
*)param
;
284 check_instance(class_info
->name
, class_info
->inst
, class_info
->info_inst
, class_info
->gcl_inst
);
289 static void check_thread_instance( const char *name
, HINSTANCE inst
, HINSTANCE info_inst
, HINSTANCE gcl_inst
)
293 struct class_info class_info
;
295 class_info
.name
= name
;
296 class_info
.inst
= inst
;
297 class_info
.info_inst
= info_inst
;
298 class_info
.gcl_inst
= gcl_inst
;
300 hThread
= CreateThread(NULL
, 0, thread_proc
, &class_info
, 0, &tid
);
301 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
302 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
303 CloseHandle(hThread
);
306 /* test various instance parameters */
307 static void test_instances(void)
311 const char *name
= "__test__";
312 HINSTANCE kernel32
= GetModuleHandleA("kernel32");
313 HINSTANCE user32
= GetModuleHandleA("user32");
314 HINSTANCE main_module
= GetModuleHandleA(NULL
);
318 memset( &cls
, 0, sizeof(cls
) );
319 cls
.style
= CS_HREDRAW
| CS_VREDRAW
;
320 cls
.lpfnWndProc
= ClassTest_WndProc
;
323 cls
.lpszClassName
= name
;
325 cls
.lpszMenuName
= "main_module";
326 cls
.hInstance
= main_module
;
328 ok( RegisterClassA( &cls
), "Failed to register local class for main module\n" );
329 check_class( main_module
, name
, "main_module" );
330 check_instance( name
, main_module
, main_module
, main_module
);
331 check_thread_instance( name
, main_module
, main_module
, main_module
);
333 cls
.lpszMenuName
= "kernel32";
334 cls
.hInstance
= kernel32
;
335 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
336 check_class( kernel32
, name
, "kernel32" );
337 check_class( main_module
, name
, "main_module" );
338 check_instance( name
, kernel32
, kernel32
, kernel32
);
339 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
340 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
342 /* Bug 2631 - Supplying an invalid number of bytes fails */
345 SetLastError(0xdeadbeef);
346 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
347 "Failed with invalid number of WndExtra bytes\n");
351 SetLastError(0xdeadbeef);
352 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
353 "Failed with invalid number of ClsExtra bytes\n");
357 SetLastError(0xdeadbeef);
358 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
359 "Failed with invalid number of ClsExtra and cbWndExtra bytes\n");
363 SetLastError(0xdeadbeef);
365 /* setting global flag doesn't change status of class */
366 hwnd
= CreateWindowExA( 0, name
, "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
367 SetClassLongA( hwnd
, GCL_STYLE
, CS_GLOBALCLASS
);
368 cls
.lpszMenuName
= "kernel32";
369 cls
.hInstance
= kernel32
;
370 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
371 check_class( kernel32
, name
, "kernel32" );
372 check_class( main_module
, name
, "main_module" );
373 check_instance( name
, kernel32
, kernel32
, kernel32
);
374 check_instance( name
, main_module
, main_module
, main_module
);
375 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
376 check_thread_instance( name
, main_module
, main_module
, main_module
);
377 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
379 /* changing the instance doesn't make it global */
380 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0 );
381 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
382 check_class( kernel32
, name
, "kernel32" );
383 check_instance( name
, kernel32
, kernel32
, kernel32
);
384 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
385 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
386 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
388 /* GetClassInfo with instance 0 finds user32 instance */
389 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, (LONG_PTR
)user32
);
390 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
391 check_class( kernel32
, name
, "kernel32" );
392 check_class( user32
, name
, "main_module" );
393 check_class( 0, name
, "main_module" );
394 check_instance( name
, kernel32
, kernel32
, kernel32
);
395 check_instance( name
, user32
, 0, user32
);
396 check_instance( name
, 0, 0, kernel32
);
397 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
398 check_thread_instance( name
, user32
, 0, user32
);
399 check_thread_instance( name
, 0, 0, kernel32
);
400 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
402 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0x12345678 );
403 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
404 check_class( kernel32
, name
, "kernel32" );
405 check_class( (HINSTANCE
)0x12345678, name
, "main_module" );
406 check_instance( name
, kernel32
, kernel32
, kernel32
);
407 check_instance( name
, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678 );
408 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
409 check_thread_instance( name
, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678 );
410 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
412 /* creating a window with instance 0 uses the first class found */
413 cls
.hInstance
= (HINSTANCE
)0xdeadbeef;
414 cls
.lpszMenuName
= "deadbeef";
416 ok( RegisterClassA( &cls
), "Failed to register local class for deadbeef\n" );
417 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
418 ok( (HINSTANCE
)GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == (HINSTANCE
)0xdeadbeef,
419 "Didn't get deadbeef class for null instance\n" );
420 DestroyWindow( hwnd2
);
421 ok( UnregisterClassA( name
, (HINSTANCE
)0xdeadbeef ), "Unregister failed for deadbeef\n" );
423 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
424 ok( (HINSTANCE
)GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == kernel32
,
425 "Didn't get kernel32 class for null instance\n" );
426 DestroyWindow( hwnd2
);
428 r
= GetClassName( hwnd
, buffer
, 4 );
429 ok( r
== 3, "expected 3, got %d\n", r
);
430 ok( !strcmp( buffer
, "__t"), "name wrong: %s\n", buffer
);
432 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
434 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
435 ok( GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == 0x12345678,
436 "Didn't get 12345678 class for null instance\n" );
437 DestroyWindow( hwnd2
);
439 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, (LONG_PTR
)main_module
);
440 DestroyWindow( hwnd
);
442 /* null handle means the same thing as main module */
443 cls
.lpszMenuName
= "null";
445 ok( !RegisterClassA( &cls
), "Succeeded registering local class for null instance\n" );
446 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
447 ok( UnregisterClassA( name
, main_module
), "Unregister failed for main module\n" );
449 ok( RegisterClassA( &cls
), "Failed to register local class for null instance\n" );
450 /* must be found with main module handle */
451 check_class( main_module
, name
, "null" );
452 check_instance( name
, main_module
, main_module
, main_module
);
453 check_thread_instance( name
, main_module
, main_module
, main_module
);
454 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
455 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
456 ok( UnregisterClassA( name
, 0 ), "Unregister failed for null instance\n" );
458 /* registering for user32 always fails */
459 cls
.lpszMenuName
= "user32";
460 cls
.hInstance
= user32
;
461 ok( !RegisterClassA( &cls
), "Succeeded registering local class for user32\n" );
462 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong error code %d\n", GetLastError() );
463 cls
.style
|= CS_GLOBALCLASS
;
464 ok( !RegisterClassA( &cls
), "Succeeded registering global class for user32\n" );
465 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong error code %d\n", GetLastError() );
467 /* unregister is OK though */
468 cls
.hInstance
= main_module
;
469 ok( RegisterClassA( &cls
), "Failed to register global class for main module\n" );
470 ok( UnregisterClassA( name
, user32
), "Unregister failed for user32\n" );
472 /* instance doesn't matter for global class */
473 cls
.style
|= CS_GLOBALCLASS
;
474 cls
.lpszMenuName
= "main_module";
475 cls
.hInstance
= main_module
;
476 ok( RegisterClassA( &cls
), "Failed to register global class for main module\n" );
477 cls
.lpszMenuName
= "kernel32";
478 cls
.hInstance
= kernel32
;
479 ok( !RegisterClassA( &cls
), "Succeeded registering local class for kernel32\n" );
480 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
481 /* even if global flag is cleared */
482 hwnd
= CreateWindowExA( 0, name
, "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
483 SetClassLongA( hwnd
, GCL_STYLE
, 0 );
484 ok( !RegisterClassA( &cls
), "Succeeded registering local class for kernel32\n" );
485 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
487 check_class( main_module
, name
, "main_module" );
488 check_class( kernel32
, name
, "main_module" );
489 check_class( 0, name
, "main_module" );
490 check_class( (HINSTANCE
)0x12345678, name
, "main_module" );
491 check_instance( name
, main_module
, main_module
, main_module
);
492 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, main_module
);
493 check_thread_instance( name
, main_module
, main_module
, main_module
);
494 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, main_module
);
496 /* changing the instance for global class doesn't make much difference */
497 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0xdeadbeef );
498 check_instance( name
, main_module
, main_module
, (HINSTANCE
)0xdeadbeef );
499 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef );
500 check_thread_instance( name
, main_module
, main_module
, (HINSTANCE
)0xdeadbeef );
501 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef );
503 DestroyWindow( hwnd
);
504 ok( UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister failed for main module global\n" );
505 ok( !UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister succeeded the second time\n" );
506 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
508 cls
.hInstance
= (HINSTANCE
)0x12345678;
509 ok( RegisterClassA( &cls
), "Failed to register global class for dummy instance\n" );
510 check_instance( name
, main_module
, main_module
, (HINSTANCE
)0x12345678 );
511 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0x12345678 );
512 check_thread_instance( name
, main_module
, main_module
, (HINSTANCE
)0x12345678 );
513 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0x12345678 );
514 ok( UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister failed for main module global\n" );
516 /* check system classes */
518 /* we cannot register a global class with the name of a system class */
519 cls
.style
|= CS_GLOBALCLASS
;
520 cls
.lpszMenuName
= "button_main_module";
521 cls
.lpszClassName
= "BUTTON";
522 cls
.hInstance
= main_module
;
523 ok( !RegisterClassA( &cls
), "Succeeded registering global button class for main module\n" );
524 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
525 cls
.hInstance
= kernel32
;
526 ok( !RegisterClassA( &cls
), "Succeeded registering global button class for kernel32\n" );
527 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
529 /* local class is OK however */
530 cls
.style
&= ~CS_GLOBALCLASS
;
531 cls
.lpszMenuName
= "button_main_module";
532 cls
.hInstance
= main_module
;
533 ok( RegisterClassA( &cls
), "Failed to register local button class for main module\n" );
534 check_class( main_module
, "BUTTON", "button_main_module" );
535 cls
.lpszMenuName
= "button_kernel32";
536 cls
.hInstance
= kernel32
;
537 ok( RegisterClassA( &cls
), "Failed to register local button class for kernel32\n" );
538 check_class( kernel32
, "BUTTON", "button_kernel32" );
539 check_class( main_module
, "BUTTON", "button_main_module" );
540 ok( UnregisterClassA( "BUTTON", kernel32
), "Unregister failed for kernel32 button\n" );
541 ok( UnregisterClassA( "BUTTON", main_module
), "Unregister failed for main module button\n" );
542 /* GetClassInfo sets instance to passed value for global classes */
543 check_instance( "BUTTON", 0, 0, user32
);
544 check_instance( "BUTTON", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
545 check_instance( "BUTTON", user32
, 0, user32
);
546 check_thread_instance( "BUTTON", 0, 0, user32
);
547 check_thread_instance( "BUTTON", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
548 check_thread_instance( "BUTTON", user32
, 0, user32
);
550 /* we can unregister system classes */
551 ok( GetClassInfo( 0, "BUTTON", &wc
), "Button class not found with null instance\n" );
552 ok( GetClassInfo( kernel32
, "BUTTON", &wc
), "Button class not found with kernel32\n" );
553 ok( UnregisterClass( "BUTTON", (HINSTANCE
)0x12345678 ), "Failed to unregister button\n" );
554 ok( !UnregisterClass( "BUTTON", (HINSTANCE
)0x87654321 ), "Unregistered button a second time\n" );
555 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
556 ok( !GetClassInfo( 0, "BUTTON", &wc
), "Button still exists\n" );
557 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
||
558 GetLastError() == ERROR_INVALID_PARAMETER
|| /* W2K3 */
559 GetLastError() == ERROR_SUCCESS
/* Vista */,
560 "Wrong error code %d\n", GetLastError() );
562 /* we can change the instance of a system class */
563 check_instance( "EDIT", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
564 check_thread_instance( "EDIT", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
565 hwnd
= CreateWindowExA( 0, "EDIT", "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
566 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0xdeadbeef );
567 check_instance( "EDIT", (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0xdeadbeef );
568 check_thread_instance( "EDIT", (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0xdeadbeef );
571 static void test_builtinproc(void)
573 /* Edit behaves differently. ScrollBar have currently only a Unicode winproc */
574 static const CHAR NORMAL_CLASSES
[][10] = {
580 "#32770", /* dialog */
582 static const int NUM_NORMAL_CLASSES
= (sizeof(NORMAL_CLASSES
)/sizeof(NORMAL_CLASSES
[0]));
583 static const char classA
[] = "deftest";
584 static const WCHAR classW
[] = {'d','e','f','t','e','s','t',0};
585 WCHAR unistring
[] = {0x142, 0x40e, 0x3b4, 0}; /* a string that would be destroyed by a W->A->W conversion */
586 WNDPROC pDefWindowProcA
, pDefWindowProcW
;
588 WNDCLASSEXA cls
; /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */
594 pDefWindowProcA
= (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcA");
595 pDefWindowProcW
= (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcW");
597 for (i
= 0; i
< 4; i
++)
599 ZeroMemory(&cls
, sizeof(cls
));
600 cls
.cbSize
= sizeof(cls
);
601 cls
.hInstance
= GetModuleHandle(NULL
);
602 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
604 cls
.lpfnWndProc
= pDefWindowProcA
;
606 cls
.lpfnWndProc
= pDefWindowProcW
;
610 cls
.lpszClassName
= classA
;
611 atom
= RegisterClassExA(&cls
);
615 cls
.lpszClassName
= (LPCSTR
)classW
;
616 atom
= RegisterClassExW((WNDCLASSEXW
*)&cls
);
618 ok(atom
!= 0, "Couldn't register class, i=%d, %d\n", i
, GetLastError());
620 hwnd
= CreateWindowA(classA
, NULL
, 0, 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), NULL
);
621 ok(hwnd
!= NULL
, "Couldn't create window i=%d\n", i
);
623 ok(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcA
, "Wrong ANSI wndproc: %p vs %p\n",
624 (void *)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), pDefWindowProcA
);
625 ok(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
) == (ULONG_PTR
)pDefWindowProcA
, "Wrong ANSI wndproc: %p vs %p\n",
626 (void *)GetClassLongPtrA(hwnd
, GCLP_WNDPROC
), pDefWindowProcA
);
628 ok(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcW
, "Wrong Unicode wndproc: %p vs %p\n",
629 (void *)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), pDefWindowProcW
);
630 ok(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
) == (ULONG_PTR
)pDefWindowProcW
, "Wrong Unicode wndproc: %p vs %p\n",
631 (void *)GetClassLongPtrW(hwnd
, GCLP_WNDPROC
), pDefWindowProcW
);
634 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
637 /* built-in winproc - window A/W type automatically detected */
638 ZeroMemory(&cls
, sizeof(cls
));
639 cls
.cbSize
= sizeof(cls
);
640 cls
.hInstance
= GetModuleHandle(NULL
);
641 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
642 cls
.lpszClassName
= classA
;
643 cls
.lpfnWndProc
= pDefWindowProcW
;
644 atom
= RegisterClassExA(&cls
);
646 hwnd
= CreateWindowExW(0, classW
, NULL
, WS_OVERLAPPEDWINDOW
,
647 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
648 ok(IsWindowUnicode(hwnd
), "Windows should be Unicode\n");
649 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)pDefWindowProcA
);
650 ok(IsWindowUnicode(hwnd
), "Windows should have remained Unicode\n");
651 ok(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcW
, "Invalid ANSI winproc\n");
652 ok(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcA
, "Invalid Unicode winproc\n");
653 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
654 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have switched window to ANSI\n");
657 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
659 /* custom winproc - the same function can be used as both A and W*/
660 ZeroMemory(&cls
, sizeof(cls
));
661 cls
.cbSize
= sizeof(cls
);
662 cls
.hInstance
= GetModuleHandle(NULL
);
663 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
664 cls
.lpszClassName
= classA
;
665 cls
.lpfnWndProc
= ClassTest_WndProc2
;
666 atom
= RegisterClassExA(&cls
);
668 hwnd
= CreateWindowExW(0, classW
, NULL
, WS_OVERLAPPEDWINDOW
,
669 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
670 ok(IsWindowUnicode(hwnd
) == FALSE
, "Window should be ANSI\n");
671 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
672 ok(IsWindowUnicode(hwnd
), "SetWindowLongPtrW should have changed window to Unicode\n");
673 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
674 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have changed window to ANSI\n");
677 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
679 /* For most of the builtin controls both GetWindowLongPtrA and W returns a pointer that is executed directly
680 * by CallWindowProcA/W */
681 for (i
= 0; i
< NUM_NORMAL_CLASSES
; i
++)
683 WNDPROC procA
, procW
;
684 hwnd
= CreateWindowExA(0, NORMAL_CLASSES
[i
], classA
, WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260,
685 NULL
, NULL
, NULL
, 0);
686 ok(hwnd
!= NULL
, "Couldn't create window of class %s\n", NORMAL_CLASSES
[i
]);
687 SetWindowText(hwnd
, classA
); /* ComboBox needs this */
688 procA
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
689 procW
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
690 ok(!IS_WNDPROC_HANDLE(procA
), "procA should not be a handle for %s (%p)\n", NORMAL_CLASSES
[i
], procA
);
691 ok(!IS_WNDPROC_HANDLE(procW
), "procW should not be a handle for %s (%p)\n", NORMAL_CLASSES
[i
], procW
);
692 CallWindowProcA(procA
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
693 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT A/A invalid return for class %s\n", NORMAL_CLASSES
[i
]);
694 CallWindowProcA(procW
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
695 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT A/W invalid return for class %s\n", NORMAL_CLASSES
[i
]);
696 CallWindowProcW(procA
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
697 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT W/A invalid return for class %s\n", NORMAL_CLASSES
[i
]);
698 CallWindowProcW(procW
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
699 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT W/W invalid return for class %s\n", NORMAL_CLASSES
[i
]);
701 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
702 ok(IS_WNDPROC_HANDLE(oldproc
) == FALSE
, "Class %s shouldn't return a handle\n", NORMAL_CLASSES
[i
]);
706 /* Edit controls are special - they return a wndproc handle when GetWindowLongPtr is called with a different A/W.
707 * On the other hand there is no W->A->W conversion so this control is treated specially. */
708 hwnd
= CreateWindowW(WC_EDITW
, unistring
, WS_OVERLAPPEDWINDOW
,
709 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, NULL
, 0);
710 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
711 ok(IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
)) == FALSE
, "Edit control class should have a Unicode wndproc\n");
712 ok(IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
)) == FALSE
, "Edit control class should have a ANSI wndproc\n");
713 /* But GetWindowLongPtr returns only a handle for the ANSI one */
714 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
)), "Edit control should return a wndproc handle\n");
715 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
)), "Edit control shouldn't return a W wndproc handle\n");
716 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
717 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
718 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
719 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
720 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
721 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
723 SetWindowTextW(hwnd
, classW
);
724 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
725 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
727 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc2
);
728 /* SetWindowLongPtr returns a wndproc handle - like GetWindowLongPtr */
729 ok(IS_WNDPROC_HANDLE(oldproc
), "Edit control should return a wndproc handle\n");
730 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have changed window to ANSI\n");
731 SetWindowTextA(hwnd
, classA
); /* Windows resets the title to WideStringToMultiByte(unistring) */
732 memset(buf
, 0, sizeof(buf
));
733 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
734 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
735 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
736 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
737 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
738 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
740 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
741 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT invalid return\n");
745 hwnd
= CreateWindowA(WC_EDITA
, classA
, WS_OVERLAPPEDWINDOW
,
746 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, NULL
, 0);
748 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
749 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
)), "Edit control class should have a Unicode wndproc\n");
750 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
)), "Edit control class should have a ANSI wndproc\n");
751 /* But GetWindowLongPtr returns only a handle for the Unicode one */
752 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
)), "Edit control shouldn't return an A wndproc handle\n");
753 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
)), "Edit control should return a wndproc handle\n");
754 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
755 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
756 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
757 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
758 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
759 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
761 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
762 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT invalid return\n");
764 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
765 SetWindowTextW(hwnd
, unistring
);
766 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
767 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
768 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
769 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
770 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
771 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
773 SetWindowTextW(hwnd
, classW
);
774 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
775 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
781 static LRESULT WINAPI
TestDlgProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
783 return DefWindowProc(hWnd
, uMsg
, wParam
, lParam
);
786 static BOOL
RegisterTestDialog(HINSTANCE hInstance
)
791 ZeroMemory(&wcx
, sizeof(WNDCLASSEX
));
792 wcx
.cbSize
= sizeof(wcx
);
793 wcx
.lpfnWndProc
= TestDlgProc
;
795 wcx
.cbWndExtra
= DLGWINDOWEXTRA
;
796 wcx
.hInstance
= hInstance
;
797 wcx
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
798 wcx
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
799 wcx
.hbrBackground
= (HBRUSH
)GetStockObject(WHITE_BRUSH
);
800 wcx
.lpszClassName
= "TestDialog";
801 wcx
.lpszMenuName
= "TestDialog";
802 wcx
.hIconSm
= (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(5),
804 GetSystemMetrics(SM_CXSMICON
),
805 GetSystemMetrics(SM_CYSMICON
),
808 atom
= RegisterClassEx(&wcx
);
809 ok(atom
!= 0, "RegisterClassEx returned 0\n");
814 /* test registering a dialog box created by using the CLASS directive in a
815 resource file, then test creating the dialog using CreateDialogParam. */
816 static void WINAPI
CreateDialogParamTest(HINSTANCE hInstance
)
820 if (RegisterTestDialog(hInstance
))
822 hWndMain
= CreateDialogParam(hInstance
, "CLASS_TEST_DIALOG", NULL
, 0, 0);
823 ok(hWndMain
!= NULL
, "CreateDialogParam returned NULL\n");
824 ShowWindow(hWndMain
, SW_SHOW
);
825 DestroyWindow(hWndMain
);
831 HANDLE hInstance
= GetModuleHandleA( NULL
);
833 if (!GetModuleHandleW(0))
835 trace("Class test is incompatible with Win9x implementation, skipping\n");
839 ClassTest(hInstance
,FALSE
);
840 ClassTest(hInstance
,TRUE
);
841 CreateDialogParamTest(hInstance
);
845 /* this test unregisters the Button class so it should be executed at the end */