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) == (~0u >> 16))
44 static LRESULT WINAPI
ClassTest_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
46 if (msg
== WM_NCCREATE
) return 1;
47 return DefWindowProcW (hWnd
, msg
, wParam
, lParam
);
50 static LRESULT WINAPI
ClassTest_WndProc2 (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
52 if (msg
== WM_NCCREATE
) return 1;
53 return DefWindowProcA (hWnd
, msg
, wParam
, lParam
);
56 /***********************************************************************
58 static void ClassTest(HINSTANCE hInstance
, BOOL global
)
61 static const WCHAR className
[] = {'T','e','s','t','C','l','a','s','s',0};
62 static const WCHAR winName
[] = {'W','i','n','C','l','a','s','s','T','e','s','t',0};
69 cls
.style
= CS_HREDRAW
| CS_VREDRAW
| (global
?CS_GLOBALCLASS
:0);
70 cls
.lpfnWndProc
= ClassTest_WndProc
;
71 cls
.cbClsExtra
= NUMCLASSWORDS
*sizeof(DWORD
);
73 cls
.hInstance
= hInstance
;
74 cls
.hIcon
= LoadIconW (0, (LPWSTR
)IDI_APPLICATION
);
75 cls
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
76 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
78 cls
.lpszClassName
= className
;
80 classatom
=RegisterClassW(&cls
);
81 if (!classatom
&& GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
83 ok(classatom
, "failed to register class\n");
85 ok(!RegisterClassW (&cls
),
86 "RegisterClass of the same class should fail for the second time\n");
89 hTestWnd
= CreateWindowW (className
, winName
,
90 WS_OVERLAPPEDWINDOW
+ WS_HSCROLL
+ WS_VSCROLL
,
91 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
94 ok(hTestWnd
!=0, "Failed to create window\n");
96 /* test initial values of valid classwords */
97 for(i
=0; i
<NUMCLASSWORDS
; i
++)
100 ok(!GetClassLongW(hTestWnd
,i
*sizeof (DWORD
)),
101 "GetClassLongW initial value nonzero!\n");
103 "GetClassLongW failed!\n");
109 * GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD))
110 * does not fail on Win 98, though MSDN says it should
113 GetClassLongW(hTestWnd
, NUMCLASSWORDS
*sizeof(DWORD
));
115 "GetClassLongW() with invalid offset did not fail\n");
118 /* set values of valid class words */
119 for(i
=0; i
<NUMCLASSWORDS
; i
++)
122 ok(!SetClassLongW(hTestWnd
,i
*sizeof(DWORD
),i
+1),
123 "GetClassLongW(%d) initial value nonzero!\n",i
);
125 "SetClassLongW(%d) failed!\n",i
);
128 /* test values of valid classwords that we set */
129 for(i
=0; i
<NUMCLASSWORDS
; i
++)
132 ok( (i
+1) == GetClassLongW(hTestWnd
,i
*sizeof (DWORD
)),
133 "GetClassLongW value doesn't match what was set!\n");
135 "GetClassLongW failed!\n");
138 /* check GetClassName */
139 i
= GetClassNameW(hTestWnd
, str
, sizeof(str
)/sizeof(str
[0]));
140 ok(i
== lstrlenW(className
),
141 "GetClassName returned incorrect length\n");
142 ok(!lstrcmpW(className
,str
),
143 "GetClassName returned incorrect name for this window's class\n");
145 /* check GetClassInfo with our hInstance */
146 if((test_atom
= GetClassInfoW(hInstance
, str
, &wc
)))
148 ok(test_atom
== classatom
,
149 "class atom did not match\n");
150 ok(wc
.cbClsExtra
== cls
.cbClsExtra
,
151 "cbClsExtra did not match\n");
152 ok(wc
.cbWndExtra
== cls
.cbWndExtra
,
153 "cbWndExtra did not match\n");
154 ok(wc
.hbrBackground
== cls
.hbrBackground
,
155 "hbrBackground did not match\n");
156 ok(wc
.hCursor
== cls
.hCursor
,
157 "hCursor did not match\n");
158 ok(wc
.hInstance
== cls
.hInstance
,
159 "hInstance did not match\n");
162 ok(FALSE
,"GetClassInfo (hinstance) failed!\n");
164 /* check GetClassInfo with zero hInstance */
167 if((test_atom
= GetClassInfoW(0, str
, &wc
)))
169 ok(test_atom
== classatom
,
170 "class atom did not match %x != %x\n", test_atom
, classatom
);
171 ok(wc
.cbClsExtra
== cls
.cbClsExtra
,
172 "cbClsExtra did not match %x!=%x\n",wc
.cbClsExtra
,cls
.cbClsExtra
);
173 ok(wc
.cbWndExtra
== cls
.cbWndExtra
,
174 "cbWndExtra did not match %x!=%x\n",wc
.cbWndExtra
,cls
.cbWndExtra
);
175 ok(wc
.hbrBackground
== cls
.hbrBackground
,
176 "hbrBackground did not match %p!=%p\n",wc
.hbrBackground
,cls
.hbrBackground
);
177 ok(wc
.hCursor
== cls
.hCursor
,
178 "hCursor did not match %p!=%p\n",wc
.hCursor
,cls
.hCursor
);
180 "hInstance not zero for global class %p\n",wc
.hInstance
);
183 ok(FALSE
,"GetClassInfo (0) failed for global class!\n");
187 ok(!GetClassInfoW(0, str
, &wc
),
188 "GetClassInfo (0) succeeded for local class!\n");
191 ok(!UnregisterClassW(className
, hInstance
),
192 "Unregister class succeeded with window existing\n");
194 ok(DestroyWindow(hTestWnd
),
195 "DestroyWindow() failed!\n");
197 ok(UnregisterClassW(className
, hInstance
),
198 "UnregisterClass() failed\n");
203 static void check_style( const char *name
, int must_exist
, UINT style
, UINT ignore
)
207 if (GetClassInfo( 0, name
, &wc
))
209 ok( !(~wc
.style
& style
& ~ignore
), "System class %s is missing bits %x (%08x/%08x)\n",
210 name
, ~wc
.style
& style
, wc
.style
, style
);
211 ok( !(wc
.style
& ~style
), "System class %s has extra bits %x (%08x/%08x)\n",
212 name
, wc
.style
& ~style
, wc
.style
, style
);
215 ok( !must_exist
, "System class %s does not exist\n", name
);
218 /* test styles of system classes */
219 static void test_styles(void)
221 /* check style bits */
222 check_style( "Button", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
223 check_style( "ComboBox", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
224 check_style( "Edit", 1, CS_PARENTDC
| CS_DBLCLKS
, 0 );
225 check_style( "ListBox", 1, CS_PARENTDC
| CS_DBLCLKS
, CS_PARENTDC
/*FIXME*/ );
226 check_style( "MDIClient", 1, 0, 0 );
227 check_style( "ScrollBar", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, 0 );
228 check_style( "Static", 1, CS_PARENTDC
| CS_DBLCLKS
, 0 );
229 check_style( "ComboLBox", 1, CS_SAVEBITS
| CS_DBLCLKS
, 0 );
230 check_style( "DDEMLEvent", 0, 0, 0 );
231 check_style( "Message", 0, 0, 0 );
232 check_style( "#32768", 1, CS_DROPSHADOW
| CS_SAVEBITS
| CS_DBLCLKS
, CS_DROPSHADOW
); /* menu */
233 check_style( "#32769", 1, CS_DBLCLKS
, 0 ); /* desktop */
234 check_style( "#32770", 1, CS_SAVEBITS
| CS_DBLCLKS
, 0 ); /* dialog */
235 todo_wine
{ check_style( "#32771", 1, CS_SAVEBITS
| CS_HREDRAW
| CS_VREDRAW
, 0 ); } /* task switch */
236 check_style( "#32772", 1, 0, 0 ); /* icon title */
239 static void check_class_(int line
, HINSTANCE inst
, const char *name
, const char *menu_name
)
242 UINT atom
= GetClassInfo(inst
,name
,&wc
);
243 ok_(__FILE__
,line
)( atom
, "Class %s %p not found\n", name
, inst
);
246 if (wc
.lpszMenuName
&& menu_name
)
247 ok_(__FILE__
,line
)( !strcmp( menu_name
, wc
.lpszMenuName
),
248 "Wrong name %s/%s for class %s %p\n",
249 wc
.lpszMenuName
, menu_name
, name
, inst
);
251 ok_(__FILE__
,line
)( !menu_name
== !wc
.lpszMenuName
, "Wrong name %p/%p for class %s %p\n",
252 wc
.lpszMenuName
, menu_name
, name
, inst
);
255 #define check_class(inst,name,menu) check_class_(__LINE__,inst,name,menu)
257 static void check_instance_( int line
, const char *name
, HINSTANCE inst
,
258 HINSTANCE info_inst
, HINSTANCE gcl_inst
)
263 ok_(__FILE__
,line
)( GetClassInfo( inst
, name
, &wc
), "Couldn't find class %s inst %p\n", name
, inst
);
264 ok_(__FILE__
,line
)( wc
.hInstance
== info_inst
, "Wrong info instance %p/%p for class %s\n",
265 wc
.hInstance
, info_inst
, name
);
266 hwnd
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, inst
, 0 );
267 ok_(__FILE__
,line
)( hwnd
!= NULL
, "Couldn't create window for class %s inst %p\n", name
, inst
);
268 ok_(__FILE__
,line
)( (HINSTANCE
)GetClassLongPtrA( hwnd
, GCLP_HMODULE
) == gcl_inst
,
269 "Wrong GCL instance %p/%p for class %s\n",
270 (HINSTANCE
)GetClassLongPtrA( hwnd
, GCLP_HMODULE
), gcl_inst
, name
);
271 ok_(__FILE__
,line
)( (HINSTANCE
)GetWindowLongPtrA( hwnd
, GWLP_HINSTANCE
) == inst
,
272 "Wrong GWL instance %p/%p for window %s\n",
273 (HINSTANCE
)GetWindowLongPtrA( hwnd
, GWLP_HINSTANCE
), inst
, name
);
274 ok_(__FILE__
,line
)(!UnregisterClassA(name
, inst
),
275 "UnregisterClassA should fail while exists a class window\n");
276 ok_(__FILE__
,line
)(GetLastError() == ERROR_CLASS_HAS_WINDOWS
,
277 "GetLastError() should be set to ERROR_CLASS_HAS_WINDOWS not %d\n", GetLastError());
280 #define check_instance(name,inst,info_inst,gcl_inst) check_instance_(__LINE__,name,inst,info_inst,gcl_inst)
285 HINSTANCE inst
, info_inst
, gcl_inst
;
288 static DWORD WINAPI
thread_proc(void *param
)
290 struct class_info
*class_info
= param
;
292 check_instance(class_info
->name
, class_info
->inst
, class_info
->info_inst
, class_info
->gcl_inst
);
297 static void check_thread_instance( const char *name
, HINSTANCE inst
, HINSTANCE info_inst
, HINSTANCE gcl_inst
)
301 struct class_info class_info
;
303 class_info
.name
= name
;
304 class_info
.inst
= inst
;
305 class_info
.info_inst
= info_inst
;
306 class_info
.gcl_inst
= gcl_inst
;
308 hThread
= CreateThread(NULL
, 0, thread_proc
, &class_info
, 0, &tid
);
309 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
310 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
311 CloseHandle(hThread
);
314 /* test various instance parameters */
315 static void test_instances(void)
319 const char *name
= "__test__";
320 HINSTANCE kernel32
= GetModuleHandleA("kernel32");
321 HINSTANCE user32
= GetModuleHandleA("user32");
322 HINSTANCE main_module
= GetModuleHandleA(NULL
);
323 HINSTANCE zero_instance
= 0;
327 memset( &cls
, 0, sizeof(cls
) );
328 cls
.style
= CS_HREDRAW
| CS_VREDRAW
;
329 cls
.lpfnWndProc
= ClassTest_WndProc
;
332 cls
.lpszClassName
= name
;
334 cls
.lpszMenuName
= "main_module";
335 cls
.hInstance
= main_module
;
337 ok( RegisterClassA( &cls
), "Failed to register local class for main module\n" );
338 check_class( main_module
, name
, "main_module" );
339 check_instance( name
, main_module
, main_module
, main_module
);
340 check_thread_instance( name
, main_module
, main_module
, main_module
);
342 cls
.lpszMenuName
= "kernel32";
343 cls
.hInstance
= kernel32
;
344 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
345 check_class( kernel32
, name
, "kernel32" );
346 check_class( main_module
, name
, "main_module" );
347 check_instance( name
, kernel32
, kernel32
, kernel32
);
348 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
349 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
351 /* Bug 2631 - Supplying an invalid number of bytes fails */
354 SetLastError(0xdeadbeef);
355 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
356 "Failed with invalid number of WndExtra bytes\n");
360 SetLastError(0xdeadbeef);
361 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
362 "Failed with invalid number of ClsExtra bytes\n");
366 SetLastError(0xdeadbeef);
367 ok( ((RegisterClassA( &cls
) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER
)),
368 "Failed with invalid number of ClsExtra and cbWndExtra bytes\n");
372 SetLastError(0xdeadbeef);
374 /* setting global flag doesn't change status of class */
375 hwnd
= CreateWindowExA( 0, name
, "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
376 ok( hwnd
!= 0, "CreateWindow failed error %u\n", GetLastError());
377 SetClassLongA( hwnd
, GCL_STYLE
, CS_GLOBALCLASS
);
378 cls
.lpszMenuName
= "kernel32";
379 cls
.hInstance
= kernel32
;
380 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
381 check_class( kernel32
, name
, "kernel32" );
382 check_class( main_module
, name
, "main_module" );
383 check_instance( name
, kernel32
, kernel32
, kernel32
);
384 check_instance( name
, main_module
, main_module
, main_module
);
385 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
386 check_thread_instance( name
, main_module
, main_module
, main_module
);
387 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
389 /* changing the instance doesn't make it global */
390 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0 );
391 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
392 check_class( kernel32
, name
, "kernel32" );
393 check_instance( name
, kernel32
, kernel32
, kernel32
);
394 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
395 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
396 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
398 /* GetClassInfo with instance 0 finds user32 instance */
399 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, (LONG_PTR
)user32
);
400 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
401 if (!GetClassInfo( 0, name
, &wc
)) zero_instance
= user32
; /* instance 0 not supported on wow64 */
404 check_instance( name
, 0, 0, kernel32
);
405 check_thread_instance( name
, 0, 0, kernel32
);
407 check_class( kernel32
, name
, "kernel32" );
408 check_class( user32
, name
, "main_module" );
409 check_class( zero_instance
, name
, "main_module" );
410 check_instance( name
, kernel32
, kernel32
, kernel32
);
411 check_instance( name
, user32
, zero_instance
, user32
);
412 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
413 check_thread_instance( name
, user32
, zero_instance
, user32
);
414 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
416 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0x12345678 );
417 ok( RegisterClassA( &cls
), "Failed to register local class for kernel32\n" );
418 check_class( kernel32
, name
, "kernel32" );
419 check_class( (HINSTANCE
)0x12345678, name
, "main_module" );
420 check_instance( name
, kernel32
, kernel32
, kernel32
);
421 check_instance( name
, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678 );
422 check_thread_instance( name
, kernel32
, kernel32
, kernel32
);
423 check_thread_instance( name
, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678 );
424 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
426 /* creating a window with instance 0 uses the first class found */
427 cls
.hInstance
= (HINSTANCE
)0xdeadbeef;
428 cls
.lpszMenuName
= "deadbeef";
430 ok( RegisterClassA( &cls
), "Failed to register local class for deadbeef\n" );
431 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
432 ok( GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == 0xdeadbeef,
433 "Didn't get deadbeef class for null instance\n" );
434 DestroyWindow( hwnd2
);
435 ok( UnregisterClassA( name
, (HINSTANCE
)0xdeadbeef ), "Unregister failed for deadbeef\n" );
437 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
438 ok( (HINSTANCE
)GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == kernel32
,
439 "Didn't get kernel32 class for null instance\n" );
440 DestroyWindow( hwnd2
);
442 r
= GetClassName( hwnd
, buffer
, 4 );
443 ok( r
== 3, "expected 3, got %d\n", r
);
444 ok( !strcmp( buffer
, "__t"), "name wrong: %s\n", buffer
);
446 ok( UnregisterClassA( name
, kernel32
), "Unregister failed for kernel32\n" );
448 hwnd2
= CreateWindowExA( 0, name
, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL
, 0 );
449 ok( GetClassLongPtrA( hwnd2
, GCLP_HMODULE
) == 0x12345678,
450 "Didn't get 12345678 class for null instance\n" );
451 DestroyWindow( hwnd2
);
453 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, (LONG_PTR
)main_module
);
454 DestroyWindow( hwnd
);
456 /* null handle means the same thing as main module */
457 cls
.lpszMenuName
= "null";
459 ok( !RegisterClassA( &cls
), "Succeeded registering local class for null instance\n" );
460 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
461 ok( UnregisterClassA( name
, main_module
), "Unregister failed for main module\n" );
463 ok( RegisterClassA( &cls
), "Failed to register local class for null instance\n" );
464 /* must be found with main module handle */
465 check_class( main_module
, name
, "null" );
466 check_instance( name
, main_module
, main_module
, main_module
);
467 check_thread_instance( name
, main_module
, main_module
, main_module
);
468 ok( !GetClassInfo( 0, name
, &wc
), "Class found with null instance\n" );
469 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
470 ok( UnregisterClassA( name
, 0 ), "Unregister failed for null instance\n" );
472 /* registering for user32 always fails */
473 cls
.lpszMenuName
= "user32";
474 cls
.hInstance
= user32
;
475 ok( !RegisterClassA( &cls
), "Succeeded registering local class for user32\n" );
476 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong error code %d\n", GetLastError() );
477 cls
.style
|= CS_GLOBALCLASS
;
478 ok( !RegisterClassA( &cls
), "Succeeded registering global class for user32\n" );
479 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "Wrong error code %d\n", GetLastError() );
481 /* unregister is OK though */
482 cls
.hInstance
= main_module
;
483 ok( RegisterClassA( &cls
), "Failed to register global class for main module\n" );
484 ok( UnregisterClassA( name
, user32
), "Unregister failed for user32\n" );
486 /* instance doesn't matter for global class */
487 cls
.style
|= CS_GLOBALCLASS
;
488 cls
.lpszMenuName
= "main_module";
489 cls
.hInstance
= main_module
;
490 ok( RegisterClassA( &cls
), "Failed to register global class for main module\n" );
491 cls
.lpszMenuName
= "kernel32";
492 cls
.hInstance
= kernel32
;
493 ok( !RegisterClassA( &cls
), "Succeeded registering local class for kernel32\n" );
494 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
495 /* even if global flag is cleared */
496 hwnd
= CreateWindowExA( 0, name
, "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
497 SetClassLongA( hwnd
, GCL_STYLE
, 0 );
498 ok( !RegisterClassA( &cls
), "Succeeded registering local class for kernel32\n" );
499 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
501 check_class( main_module
, name
, "main_module" );
502 check_class( kernel32
, name
, "main_module" );
503 check_class( 0, name
, "main_module" );
504 check_class( (HINSTANCE
)0x12345678, name
, "main_module" );
505 check_instance( name
, main_module
, main_module
, main_module
);
506 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, main_module
);
507 check_thread_instance( name
, main_module
, main_module
, main_module
);
508 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, main_module
);
510 /* changing the instance for global class doesn't make much difference */
511 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0xdeadbeef );
512 check_instance( name
, main_module
, main_module
, (HINSTANCE
)0xdeadbeef );
513 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef );
514 check_thread_instance( name
, main_module
, main_module
, (HINSTANCE
)0xdeadbeef );
515 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef );
517 DestroyWindow( hwnd
);
518 ok( UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister failed for main module global\n" );
519 ok( !UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister succeeded the second time\n" );
520 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
522 cls
.hInstance
= (HINSTANCE
)0x12345678;
523 ok( RegisterClassA( &cls
), "Failed to register global class for dummy instance\n" );
524 check_instance( name
, main_module
, main_module
, (HINSTANCE
)0x12345678 );
525 check_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0x12345678 );
526 check_thread_instance( name
, main_module
, main_module
, (HINSTANCE
)0x12345678 );
527 check_thread_instance( name
, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0x12345678 );
528 ok( UnregisterClassA( name
, (HINSTANCE
)0x87654321 ), "Unregister failed for main module global\n" );
530 /* check system classes */
532 /* we cannot register a global class with the name of a system class */
533 cls
.style
|= CS_GLOBALCLASS
;
534 cls
.lpszMenuName
= "button_main_module";
535 cls
.lpszClassName
= "BUTTON";
536 cls
.hInstance
= main_module
;
537 ok( !RegisterClassA( &cls
), "Succeeded registering global button class for main module\n" );
538 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
539 cls
.hInstance
= kernel32
;
540 ok( !RegisterClassA( &cls
), "Succeeded registering global button class for kernel32\n" );
541 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS
, "Wrong error code %d\n", GetLastError() );
543 /* local class is OK however */
544 cls
.style
&= ~CS_GLOBALCLASS
;
545 cls
.lpszMenuName
= "button_main_module";
546 cls
.hInstance
= main_module
;
547 ok( RegisterClassA( &cls
), "Failed to register local button class for main module\n" );
548 check_class( main_module
, "BUTTON", "button_main_module" );
549 cls
.lpszMenuName
= "button_kernel32";
550 cls
.hInstance
= kernel32
;
551 ok( RegisterClassA( &cls
), "Failed to register local button class for kernel32\n" );
552 check_class( kernel32
, "BUTTON", "button_kernel32" );
553 check_class( main_module
, "BUTTON", "button_main_module" );
554 ok( UnregisterClassA( "BUTTON", kernel32
), "Unregister failed for kernel32 button\n" );
555 ok( UnregisterClassA( "BUTTON", main_module
), "Unregister failed for main module button\n" );
556 /* GetClassInfo sets instance to passed value for global classes */
557 check_instance( "BUTTON", 0, 0, user32
);
558 check_instance( "BUTTON", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
559 check_instance( "BUTTON", user32
, zero_instance
, user32
);
560 check_thread_instance( "BUTTON", 0, 0, user32
);
561 check_thread_instance( "BUTTON", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
562 check_thread_instance( "BUTTON", user32
, zero_instance
, user32
);
564 /* we can unregister system classes */
565 ok( GetClassInfo( 0, "BUTTON", &wc
), "Button class not found with null instance\n" );
566 ok( GetClassInfo( kernel32
, "BUTTON", &wc
), "Button class not found with kernel32\n" );
567 ok( UnregisterClass( "BUTTON", (HINSTANCE
)0x12345678 ), "Failed to unregister button\n" );
568 ok( !UnregisterClass( "BUTTON", (HINSTANCE
)0x87654321 ), "Unregistered button a second time\n" );
569 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
, "Wrong error code %d\n", GetLastError() );
570 ok( !GetClassInfo( 0, "BUTTON", &wc
), "Button still exists\n" );
571 /* last error not set reliably */
573 /* we can change the instance of a system class */
574 check_instance( "EDIT", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
575 check_thread_instance( "EDIT", (HINSTANCE
)0xdeadbeef, (HINSTANCE
)0xdeadbeef, user32
);
576 hwnd
= CreateWindowExA( 0, "EDIT", "test", 0, 0, 0, 0, 0, 0, 0, main_module
, 0 );
577 SetClassLongPtrA( hwnd
, GCLP_HMODULE
, 0xdeadbeef );
578 check_instance( "EDIT", (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0xdeadbeef );
579 check_thread_instance( "EDIT", (HINSTANCE
)0x12345678, (HINSTANCE
)0x12345678, (HINSTANCE
)0xdeadbeef );
583 static void test_builtinproc(void)
585 /* Edit behaves differently */
586 static const CHAR NORMAL_CLASSES
[][10] = {
593 "#32770", /* dialog */
595 static const int NUM_NORMAL_CLASSES
= (sizeof(NORMAL_CLASSES
)/sizeof(NORMAL_CLASSES
[0]));
596 static const char classA
[] = "deftest";
597 static const WCHAR classW
[] = {'d','e','f','t','e','s','t',0};
598 WCHAR unistring
[] = {0x142, 0x40e, 0x3b4, 0}; /* a string that would be destroyed by a W->A->W conversion */
599 WNDPROC pDefWindowProcA
, pDefWindowProcW
;
601 WNDCLASSEXA cls
; /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */
607 pDefWindowProcA
= (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcA");
608 pDefWindowProcW
= (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcW");
610 for (i
= 0; i
< 4; i
++)
612 ZeroMemory(&cls
, sizeof(cls
));
613 cls
.cbSize
= sizeof(cls
);
614 cls
.hInstance
= GetModuleHandle(NULL
);
615 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
617 cls
.lpfnWndProc
= pDefWindowProcA
;
619 cls
.lpfnWndProc
= pDefWindowProcW
;
623 cls
.lpszClassName
= classA
;
624 atom
= RegisterClassExA(&cls
);
628 cls
.lpszClassName
= (LPCSTR
)classW
;
629 atom
= RegisterClassExW((WNDCLASSEXW
*)&cls
);
631 ok(atom
!= 0, "Couldn't register class, i=%d, %d\n", i
, GetLastError());
633 hwnd
= CreateWindowA(classA
, NULL
, 0, 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), NULL
);
634 ok(hwnd
!= NULL
, "Couldn't create window i=%d\n", i
);
636 ok(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcA
, "Wrong ANSI wndproc: %p vs %p\n",
637 (void *)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), pDefWindowProcA
);
638 ok(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
) == (ULONG_PTR
)pDefWindowProcA
, "Wrong ANSI wndproc: %p vs %p\n",
639 (void *)GetClassLongPtrA(hwnd
, GCLP_WNDPROC
), pDefWindowProcA
);
641 ok(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcW
, "Wrong Unicode wndproc: %p vs %p\n",
642 (void *)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), pDefWindowProcW
);
643 ok(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
) == (ULONG_PTR
)pDefWindowProcW
, "Wrong Unicode wndproc: %p vs %p\n",
644 (void *)GetClassLongPtrW(hwnd
, GCLP_WNDPROC
), pDefWindowProcW
);
647 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
650 /* built-in winproc - window A/W type automatically detected */
651 ZeroMemory(&cls
, sizeof(cls
));
652 cls
.cbSize
= sizeof(cls
);
653 cls
.hInstance
= GetModuleHandle(NULL
);
654 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
655 cls
.lpszClassName
= classA
;
656 cls
.lpfnWndProc
= pDefWindowProcW
;
657 atom
= RegisterClassExA(&cls
);
659 hwnd
= CreateWindowExW(0, classW
, NULL
, WS_OVERLAPPEDWINDOW
,
660 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
661 ok(IsWindowUnicode(hwnd
), "Windows should be Unicode\n");
662 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)pDefWindowProcA
);
663 ok(IsWindowUnicode(hwnd
), "Windows should have remained Unicode\n");
664 if (GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcA
)
666 /* DefWindowProc isn't magic on wow64 */
667 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
)), "Ansi winproc is not a handle\n");
671 ok(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcW
, "Invalid Unicode winproc\n");
672 ok(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
) == (LONG_PTR
)pDefWindowProcA
, "Invalid Ansi winproc\n");
674 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
675 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have switched window to ANSI\n");
678 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
680 /* custom winproc - the same function can be used as both A and W*/
681 ZeroMemory(&cls
, sizeof(cls
));
682 cls
.cbSize
= sizeof(cls
);
683 cls
.hInstance
= GetModuleHandle(NULL
);
684 cls
.hbrBackground
= GetStockObject (WHITE_BRUSH
);
685 cls
.lpszClassName
= classA
;
686 cls
.lpfnWndProc
= ClassTest_WndProc2
;
687 atom
= RegisterClassExA(&cls
);
689 hwnd
= CreateWindowExW(0, classW
, NULL
, WS_OVERLAPPEDWINDOW
,
690 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
691 ok(IsWindowUnicode(hwnd
) == FALSE
, "Window should be ANSI\n");
692 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
693 ok(IsWindowUnicode(hwnd
), "SetWindowLongPtrW should have changed window to Unicode\n");
694 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
695 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have changed window to ANSI\n");
698 UnregisterClass((LPSTR
)(DWORD_PTR
)atom
, GetModuleHandle(NULL
));
700 /* For most of the builtin controls both GetWindowLongPtrA and W returns a pointer that is executed directly
701 * by CallWindowProcA/W */
702 for (i
= 0; i
< NUM_NORMAL_CLASSES
; i
++)
704 WNDPROC procA
, procW
;
705 hwnd
= CreateWindowExA(0, NORMAL_CLASSES
[i
], classA
, WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260,
706 NULL
, NULL
, NULL
, 0);
707 ok(hwnd
!= NULL
, "Couldn't create window of class %s\n", NORMAL_CLASSES
[i
]);
708 SetWindowText(hwnd
, classA
); /* ComboBox needs this */
709 procA
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
710 procW
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
711 ok(!IS_WNDPROC_HANDLE(procA
), "procA should not be a handle for %s (%p)\n", NORMAL_CLASSES
[i
], procA
);
712 ok(!IS_WNDPROC_HANDLE(procW
), "procW should not be a handle for %s (%p)\n", NORMAL_CLASSES
[i
], procW
);
713 CallWindowProcA(procA
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
714 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT A/A invalid return for class %s\n", NORMAL_CLASSES
[i
]);
715 CallWindowProcA(procW
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
716 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT A/W invalid return for class %s\n", NORMAL_CLASSES
[i
]);
717 CallWindowProcW(procA
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
718 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT W/A invalid return for class %s\n", NORMAL_CLASSES
[i
]);
719 CallWindowProcW(procW
, hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
720 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT W/W invalid return for class %s\n", NORMAL_CLASSES
[i
]);
722 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
723 ok(IS_WNDPROC_HANDLE(oldproc
) == FALSE
, "Class %s shouldn't return a handle\n", NORMAL_CLASSES
[i
]);
724 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
728 /* Edit controls are special - they return a wndproc handle when GetWindowLongPtr is called with a different A/W.
729 * On the other hand there is no W->A->W conversion so this control is treated specially. */
730 hwnd
= CreateWindowW(WC_EDITW
, unistring
, WS_OVERLAPPEDWINDOW
,
731 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, NULL
, 0);
732 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
733 ok(IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
)) == FALSE
, "Edit control class should have a Unicode wndproc\n");
734 ok(IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
)) == FALSE
, "Edit control class should have a ANSI wndproc\n");
735 /* But GetWindowLongPtr returns only a handle for the ANSI one */
736 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
)), "Edit control should return a wndproc handle\n");
737 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
)), "Edit control shouldn't return a W wndproc handle\n");
738 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
739 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
740 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
741 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
742 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
743 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
745 SetWindowTextW(hwnd
, classW
);
746 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
747 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
749 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc2
);
750 /* SetWindowLongPtr returns a wndproc handle - like GetWindowLongPtr */
751 ok(IS_WNDPROC_HANDLE(oldproc
), "Edit control should return a wndproc handle\n");
752 ok(IsWindowUnicode(hwnd
) == FALSE
, "SetWindowLongPtrA should have changed window to ANSI\n");
753 SetWindowTextA(hwnd
, classA
); /* Windows resets the title to WideStringToMultiByte(unistring) */
754 memset(buf
, 0, sizeof(buf
));
755 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
756 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
757 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
758 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
759 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
760 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
762 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
763 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT invalid return\n");
765 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
769 hwnd
= CreateWindowA(WC_EDITA
, classA
, WS_OVERLAPPEDWINDOW
,
770 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, NULL
, 0);
772 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
773 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd
, GCLP_WNDPROC
)), "Edit control class should have a Unicode wndproc\n");
774 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd
, GCLP_WNDPROC
)), "Edit control class should have a ANSI wndproc\n");
775 /* But GetWindowLongPtr returns only a handle for the Unicode one */
776 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
)), "Edit control shouldn't return an A wndproc handle\n");
777 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
)), "Edit control should return a wndproc handle\n");
778 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
779 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
780 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
781 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
782 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
783 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
785 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
786 ok(memcmp(buf
, classW
, sizeof(classW
)) == 0, "WM_GETTEXT invalid return\n");
788 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)ClassTest_WndProc
);
789 SetWindowTextW(hwnd
, unistring
);
790 CallWindowProcW((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
791 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
792 CallWindowProcA((WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
793 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
794 CallWindowProcW((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
795 ok(memcmp(buf
, unistring
, sizeof(unistring
)) == 0, "WM_GETTEXT invalid return\n");
797 SetWindowTextW(hwnd
, classW
);
798 CallWindowProcA((WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
), hwnd
, WM_GETTEXT
, 120, (LPARAM
)buf
);
799 ok(memcmp(buf
, classA
, sizeof(classA
)) == 0, "WM_GETTEXT invalid return\n");
801 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
807 static LRESULT WINAPI
TestDlgProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
809 return DefWindowProc(hWnd
, uMsg
, wParam
, lParam
);
812 static BOOL
RegisterTestDialog(HINSTANCE hInstance
)
817 ZeroMemory(&wcx
, sizeof(WNDCLASSEX
));
818 wcx
.cbSize
= sizeof(wcx
);
819 wcx
.lpfnWndProc
= TestDlgProc
;
821 wcx
.cbWndExtra
= DLGWINDOWEXTRA
;
822 wcx
.hInstance
= hInstance
;
823 wcx
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
824 wcx
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
825 wcx
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
826 wcx
.lpszClassName
= "TestDialog";
827 wcx
.lpszMenuName
= "TestDialog";
828 wcx
.hIconSm
= LoadImage(hInstance
, MAKEINTRESOURCE(5), IMAGE_ICON
,
829 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
),
832 atom
= RegisterClassEx(&wcx
);
833 ok(atom
!= 0, "RegisterClassEx returned 0\n");
838 /* test registering a dialog box created by using the CLASS directive in a
839 resource file, then test creating the dialog using CreateDialogParam. */
840 static void CreateDialogParamTest(HINSTANCE hInstance
)
844 if (RegisterTestDialog(hInstance
))
846 hWndMain
= CreateDialogParam(hInstance
, "CLASS_TEST_DIALOG", NULL
, 0, 0);
847 ok(hWndMain
!= NULL
, "CreateDialogParam returned NULL\n");
848 ShowWindow(hWndMain
, SW_SHOW
);
849 DestroyWindow(hWndMain
);
860 {"#32770",30,30}, /* Dialog */
864 {"Edit",6,8}, /* Windows XP 64-bit returns 8 also to 32-bit applications */
868 static void test_extra_values(void)
871 for(i
=0; i
< sizeof(extra_values
)/sizeof(extra_values
[0]); i
++)
874 BOOL ret
= GetClassInfoEx(NULL
,extra_values
[i
].name
,&wcx
);
876 ok( ret
, "GetClassInfo (0) failed for global class %s\n", extra_values
[i
].name
);
878 ok(extra_values
[i
].value
== wcx
.cbWndExtra
|| broken(extra_values
[i
].badvalue
== wcx
.cbWndExtra
),
879 "expected %d, got %d\n", extra_values
[i
].value
, wcx
.cbWndExtra
);
885 HANDLE hInstance
= GetModuleHandleA( NULL
);
889 if (!GetModuleHandleW(0))
891 trace("Class test is incompatible with Win9x implementation, skipping\n");
895 ClassTest(hInstance
,FALSE
);
896 ClassTest(hInstance
,TRUE
);
897 CreateDialogParamTest(hInstance
);
901 /* this test unregisters the Button class so it should be executed at the end */