ReactOS 0.4.15-dev-8127-g6338913
class.c File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include "commctrl.h"
Include dependency graph for class.c:

Go to the source code of this file.

Classes

struct  class_info
 

Macros

#define NUMCLASSWORDS   4
 
#define IS_WNDPROC_HANDLE(x)   (((ULONG_PTR)(x) >> 16) == (~0u >> 16))
 
#define ARCH   "none"
 
#define check_class(inst, name, menu)   check_class_(__LINE__,inst,name,menu)
 
#define check_instance(name, inst, info_inst, gcl_inst)   check_instance_(__LINE__,name,inst,info_inst,gcl_inst)
 

Functions

static LRESULT WINAPI ClassTest_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT WINAPI ClassTest_WndProc2 (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void ClassTest (HINSTANCE hInstance, BOOL global)
 
static void check_style (const char *name, int must_exist, UINT style, UINT ignore)
 
static void test_styles (void)
 
static void check_class_ (int line, HINSTANCE inst, const char *name, const char *menu_name)
 
static void check_instance_ (int line, const char *name, HINSTANCE inst, HINSTANCE info_inst, HINSTANCE gcl_inst)
 
static DWORD WINAPI thread_proc (void *param)
 
static void check_thread_instance (const char *name, HINSTANCE inst, HINSTANCE info_inst, HINSTANCE gcl_inst)
 
static void test_instances (void)
 
static void test_builtinproc (void)
 
static LRESULT WINAPI TestDlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL RegisterTestDialog (HINSTANCE hInstance)
 
static void CreateDialogParamTest (HINSTANCE hInstance)
 
static void test_extra_values (void)
 
static void test_GetClassInfo (void)
 
static void test_icons (void)
 
static void create_manifest_file (const char *filename, const char *manifest)
 
static HANDLE create_test_actctx (const char *file)
 
static void test_comctl32_class (const char *name)
 
static void test_comctl32_classes (void)
 
static void test_IME (void)
 
static void test_actctx_classes (void)
 
 START_TEST (class)
 

Variables

static const char comctl32_manifest []
 
struct {
   const char   name [9]
 
   int   value
 
   int   badvalue
 
extra_values []
 

Macro Definition Documentation

◆ ARCH

#define ARCH   "none"

Definition at line 47 of file class.c.

◆ check_class

#define check_class (   inst,
  name,
  menu 
)    check_class_(__LINE__,inst,name,menu)

Definition at line 289 of file class.c.

◆ check_instance

#define check_instance (   name,
  inst,
  info_inst,
  gcl_inst 
)    check_instance_(__LINE__,name,inst,info_inst,gcl_inst)

Definition at line 314 of file class.c.

◆ IS_WNDPROC_HANDLE

#define IS_WNDPROC_HANDLE (   x)    (((ULONG_PTR)(x) >> 16) == (~0u >> 16))

Definition at line 36 of file class.c.

◆ NUMCLASSWORDS

#define NUMCLASSWORDS   4

Definition at line 34 of file class.c.

Function Documentation

◆ check_class_()

static void check_class_ ( int  line,
HINSTANCE  inst,
const char name,
const char menu_name 
)
static

Definition at line 273 of file class.c.

274{
275 WNDCLASSA wc;
276 UINT atom = GetClassInfoA(inst,name,&wc);
277 ok_(__FILE__,line)( atom, "Class %s %p not found\n", name, inst );
278 if (atom)
279 {
280 if (wc.lpszMenuName && menu_name)
281 ok_(__FILE__,line)( !strcmp( menu_name, wc.lpszMenuName ),
282 "Wrong name %s/%s for class %s %p\n",
283 wc.lpszMenuName, menu_name, name, inst );
284 else
285 ok_(__FILE__,line)( !menu_name == !wc.lpszMenuName, "Wrong name %p/%p for class %s %p\n",
286 wc.lpszMenuName, menu_name, name, inst );
287 }
288}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok_(x1, x2)
Definition: atltest.h:61
unsigned int UINT
Definition: ndis.h:50
LPCSTR lpszMenuName
Definition: winuser.h:3171
Definition: parser.c:49
Definition: name.c:39
BOOL WINAPI GetClassInfoA(_In_opt_ HINSTANCE, _In_ LPCSTR, _Out_ LPWNDCLASSA)

◆ check_instance_()

static void check_instance_ ( int  line,
const char name,
HINSTANCE  inst,
HINSTANCE  info_inst,
HINSTANCE  gcl_inst 
)
static

Definition at line 291 of file class.c.

293{
294 WNDCLASSA wc;
295 HWND hwnd;
296
297 ok_(__FILE__,line)( GetClassInfoA( inst, name, &wc ), "Couldn't find class %s inst %p\n", name, inst );
298 ok_(__FILE__,line)( wc.hInstance == info_inst, "Wrong info instance %p/%p for class %s\n",
299 wc.hInstance, info_inst, name );
300 hwnd = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, inst, 0 );
301 ok_(__FILE__,line)( hwnd != NULL, "Couldn't create window for class %s inst %p\n", name, inst );
302 ok_(__FILE__,line)( (HINSTANCE)GetClassLongPtrA( hwnd, GCLP_HMODULE ) == gcl_inst,
303 "Wrong GCL instance %p/%p for class %s\n",
305 ok_(__FILE__,line)( (HINSTANCE)GetWindowLongPtrA( hwnd, GWLP_HINSTANCE ) == inst,
306 "Wrong GWL instance %p/%p for window %s\n",
308 ok_(__FILE__,line)(!UnregisterClassA(name, inst),
309 "UnregisterClassA should fail while exists a class window\n");
311 "GetLastError() should be set to ERROR_CLASS_HAS_WINDOWS not %d\n", GetLastError());
313}
#define NULL
Definition: types.h:112
HINSTANCE hInstance
Definition: winuser.h:3167
HANDLE HINSTANCE
Definition: typedefs.h:77
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define ERROR_CLASS_HAS_WINDOWS
Definition: winerror.h:893
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
#define GCLP_HMODULE
Definition: winuser.h:676
#define GetWindowLongPtrA
Definition: winuser.h:4828
#define GWLP_HINSTANCE
Definition: winuser.h:856
#define GetClassLongPtrA
Definition: winuser.h:4563
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ check_style()

static void check_style ( const char name,
int  must_exist,
UINT  style,
UINT  ignore 
)
static

Definition at line 237 of file class.c.

238{
239 WNDCLASSA wc;
240
241 if (GetClassInfoA( 0, name, &wc ))
242 {
243 ok( !(~wc.style & style & ~ignore), "System class %s is missing bits %x (%08x/%08x)\n",
244 name, ~wc.style & style, wc.style, style );
245 ok( !(wc.style & ~style), "System class %s has extra bits %x (%08x/%08x)\n",
246 name, wc.style & ~style, wc.style, style );
247 }
248 else
249 ok( !must_exist, "System class %s does not exist\n", name );
250}
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
UINT style
Definition: winuser.h:3163

Referenced by test_styles().

◆ check_thread_instance()

static void check_thread_instance ( const char name,
HINSTANCE  inst,
HINSTANCE  info_inst,
HINSTANCE  gcl_inst 
)
static

Definition at line 331 of file class.c.

332{
334 DWORD tid;
335 struct class_info class_info;
336
341
343 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
344 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
346}
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
static TfClientId tid
static DWORD WINAPI thread_proc(void *param)
Definition: class.c:322
HANDLE hThread
Definition: wizard.c:28
HINSTANCE gcl_inst
Definition: class.c:319
HINSTANCE info_inst
Definition: class.c:319
HINSTANCE inst
Definition: class.c:319
const char * name
Definition: class.c:318
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by test_instances().

◆ ClassTest()

static void ClassTest ( HINSTANCE  hInstance,
BOOL  global 
)
static

Definition at line 88 of file class.c.

89{
90 WNDCLASSW cls, wc;
91 static const WCHAR className[] = {'T','e','s','t','C','l','a','s','s',0};
92 static const WCHAR winName[] = {'W','i','n','C','l','a','s','s','T','e','s','t',0};
93 ATOM test_atom;
94 HWND hTestWnd;
95 LONG i;
96 WCHAR str[20];
97 ATOM classatom;
98
101 cls.cbClsExtra = NUMCLASSWORDS*sizeof(DWORD);
102 cls.cbWndExtra = 12;
103 cls.hInstance = hInstance;
107 cls.lpszMenuName = 0;
108 cls.lpszClassName = className;
109
110 classatom=RegisterClassW(&cls);
111 if (!classatom && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
112 return;
113 ok(classatom, "failed to register class\n");
114
115 ok(GetClipboardFormatNameW(classatom, str, ARRAY_SIZE(str)) != 0, "atom not found\n");
116
117 ok(!RegisterClassW (&cls),
118 "RegisterClass of the same class should fail for the second time\n");
119
120 /* Setup windows */
121 hTestWnd = CreateWindowW (className, winName,
124 0, hInstance, 0);
125
126 ok(hTestWnd!=0, "Failed to create window\n");
127
128 /* test initial values of valid classwords */
129 for(i=0; i<NUMCLASSWORDS; i++)
130 {
131 SetLastError(0);
132 ok(!GetClassLongW(hTestWnd,i*sizeof (DWORD)),
133 "GetClassLongW initial value nonzero!\n");
134 ok(!GetLastError(),
135 "GetClassLongW failed!\n");
136 }
137
138 if (0)
139 {
140 /*
141 * GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD))
142 * does not fail on Win 98, though MSDN says it should
143 */
144 SetLastError(0);
145 GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD));
147 "GetClassLongW() with invalid offset did not fail\n");
148 }
149
150 /* set values of valid class words */
151 for(i=0; i<NUMCLASSWORDS; i++)
152 {
153 SetLastError(0);
154 ok(!SetClassLongW(hTestWnd,i*sizeof(DWORD),i+1),
155 "GetClassLongW(%d) initial value nonzero!\n",i);
156 ok(!GetLastError(),
157 "SetClassLongW(%d) failed!\n",i);
158 }
159
160 /* test values of valid classwords that we set */
161 for(i=0; i<NUMCLASSWORDS; i++)
162 {
163 SetLastError(0);
164 ok( (i+1) == GetClassLongW(hTestWnd,i*sizeof (DWORD)),
165 "GetClassLongW value doesn't match what was set!\n");
166 ok(!GetLastError(),
167 "GetClassLongW failed!\n");
168 }
169
170 /* check GetClassName */
171 i = GetClassNameW(hTestWnd, str, ARRAY_SIZE(str));
172 ok(i == lstrlenW(className),
173 "GetClassName returned incorrect length\n");
174 ok(!lstrcmpW(className,str),
175 "GetClassName returned incorrect name for this window's class\n");
176
177 /* check GetClassInfo with our hInstance */
178 if((test_atom = GetClassInfoW(hInstance, str, &wc)))
179 {
180 ok(test_atom == classatom,
181 "class atom did not match\n");
182 ok(wc.cbClsExtra == cls.cbClsExtra,
183 "cbClsExtra did not match\n");
184 ok(wc.cbWndExtra == cls.cbWndExtra,
185 "cbWndExtra did not match\n");
187 "hbrBackground did not match\n");
188 ok(wc.hCursor== cls.hCursor,
189 "hCursor did not match\n");
190 ok(wc.hInstance== cls.hInstance,
191 "hInstance did not match\n");
192 }
193 else
194 ok(FALSE,"GetClassInfo (hinstance) failed!\n");
195
196 /* check GetClassInfo with zero hInstance */
197 if(global)
198 {
199 if((test_atom = GetClassInfoW(0, str, &wc)))
200 {
201 ok(test_atom == classatom,
202 "class atom did not match %x != %x\n", test_atom, classatom);
203 ok(wc.cbClsExtra == cls.cbClsExtra,
204 "cbClsExtra did not match %x!=%x\n",wc.cbClsExtra,cls.cbClsExtra);
205 ok(wc.cbWndExtra == cls.cbWndExtra,
206 "cbWndExtra did not match %x!=%x\n",wc.cbWndExtra,cls.cbWndExtra);
208 "hbrBackground did not match %p!=%p\n",wc.hbrBackground,cls.hbrBackground);
209 ok(wc.hCursor== cls.hCursor,
210 "hCursor did not match %p!=%p\n",wc.hCursor,cls.hCursor);
211 ok(!wc.hInstance,
212 "hInstance not zero for global class %p\n",wc.hInstance);
213 }
214 else
215 ok(FALSE,"GetClassInfo (0) failed for global class!\n");
216 }
217 else
218 {
219 ok(!GetClassInfoW(0, str, &wc),
220 "GetClassInfo (0) succeeded for local class!\n");
221 }
222
223 ok(!UnregisterClassW(className, hInstance),
224 "Unregister class succeeded with window existing\n");
225
226 ok(DestroyWindow(hTestWnd),
227 "DestroyWindow() failed!\n");
228
229 ok(UnregisterClassW(className, hInstance),
230 "UnregisterClass() failed\n");
231
232 ok(GetClipboardFormatNameW(classatom, str, ARRAY_SIZE(str)) == 0,
233 "atom still found\n");
234 return;
235}
#define ARRAY_SIZE(A)
Definition: main.h:33
HINSTANCE hInstance
Definition: charmap.c:19
WORD ATOM
Definition: dimm.idl:113
#define FALSE
Definition: types.h:117
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752
#define lstrlenW
Definition: compat.h:750
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
int global
Definition: ehframes.cpp:22
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NUMCLASSWORDS
Definition: class.c:34
static LRESULT WINAPI ClassTest_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: class.c:74
#define DWORD
Definition: nt_native.h:44
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VSCROLL
Definition: pedump.c:627
long LONG
Definition: pedump.c:60
#define WS_HSCROLL
Definition: pedump.c:628
const WCHAR * str
LPCWSTR lpszClassName
Definition: winuser.h:3185
LPCWSTR lpszMenuName
Definition: winuser.h:3184
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define IDI_APPLICATION
Definition: winuser.h:704
DWORD WINAPI SetClassLongW(_In_ HWND, _In_ int, _In_ LONG)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#define CW_USEDEFAULT
Definition: winuser.h:225
int WINAPI GetClipboardFormatNameW(_In_ UINT format, _Out_writes_(cchMaxCount) LPWSTR lpszFormatName, _In_ int cchMaxCount)
#define CS_GLOBALCLASS
Definition: winuser.h:652
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
DWORD WINAPI GetClassLongW(_In_ HWND, _In_ int)
BOOL WINAPI GetClassInfoW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSW)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ ClassTest_WndProc()

static LRESULT WINAPI ClassTest_WndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 74 of file class.c.

75{
76 if (msg == WM_NCCREATE) return 1;
78}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NCCREATE
Definition: winuser.h:1683

Referenced by ClassTest(), test_actctx_classes(), test_builtinproc(), test_icons(), and test_instances().

◆ ClassTest_WndProc2()

static LRESULT WINAPI ClassTest_WndProc2 ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 80 of file class.c.

81{
82 if (msg == WM_NCCREATE) return 1;
84}
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_builtinproc().

◆ create_manifest_file()

static void create_manifest_file ( const char filename,
const char manifest 
)
static

Definition at line 1081 of file class.c.

1082{
1084 HANDLE file;
1085 DWORD size;
1086
1089 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
1092}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLsizeiptr size
Definition: glext.h:5919
const char * filename
Definition: ioapi.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:127
static const CHAR manifest[]
Definition: v6util.h:39

Referenced by test_actctx_classes(), and test_comctl32_class().

◆ create_test_actctx()

static HANDLE create_test_actctx ( const char file)
static

Definition at line 1094 of file class.c.

1095{
1097 ACTCTXW actctx;
1098 HANDLE handle;
1099
1101 memset(&actctx, 0, sizeof(ACTCTXW));
1102 actctx.cbSize = sizeof(ACTCTXW);
1103 actctx.lpSource = path;
1104
1106 ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError());
1107
1108 ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize);
1109 ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags);
1110 ok(actctx.lpSource == path, "lpSource=%p\n", actctx.lpSource);
1111 ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
1112 ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId);
1113 ok(actctx.lpAssemblyDirectory == NULL, "lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
1114 ok(actctx.lpResourceName == NULL, "lpResourceName=%p\n", actctx.lpResourceName);
1115 ok(actctx.lpApplicationName == NULL, "lpApplicationName=%p\n", actctx.lpApplicationName);
1116 ok(actctx.hModule == NULL, "hModule=%p\n", actctx.hModule);
1117
1118 return handle;
1119}
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:102
#define actctx
Definition: kernel32.h:8
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_actctx_classes(), and test_comctl32_class().

◆ CreateDialogParamTest()

static void CreateDialogParamTest ( HINSTANCE  hInstance)
static

Definition at line 912 of file class.c.

913{
915
917 {
918 hWndMain = CreateDialogParamA(hInstance, "CLASS_TEST_DIALOG", NULL, 0, 0);
919 ok(hWndMain != NULL, "CreateDialogParam returned NULL\n");
922 }
923}
static BOOL RegisterTestDialog(HINSTANCE hInstance)
Definition: class.c:884
HWND hWndMain
Definition: welcome.c:60
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND WINAPI CreateDialogParamA(_In_opt_ HINSTANCE, _In_ LPCSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define SW_SHOW
Definition: winuser.h:775

Referenced by START_TEST().

◆ RegisterTestDialog()

static BOOL RegisterTestDialog ( HINSTANCE  hInstance)
static

Definition at line 884 of file class.c.

885{
886 WNDCLASSEXA wcx;
887 ATOM atom = 0;
888
889 ZeroMemory(&wcx, sizeof(WNDCLASSEXA));
890 wcx.cbSize = sizeof(wcx);
892 wcx.cbClsExtra = 0;
894 wcx.hInstance = hInstance;
898 wcx.lpszClassName = "TestDialog";
899 wcx.lpszMenuName = "TestDialog";
903
904 atom = RegisterClassExA(&wcx);
905 ok(atom != 0, "RegisterClassEx returned 0\n");
906
907 return atom;
908}
static LRESULT WINAPI TestDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: class.c:879
int cbClsExtra
Definition: winuser.h:3204
HINSTANCE hInstance
Definition: winuser.h:3206
HCURSOR hCursor
Definition: winuser.h:3208
LPCSTR lpszMenuName
Definition: winuser.h:3210
HICON hIconSm
Definition: winuser.h:3212
int cbWndExtra
Definition: winuser.h:3205
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3207
HBRUSH hbrBackground
Definition: winuser.h:3209
#define ZeroMemory
Definition: winbase.h:1712
#define DLGWINDOWEXTRA
Definition: winuser.h:2565
#define IMAGE_ICON
Definition: winuser.h:212
#define SM_CYSMICON
Definition: winuser.h:1013
#define SM_CXSMICON
Definition: winuser.h:1012
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2091
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2209
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2121
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by CreateDialogParamTest().

◆ START_TEST()

START_TEST ( class  )

Definition at line 1467 of file class.c.

1468{
1469 char **argv;
1472
1473 if (argc >= 3)
1474 {
1476 return;
1477 }
1478
1479 test_IME();
1482
1483 if (!GetModuleHandleW(0))
1484 {
1485 trace("Class test is incompatible with Win9x implementation, skipping\n");
1486 return;
1487 }
1488
1492 test_styles();
1494 test_icons();
1497
1498 /* this test unregisters the Button class so it should be executed at the end */
1500}
static int argc
Definition: ServiceArgs.c:12
#define trace
Definition: atltest.h:70
#define TRUE
Definition: types.h:120
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void ClassTest(HINSTANCE hInstance, BOOL global)
Definition: class.c:88
static void test_comctl32_classes(void)
Definition: class.c:1208
static void test_builtinproc(void)
Definition: class.c:637
static void test_extra_values(void)
Definition: class.c:940
static void test_IME(void)
Definition: class.c:1260
static void test_styles(void)
Definition: class.c:253
static void test_icons(void)
Definition: class.c:1022
static void test_actctx_classes(void)
Definition: class.c:1306
static void test_instances(void)
Definition: class.c:349
static void CreateDialogParamTest(HINSTANCE hInstance)
Definition: class.c:912
static void test_GetClassInfo(void)
Definition: class.c:955
static void test_comctl32_class(const char *name)
Definition: class.c:1120
#define argv
Definition: mplay32.c:18
int winetest_get_mainargs(char ***pargv)

◆ test_actctx_classes()

static void test_actctx_classes ( void  )
static

Definition at line 1306 of file class.c.

1307{
1308 static const char main_manifest[] =
1309 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
1310 "<assemblyIdentity version=\"4.3.2.1\" name=\"Wine.WndClass.Test\" type=\"win32\" />"
1311 "<file name=\"file.exe\">"
1312 "<windowClass>MyTestClass</windowClass>"
1313 "</file>"
1314 "</assembly>";
1315 static const char *testclass = "MyTestClass";
1316 WNDCLASSA wc;
1319 BOOL ret;
1320 ATOM class;
1322 char buff[64];
1323 HWND hwnd, hwnd2;
1324 char path[MAX_PATH];
1325
1327 strcat(path, "actctx_classes.manifest");
1328
1329 create_manifest_file(path, main_manifest);
1331 ret = DeleteFileA(path);
1332 ok(ret, "Failed to delete manifest file, error %d.\n", GetLastError());
1333
1335 ok(ret, "Failed to activate context.\n");
1336
1337 memset(&wc, 0, sizeof(wc));
1340 wc.lpszClassName = testclass;
1341
1343
1344 ret = GetClassInfoA(hinst, testclass, &wc);
1345 ok(!ret, "Expected failure.\n");
1346
1347 class = RegisterClassA(&wc);
1348 ok(class != 0, "Failed to register class.\n");
1349
1350 /* Class info is available by versioned and regular names. */
1351 ret = GetClassInfoA(hinst, testclass, &wc);
1352 ok(ret, "Failed to get class info.\n");
1353
1354 hwnd = CreateWindowExA(0, testclass, "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0);
1355 ok(hwnd != NULL, "Failed to create a window.\n");
1356
1357 hwnd2 = FindWindowExA(NULL, NULL, "MyTestClass", NULL);
1358 ok(hwnd2 == hwnd, "Failed to find test window.\n");
1359
1360 hwnd2 = FindWindowExA(NULL, NULL, "4.3.2.1!MyTestClass", NULL);
1361 ok(hwnd2 == NULL, "Unexpected find result %p.\n", hwnd2);
1362
1363 ret = GetClassNameA(hwnd, buff, sizeof(buff));
1364 ok(ret, "Failed to get class name.\n");
1365 ok(!strcmp(buff, testclass), "Unexpected class name.\n");
1366
1367 ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc);
1368 ok(ret, "Failed to get class info.\n");
1369
1370 ret = UnregisterClassA(testclass, hinst);
1371 ok(!ret, "Failed to unregister class.\n");
1372
1374 ok(ret, "Failed to deactivate context.\n");
1375
1376 ret = GetClassInfoA(hinst, testclass, &wc);
1377 ok(!ret, "Unexpected ret val %d.\n", ret);
1378
1379 ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc);
1380 ok(ret, "Failed to get class info.\n");
1381
1382 ret = GetClassNameA(hwnd, buff, sizeof(buff));
1383 ok(ret, "Failed to get class name.\n");
1384 ok(!strcmp(buff, testclass), "Unexpected class name.\n");
1385
1387
1388 hwnd = CreateWindowExA(0, "4.3.2.1!MyTestClass", "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0);
1389 ok(hwnd != NULL, "Failed to create a window.\n");
1390
1391 hwnd2 = FindWindowExA(NULL, NULL, "MyTestClass", NULL);
1392 ok(hwnd2 == hwnd, "Failed to find test window.\n");
1393
1394 hwnd2 = FindWindowExA(NULL, NULL, "4.3.2.1!MyTestClass", NULL);
1395 ok(hwnd2 == NULL, "Unexpected find result %p.\n", hwnd2);
1396
1398
1399 ret = UnregisterClassA("MyTestClass", hinst);
1400 ok(!ret, "Unexpected ret value %d.\n", ret);
1401
1402 ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst);
1403 ok(ret, "Failed to unregister class.\n");
1404
1405 /* Register versioned class without active context. */
1406 wc.lpszClassName = "4.3.2.1!MyTestClass";
1407 class = RegisterClassA(&wc);
1408 ok(class != 0, "Failed to register class.\n");
1409
1411 ok(ret, "Failed to activate context.\n");
1412
1413 wc.lpszClassName = "MyTestClass";
1414 class = RegisterClassA(&wc);
1415 ok(class == 0, "Expected failure.\n");
1416
1418 ok(ret, "Failed to deactivate context.\n");
1419
1420 ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst);
1421 ok(ret, "Failed to unregister class.\n");
1422
1423 /* Only versioned name is registered. */
1425 ok(ret, "Failed to activate context.\n");
1426
1427 wc.lpszClassName = "MyTestClass";
1428 class = RegisterClassA(&wc);
1429 ok(class != 0, "Failed to register class\n");
1430
1432 ok(ret, "Failed to deactivate context.\n");
1433
1434 ret = GetClassInfoA(hinst, "MyTestClass", &wc);
1435 ok(!ret, "Expected failure.\n");
1436
1437 ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc);
1438 ok(ret, "Failed to get class info.\n");
1439
1440 ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst);
1441 ok(ret, "Failed to unregister class.\n");
1442
1443 /* Register regular name first, it's not considered when versioned name is registered. */
1444 wc.lpszClassName = "MyTestClass";
1445 class = RegisterClassA(&wc);
1446 ok(class != 0, "Failed to register class.\n");
1447
1449 ok(ret, "Failed to activate context.\n");
1450
1451 wc.lpszClassName = "MyTestClass";
1452 class = RegisterClassA(&wc);
1453 ok(class != 0, "Failed to register class.\n");
1454
1456 ok(ret, "Failed to deactivate context.\n");
1457
1458 ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst);
1459 ok(ret, "Failed to unregister class.\n");
1460
1461 ret = UnregisterClassA("MyTestClass", hinst);
1462 ok(ret, "Failed to unregister class.\n");
1463
1465}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
static HINSTANCE hinst
Definition: edit.c:551
static void create_manifest_file(const char *filename, const char *manifest)
Definition: class.c:1081
static HANDLE create_test_actctx(const char *file)
Definition: class.c:1094
HICON hIcon
Definition: winuser.h:3168
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
Definition: http.c:7252
Definition: cookie.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65
int ret
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)
HWND WINAPI FindWindowExA(_In_opt_ HWND, _In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ test_builtinproc()

static void test_builtinproc ( void  )
static

Definition at line 637 of file class.c.

638{
639 /* Edit behaves differently */
640 static const CHAR NORMAL_CLASSES[][10] = {
641 "Button",
642 "Static",
643 "ComboBox",
644 "ComboLBox",
645 "ListBox",
646 "ScrollBar",
647 "#32770", /* dialog */
648 };
649 static const char classA[] = "deftest";
650 static const WCHAR classW[] = {'d','e','f','t','e','s','t',0};
651 WCHAR unistring[] = {0x142, 0x40e, 0x3b4, 0}; /* a string that would be destroyed by a W->A->W conversion */
652 WNDPROC pDefWindowProcA, pDefWindowProcW;
653 WNDPROC pNtdllDefWindowProcA, pNtdllDefWindowProcW;
654 WNDPROC oldproc;
655 WNDCLASSEXA cls; /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */
656 WCHAR buf[128];
657 ATOM atom;
658 HWND hwnd;
659 unsigned int i;
660
661 pDefWindowProcA = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "DefWindowProcA");
662 pDefWindowProcW = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "DefWindowProcW");
663 pNtdllDefWindowProcA = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtdllDefWindowProc_A");
664 pNtdllDefWindowProcW = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtdllDefWindowProc_W");
665
666 /* On Vista+, the user32.dll export DefWindowProcA/W is forwarded to */
667 /* ntdll.NtdllDefWindowProc_A/W. However, the wndproc returned by */
668 /* GetClassLong/GetWindowLong points to an unexported user32 function */
669 if (pDefWindowProcA == pNtdllDefWindowProcA &&
670 pDefWindowProcW == pNtdllDefWindowProcW)
671 skip("user32.DefWindowProcX forwarded to ntdll.NtdllDefWindowProc_X\n");
672 else
673 {
674 for (i = 0; i < 4; i++)
675 {
676 ZeroMemory(&cls, sizeof(cls));
677 cls.cbSize = sizeof(cls);
680 if (i & 1)
681 cls.lpfnWndProc = pDefWindowProcA;
682 else
683 cls.lpfnWndProc = pDefWindowProcW;
684
685 if (i & 2)
686 {
687 cls.lpszClassName = classA;
688 atom = RegisterClassExA(&cls);
689 }
690 else
691 {
693 atom = RegisterClassExW((WNDCLASSEXW *)&cls);
694 }
695 ok(atom != 0, "Couldn't register class, i=%d, %d\n", i, GetLastError());
696
697 hwnd = CreateWindowA(classA, NULL, 0, 0, 0, 100, 100, NULL, NULL, GetModuleHandleA(NULL), NULL);
698 ok(hwnd != NULL, "Couldn't create window i=%d\n", i);
699
700 ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
701 (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), pDefWindowProcA);
702 ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n",
703 (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), pDefWindowProcA);
704
705 ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
706 (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), pDefWindowProcW);
707 ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n",
708 (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), pDefWindowProcW);
709
712 }
713 }
714
715 /* built-in winproc - window A/W type automatically detected */
716 ZeroMemory(&cls, sizeof(cls));
717 cls.cbSize = sizeof(cls);
720 cls.lpszClassName = classA;
721 cls.lpfnWndProc = pDefWindowProcW;
722 atom = RegisterClassExA(&cls);
723
727 broken(!IsWindowUnicode(hwnd)) /* Windows 8 and 10 */,
728 "Windows should be Unicode\n");
731 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
732 else
733 ok(memcmp(buf, unistring, sizeof(unistring)) != 0, "WM_GETTEXT invalid return\n");
734 SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)pDefWindowProcA);
735 ok(IsWindowUnicode(hwnd), "Windows should have remained Unicode\n");
736 if (GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA)
737 {
738 /* DefWindowProc isn't magic on wow64 */
739 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd, GWLP_WNDPROC)), "Ansi winproc is not a handle\n");
740 }
741 else
742 {
743 ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Invalid Unicode winproc\n");
744 ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Invalid Ansi winproc\n");
745 }
747 ok(IsWindowUnicode(hwnd) == FALSE, "SetWindowLongPtrA should have switched window to ANSI\n");
748
751
752 /* custom winproc - the same function can be used as both A and W*/
753 ZeroMemory(&cls, sizeof(cls));
754 cls.cbSize = sizeof(cls);
757 cls.lpszClassName = classA;
759 atom = RegisterClassExA(&cls);
760
763 ok(IsWindowUnicode(hwnd) == FALSE, "Window should be ANSI\n");
765 ok(IsWindowUnicode(hwnd), "SetWindowLongPtrW should have changed window to Unicode\n");
767 ok(IsWindowUnicode(hwnd) == FALSE, "SetWindowLongPtrA should have changed window to ANSI\n");
768
771
772 /* For most of the builtin controls both GetWindowLongPtrA and W returns a pointer that is executed directly
773 * by CallWindowProcA/W */
774 for (i = 0; i < ARRAY_SIZE(NORMAL_CLASSES); i++)
775 {
776 WNDPROC procA, procW;
777 hwnd = CreateWindowExA(0, NORMAL_CLASSES[i], classA, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 680, 260,
778 NULL, NULL, NULL, 0);
779 ok(hwnd != NULL, "Couldn't create window of class %s\n", NORMAL_CLASSES[i]);
780 SetWindowTextA(hwnd, classA); /* ComboBox needs this */
783 ok(!IS_WNDPROC_HANDLE(procA), "procA should not be a handle for %s (%p)\n", NORMAL_CLASSES[i], procA);
784 ok(!IS_WNDPROC_HANDLE(procW), "procW should not be a handle for %s (%p)\n", NORMAL_CLASSES[i], procW);
785 CallWindowProcA(procA, hwnd, WM_GETTEXT, 120, (LPARAM)buf);
786 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT A/A invalid return for class %s\n", NORMAL_CLASSES[i]);
787 CallWindowProcA(procW, hwnd, WM_GETTEXT, 120, (LPARAM)buf);
788 ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT A/W invalid return for class %s\n", NORMAL_CLASSES[i]);
789 CallWindowProcW(procA, hwnd, WM_GETTEXT, 120, (LPARAM)buf);
790 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT W/A invalid return for class %s\n", NORMAL_CLASSES[i]);
791 CallWindowProcW(procW, hwnd, WM_GETTEXT, 120, (LPARAM)buf);
792 ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT W/W invalid return for class %s\n", NORMAL_CLASSES[i]);
793
795 ok(IS_WNDPROC_HANDLE(oldproc) == FALSE, "Class %s shouldn't return a handle\n", NORMAL_CLASSES[i]);
798 }
799
800 /* Edit controls are special - they return a wndproc handle when GetWindowLongPtr is called with a different A/W.
801 * On the other hand there is no W->A->W conversion so this control is treated specially. */
803 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, NULL, 0);
804 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
805 ok(IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd, GCLP_WNDPROC)) == FALSE, "Edit control class should have a Unicode wndproc\n");
806 ok(IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd, GCLP_WNDPROC)) == FALSE, "Edit control class should have a ANSI wndproc\n");
807 /* But GetWindowLongPtr returns only a handle for the ANSI one */
808 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd, GWLP_WNDPROC)), "Edit control should return a wndproc handle\n");
809 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd, GWLP_WNDPROC)), "Edit control shouldn't return a W wndproc handle\n");
811 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
813 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
815 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
816
819 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
820
822 /* SetWindowLongPtr returns a wndproc handle - like GetWindowLongPtr */
823 ok(IS_WNDPROC_HANDLE(oldproc), "Edit control should return a wndproc handle\n");
824 ok(IsWindowUnicode(hwnd) == FALSE, "SetWindowLongPtrA should have changed window to ANSI\n");
825 SetWindowTextA(hwnd, classA); /* Windows resets the title to WideStringToMultiByte(unistring) */
826 memset(buf, 0, sizeof(buf));
828 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
830 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
832 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
833
835 ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT invalid return\n");
836
838
840
842 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, NULL, 0);
843
844 /* GetClassLongPtr returns that both the Unicode and ANSI wndproc */
845 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrA(hwnd, GCLP_WNDPROC)), "Edit control class should have a Unicode wndproc\n");
846 ok(!IS_WNDPROC_HANDLE(GetClassLongPtrW(hwnd, GCLP_WNDPROC)), "Edit control class should have a ANSI wndproc\n");
847 /* But GetWindowLongPtr returns only a handle for the Unicode one */
848 ok(!IS_WNDPROC_HANDLE(GetWindowLongPtrA(hwnd, GWLP_WNDPROC)), "Edit control shouldn't return an A wndproc handle\n");
849 ok(IS_WNDPROC_HANDLE(GetWindowLongPtrW(hwnd, GWLP_WNDPROC)), "Edit control should return a wndproc handle\n");
851 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
853 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
855 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
856
858 ok(memcmp(buf, classW, sizeof(classW)) == 0, "WM_GETTEXT invalid return\n");
859
861 SetWindowTextW(hwnd, unistring);
863 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
865 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
867 ok(memcmp(buf, unistring, sizeof(unistring)) == 0, "WM_GETTEXT invalid return\n");
868
871 ok(memcmp(buf, classA, sizeof(classA)) == 0, "WM_GETTEXT invalid return\n");
872
874
876}
#define broken(x)
Definition: _sntprintf.h:21
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define IS_WNDPROC_HANDLE(x)
Definition: class.c:36
static LRESULT WINAPI ClassTest_WndProc2(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: class.c:80
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WC_EDITW
Definition: commctrl.h:4687
#define WC_EDITA
Definition: commctrl.h:4686
#define GWLP_WNDPROC
Definition: treelist.c:66
uint32_t DWORD_PTR
Definition: typedefs.h:65
static const WCHAR classW[]
Definition: lex.c:40
LONG_PTR LPARAM
Definition: windef.h:208
#define SetWindowLongPtrA
Definition: winuser.h:5345
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define GCLP_WNDPROC
Definition: winuser.h:678
#define WM_GETTEXT
Definition: winuser.h:1618
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI IsWindowUnicode(_In_ HWND)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define GetClassLongPtrW
Definition: winuser.h:4564
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define SetWindowLongPtrW
Definition: winuser.h:5346
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_comctl32_class()

static void test_comctl32_class ( const char name)
static

Definition at line 1120 of file class.c.

1121{
1122 WNDCLASSA wcA;
1123 WNDCLASSW wcW;
1124 BOOL ret;
1126 WCHAR nameW[20];
1127 HWND hwnd;
1128
1129 if (name[0] == '!')
1130 {
1131 char path[MAX_PATH];
1134
1135 name++;
1136
1138 strcat(path, "comctl32_class.manifest");
1139
1142 ret = DeleteFileA(path);
1143 ok(ret, "Failed to delete manifest file, error %d.\n", GetLastError());
1144
1145 module = GetModuleHandleA( "comctl32" );
1146 ok( !module, "comctl32 already loaded\n" );
1147
1149 ok(ret, "Failed to activate context.\n");
1150
1151 /* Some systems load modules during context activation. In this case skip the rest of the test. */
1152 module = GetModuleHandleA( "comctl32" );
1153 ok( !module || broken(module != NULL) /* Vista/Win7 */, "comctl32 already loaded\n" );
1154 if (module)
1155 {
1156 win_skip("Module loaded during context activation. Skipping tests.\n");
1157 goto skiptest;
1158 }
1159
1160 ret = GetClassInfoA( 0, name, &wcA );
1161 ok( ret || broken(!ret) /* WinXP */, "GetClassInfoA failed for %s\n", name );
1162 if (!ret)
1163 goto skiptest;
1164
1166 ret = GetClassInfoW( 0, nameW, &wcW );
1167 ok( ret, "GetClassInfoW failed for %s\n", name );
1168 module = GetModuleHandleA( "comctl32" );
1169 ok( module != 0, "comctl32 not loaded\n" );
1171 module = GetModuleHandleA( "comctl32" );
1172 ok( !module || broken(module != NULL) /* Vista */, "comctl32 still loaded\n" );
1173 hwnd = CreateWindowA( name, "test", WS_OVERLAPPEDWINDOW, 0, 0, 10, 10, NULL, NULL, NULL, 0 );
1174 ok( hwnd != 0, "failed to create window for %s\n", name );
1175 module = GetModuleHandleA( "comctl32" );
1176 ok( module != 0, "comctl32 not loaded\n" );
1178
1179 skiptest:
1181 ok(ret, "Failed to deactivate context.\n");
1183 }
1184 else
1185 {
1186 module = GetModuleHandleA( "comctl32" );
1187 ok( !module, "comctl32 already loaded\n" );
1188 ret = GetClassInfoA( 0, name, &wcA );
1189 ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name );
1190 if (!ret) return;
1192 ret = GetClassInfoW( 0, nameW, &wcW );
1193 ok( ret, "GetClassInfoW failed for %s\n", name );
1194 module = GetModuleHandleA( "comctl32" );
1195 ok( module != 0, "comctl32 not loaded\n" );
1197 module = GetModuleHandleA( "comctl32" );
1198 ok( !module, "comctl32 still loaded\n" );
1199 hwnd = CreateWindowA( name, "test", WS_OVERLAPPEDWINDOW, 0, 0, 10, 10, NULL, NULL, NULL, 0 );
1200 ok( hwnd != 0, "failed to create window for %s\n", name );
1201 module = GetModuleHandleA( "comctl32" );
1202 ok( module != 0, "comctl32 not loaded\n" );
1204 }
1205}
static const WCHAR nameW[]
Definition: main.c:46
#define FreeLibrary(x)
Definition: compat.h:748
static const char comctl32_manifest[]
Definition: class.c:50
#define win_skip
Definition: test.h:163

Referenced by START_TEST().

◆ test_comctl32_classes()

static void test_comctl32_classes ( void  )
static

Definition at line 1208 of file class.c.

1209{
1210 char path_name[MAX_PATH];
1213 char **argv;
1214 int i;
1215
1216 static const char *classes[] =
1217 {
1221 WC_HEADERA,
1231 "SysLink",
1238 "!Button",
1239 "!Edit",
1240 "!Static",
1241 "!Listbox",
1242 "!ComboBox",
1243 "!ComboLBox",
1244 };
1245
1247 for (i = 0; i < ARRAY_SIZE(classes); i++)
1248 {
1249 memset( &startup, 0, sizeof(startup) );
1250 startup.cb = sizeof( startup );
1251 sprintf( path_name, "%s class %s", argv[0], classes[i] );
1253 "CreateProcess failed.\n" );
1255 CloseHandle( info.hProcess );
1256 CloseHandle( info.hThread );
1257 }
1258}
static void startup(void)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4741
static char * path_name(DOS_FILE *file)
Definition: check.c:208
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define WC_LISTVIEWA
Definition: commctrl.h:2256
#define WC_HEADERA
Definition: commctrl.h:623
#define UPDOWN_CLASSA
Definition: commctrl.h:2118
#define WC_PAGESCROLLERA
Definition: commctrl.h:4498
#define TRACKBAR_CLASSA
Definition: commctrl.h:2010
#define WC_COMBOBOXEXA
Definition: commctrl.h:3782
#define WC_TABCONTROLA
Definition: commctrl.h:3934
#define WC_TREEVIEWA
Definition: commctrl.h:3242
#define TOOLTIPS_CLASSA
Definition: commctrl.h:1708
#define REBARCLASSNAMEA
Definition: commctrl.h:1464
#define PROGRESS_CLASSA
Definition: commctrl.h:2175
#define WC_IPADDRESSA
Definition: commctrl.h:4473
#define STATUSCLASSNAMEA
Definition: commctrl.h:1937
#define WC_NATIVEFONTCTLA
Definition: commctrl.h:4607
#define DATETIMEPICK_CLASSA
Definition: commctrl.h:4323
#define ANIMATE_CLASSA
Definition: commctrl.h:4142
#define HOTKEY_CLASSA
Definition: commctrl.h:2235
#define MONTHCAL_CLASSA
Definition: commctrl.h:4176
#define TOOLBARCLASSNAMEA
Definition: commctrl.h:944
void winetest_wait_child_process(HANDLE process)

Referenced by START_TEST().

◆ test_extra_values()

static void test_extra_values ( void  )
static

Definition at line 940 of file class.c.

941{
942 int i;
943 for(i = 0; i < ARRAY_SIZE(extra_values); i++)
944 {
945 WNDCLASSEXA wcx;
947
948 ok( ret, "GetClassInfo (0) failed for global class %s\n", extra_values[i].name);
949 if (!ret) continue;
951 "expected %d, got %d\n", extra_values[i].value, wcx.cbWndExtra);
952 }
953}
static const struct @1725 extra_values[]
int badvalue
Definition: class.c:929
Definition: pdh_main.c:94
BOOL WINAPI GetClassInfoExA(_In_opt_ HINSTANCE, _In_ LPCSTR, _Out_ LPWNDCLASSEXA)

Referenced by START_TEST().

◆ test_GetClassInfo()

static void test_GetClassInfo ( void  )
static

Definition at line 955 of file class.c.

956{
957 static const WCHAR staticW[] = {'s','t','a','t','i','c',0};
958 WNDCLASSA wc;
959 WNDCLASSEXA wcx;
960 BOOL ret;
961
962 SetLastError(0xdeadbeef);
963 ret = GetClassInfoA(0, "static", &wc);
964 ok(ret, "GetClassInfoA() error %d\n", GetLastError());
965
966if (0) { /* crashes under XP */
967 SetLastError(0xdeadbeef);
968 ret = GetClassInfoA(0, "static", NULL);
969 ok(ret, "GetClassInfoA() error %d\n", GetLastError());
970
971 SetLastError(0xdeadbeef);
973 ok(ret, "GetClassInfoW() error %d\n", GetLastError());
974}
975
976 wcx.cbSize = sizeof(wcx);
977 SetLastError(0xdeadbeef);
978 ret = GetClassInfoExA(0, "static", &wcx);
979 ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
980
981 SetLastError(0xdeadbeef);
982 ret = GetClassInfoExA(0, "static", NULL);
983 ok(!ret, "GetClassInfoExA() should fail\n");
985 broken(GetLastError() == 0xdeadbeef), /* win9x */
986 "expected ERROR_NOACCESS, got %d\n", GetLastError());
987
988 SetLastError(0xdeadbeef);
990 ok(!ret, "GetClassInfoExW() should fail\n");
992 broken(GetLastError() == 0xdeadbeef) /* NT4 */ ||
994 "expected ERROR_NOACCESS, got %d\n", GetLastError());
995
996 wcx.cbSize = 0;
997 wcx.lpfnWndProc = NULL;
998 SetLastError(0xdeadbeef);
999 ret = GetClassInfoExA(0, "static", &wcx);
1000 ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
1001 ok(GetLastError() == 0xdeadbeef, "Unexpected error code %d\n", GetLastError());
1002 ok(wcx.cbSize == 0, "expected 0, got %u\n", wcx.cbSize);
1003 ok(wcx.lpfnWndProc != NULL, "got null proc\n");
1004
1005 wcx.cbSize = sizeof(wcx) - 1;
1006 wcx.lpfnWndProc = NULL;
1007 SetLastError(0xdeadbeef);
1008 ret = GetClassInfoExA(0, "static", &wcx);
1009 ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
1010 ok(wcx.cbSize == sizeof(wcx) - 1, "expected sizeof(wcx)-1, got %u\n", wcx.cbSize);
1011 ok(wcx.lpfnWndProc != NULL, "got null proc\n");
1012
1013 wcx.cbSize = sizeof(wcx) + 1;
1014 wcx.lpfnWndProc = NULL;
1015 SetLastError(0xdeadbeef);
1016 ret = GetClassInfoExA(0, "static", &wcx);
1017 ok(ret, "GetClassInfoExA() error %d\n", GetLastError());
1018 ok(wcx.cbSize == sizeof(wcx) + 1, "expected sizeof(wcx)+1, got %u\n", wcx.cbSize);
1019 ok(wcx.lpfnWndProc != NULL, "got null proc\n");
1020}
static const WCHAR staticW[]
Definition: actctx.c:761
#define ERROR_NOACCESS
Definition: winerror.h:578
BOOL WINAPI GetClassInfoExW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSEXW)

Referenced by START_TEST().

◆ test_icons()

static void test_icons ( void  )
static

Definition at line 1022 of file class.c.

1023{
1024 WNDCLASSEXW wcex, ret_wcex;
1025 WCHAR cls_name[] = {'I','c','o','n','T','e','s','t','C','l','a','s','s',0};
1026 HWND hwnd;
1028 HICON hsmicon, hsmallnew;
1029 ICONINFO icinf;
1030
1031 memset(&wcex, 0, sizeof wcex);
1032 wcex.cbSize = sizeof wcex;
1035 wcex.hInstance = hinst;
1036 wcex.lpszClassName = cls_name;
1037 ok(RegisterClassExW(&wcex), "RegisterClassExW returned 0\n");
1039 0, 0, 0, 0, NULL, NULL, hinst, 0);
1040 ok(hwnd != NULL, "Window was not created\n");
1041
1042 ok(GetClassInfoExW(hinst, cls_name, &ret_wcex), "Class info was not retrieved\n");
1043 ok(wcex.hIcon == ret_wcex.hIcon, "Icons don't match\n");
1044 ok(ret_wcex.hIconSm != NULL, "hIconSm should be non-zero handle\n");
1045
1047 ok(hsmicon != NULL, "GetClassLong should return non-zero handle\n");
1048
1049 ok(SendMessageA(hwnd, WM_GETICON, ICON_BIG, 0) == 0,
1050 "WM_GETICON with ICON_BIG should not return the class icon\n");
1051 ok(SendMessageA(hwnd, WM_GETICON, ICON_SMALL, 0) == 0,
1052 "WM_GETICON with ICON_SMALL should not return the class icon\n");
1053 ok(SendMessageA(hwnd, WM_GETICON, ICON_SMALL2, 0) == 0,
1054 "WM_GETICON with ICON_SMALL2 should not return the class icon\n");
1055
1059 "Previous hIconSm should be zero\n");
1060 ok(hsmallnew == (HICON)GetClassLongPtrW(hwnd, GCLP_HICONSM),
1061 "Should return explicitly assigned small icon\n");
1062 ok(!GetIconInfo(hsmicon, &icinf), "Previous small icon should be destroyed\n");
1063
1066 ok( hsmicon != NULL, "GetClassLong should return non-zero handle\n");
1067
1069 ok(!GetClassLongPtrW(hwnd, GCLP_HICONSM), "GetClassLong should return zero handle\n");
1070
1073 ok(hsmicon != NULL, "GetClassLong should return non-zero handle\n");
1075 ok(GetIconInfo(hsmicon, &icinf), "Icon should NOT be destroyed\n");
1076
1077 DestroyIcon(hsmallnew);
1079}
static HICON
Definition: imagelist.c:84
static const char cls_name[]
Definition: compobj.c:2476
LPCWSTR lpszClassName
Definition: winuser.h:3226
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
HICON hIconSm
Definition: winuser.h:3227
HINSTANCE hInstance
Definition: winuser.h:3221
HICON hIcon
Definition: winuser.h:3222
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
#define SetClassLongPtrW
Definition: winuser.h:5265
#define GCLP_HICONSM
Definition: winuser.h:675
#define IDI_QUESTION
Definition: winuser.h:706
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2076
#define GCLP_HICON
Definition: winuser.h:674
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2018
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2084

Referenced by START_TEST().

◆ test_IME()

static void test_IME ( void  )
static

Definition at line 1260 of file class.c.

1261{
1262 static const WCHAR ime_classW[] = {'I','M','E',0};
1263
1264 char module_name[MAX_PATH], *ptr;
1266 WNDCLASSW wnd_classw;
1268 SIZE_T size;
1269 BOOL ret;
1270
1271 if (!GetProcAddress(GetModuleHandleA("user32.dll"), "BroadcastSystemMessageExA"))
1272 {
1273 win_skip("BroadcastSystemMessageExA not available, skipping IME class test\n");
1274 return;
1275 }
1276
1277 ok(GetModuleHandleA("imm32") != 0, "imm32.dll is not loaded\n");
1278
1279 ret = GetClassInfoA(NULL, "IME", &wnd_class);
1280 ok(ret, "GetClassInfo failed: %d\n", GetLastError());
1281
1282 size = VirtualQuery(wnd_class.lpfnWndProc, &mbi, sizeof(mbi));
1283 ok(size == sizeof(mbi), "VirtualQuery returned %ld\n", size);
1284 if (size == sizeof(mbi)) {
1286 ok(size, "GetModuleFileName failed\n");
1287 for (ptr = module_name+size-1; ptr > module_name; ptr--)
1288 if (*ptr == '\\' || *ptr == '/') break;
1289 if (*ptr == '\\' || *ptr=='/') ptr++;
1290 ok(!lstrcmpiA(ptr, "user32.dll") || !lstrcmpiA(ptr, "ntdll.dll"), "IME window proc implemented in %s\n", ptr);
1291 }
1292
1293 ret = GetClassInfoW(NULL, ime_classW, &wnd_classw);
1294 ok(ret, "GetClassInfo failed: %d\n", GetLastError());
1295
1296 size = VirtualQuery(wnd_classw.lpfnWndProc, &mbi, sizeof(mbi));
1297 ok(size == sizeof(mbi), "VirtualQuery returned %ld\n", size);
1299 ok(size, "GetModuleFileName failed\n");
1300 for (ptr = module_name+size-1; ptr > module_name; ptr--)
1301 if (*ptr == '\\' || *ptr == '/') break;
1302 if (*ptr == '\\' || *ptr=='/') ptr++;
1303 ok(!lstrcmpiA(ptr, "user32.dll") || !lstrcmpiA(ptr, "ntdll.dll"), "IME window proc implemented in %s\n", ptr);
1304}
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:170
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
static PVOID ptr
Definition: dispmode.c:27
WNDCLASSW wnd_class
Definition: startup.c:16
ULONG_PTR SIZE_T
Definition: typedefs.h:80
SIZE_T NTAPI VirtualQuery(IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:211

Referenced by START_TEST().

◆ test_instances()

static void test_instances ( void  )
static

Definition at line 349 of file class.c.

350{
351 WNDCLASSA cls, wc;
352 WNDCLASSEXA wcexA;
353 HWND hwnd, hwnd2;
354 const char *name = "__test__";
355 HINSTANCE kernel32 = GetModuleHandleA("kernel32");
356 HINSTANCE user32 = GetModuleHandleA("user32");
357 HINSTANCE main_module = GetModuleHandleA(NULL);
358 HINSTANCE zero_instance = 0;
359 DWORD r;
360 char buffer[0x10];
361
362 memset( &cls, 0, sizeof(cls) );
365 cls.cbClsExtra = 0;
366 cls.cbWndExtra = 0;
367 cls.lpszClassName = name;
368
369 cls.lpszMenuName = "main_module";
370 cls.hInstance = main_module;
371
372 ok( RegisterClassA( &cls ), "Failed to register local class for main module\n" );
373 check_class( main_module, name, "main_module" );
374 check_instance( name, main_module, main_module, main_module );
375 check_thread_instance( name, main_module, main_module, main_module );
376
377 cls.lpszMenuName = "kernel32";
378 cls.hInstance = kernel32;
379 ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
380 check_class( kernel32, name, "kernel32" );
381 check_class( main_module, name, "main_module" );
382 check_instance( name, kernel32, kernel32, kernel32 );
383 check_thread_instance( name, kernel32, kernel32, kernel32 );
384 ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
385
386 ZeroMemory(&wcexA, sizeof(wcexA));
388 wcexA.lpszClassName = "__classex_test__";
389 SetLastError(0xdeadbeef);
390 wcexA.cbSize = sizeof(wcexA) - 1;
391 ok( ((RegisterClassExA( &wcexA ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
392 "Succeeded with invalid number of cbSize bytes\n");
393 SetLastError(0xdeadbeef);
394 wcexA.cbSize = sizeof(wcexA) + 1;
395 ok( ((RegisterClassExA( &wcexA ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
396 "Succeeded with invalid number of cbSize bytes\n");
397 SetLastError(0xdeadbeef);
398 wcexA.cbSize = sizeof(wcexA);
399 ok( RegisterClassExA( &wcexA ), "Failed with valid number of cbSize bytes\n");
400 wcexA.cbSize = 0xdeadbeef;
401 ok( GetClassInfoExA(main_module, wcexA.lpszClassName, &wcexA), "GetClassInfoEx failed\n");
402 ok( wcexA.cbSize == 0xdeadbeef, "GetClassInfoEx returned wrong cbSize value %d\n", wcexA.cbSize);
403 UnregisterClassA(wcexA.lpszClassName, main_module);
404
405 /* Bug 2631 - Supplying an invalid number of bytes fails */
406 cls.cbClsExtra = 0;
407 cls.cbWndExtra = -1;
408 SetLastError(0xdeadbeef);
409 ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
410 "Failed with invalid number of WndExtra bytes\n");
411
412 cls.cbClsExtra = -1;
413 cls.cbWndExtra = 0;
414 SetLastError(0xdeadbeef);
415 ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
416 "Failed with invalid number of ClsExtra bytes\n");
417
418 cls.cbClsExtra = -1;
419 cls.cbWndExtra = -1;
420 SetLastError(0xdeadbeef);
421 ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
422 "Failed with invalid number of ClsExtra and cbWndExtra bytes\n");
423
424 cls.cbClsExtra = 0;
425 cls.cbWndExtra = 0;
426 SetLastError(0xdeadbeef);
427
428 /* setting global flag doesn't change status of class */
429 hwnd = CreateWindowExA( 0, name, "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
430 ok( hwnd != 0, "CreateWindow failed error %u\n", GetLastError());
432 cls.lpszMenuName = "kernel32";
433 cls.hInstance = kernel32;
434 ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
435 check_class( kernel32, name, "kernel32" );
436 check_class( main_module, name, "main_module" );
437 check_instance( name, kernel32, kernel32, kernel32 );
438 check_instance( name, main_module, main_module, main_module );
439 check_thread_instance( name, kernel32, kernel32, kernel32 );
440 check_thread_instance( name, main_module, main_module, main_module );
441 ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
442
443 /* changing the instance doesn't make it global */
445 ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
446 check_class( kernel32, name, "kernel32" );
447 check_instance( name, kernel32, kernel32, kernel32 );
448 check_thread_instance( name, kernel32, kernel32, kernel32 );
449 ok( !GetClassInfoA( 0, name, &wc ), "Class found with null instance\n" );
450 ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
451
452 /* GetClassInfo with instance 0 finds user32 instance */
454 ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
455 if (!GetClassInfoA( 0, name, &wc )) zero_instance = user32; /* instance 0 not supported on wow64 */
456 else
457 {
458 check_instance( name, 0, 0, kernel32 );
459 check_thread_instance( name, 0, 0, kernel32 );
460 }
461 check_class( kernel32, name, "kernel32" );
462 check_class( user32, name, "main_module" );
463 check_class( zero_instance, name, "main_module" );
464 check_instance( name, kernel32, kernel32, kernel32 );
465 check_instance( name, user32, zero_instance, user32 );
466 check_thread_instance( name, kernel32, kernel32, kernel32 );
467 check_thread_instance( name, user32, zero_instance, user32 );
468 ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
469
470 SetClassLongPtrA( hwnd, GCLP_HMODULE, 0x12345678 );
471 ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
472 check_class( kernel32, name, "kernel32" );
473 check_class( (HINSTANCE)0x12345678, name, "main_module" );
474 check_instance( name, kernel32, kernel32, kernel32 );
475 check_instance( name, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678 );
476 check_thread_instance( name, kernel32, kernel32, kernel32 );
477 check_thread_instance( name, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678 );
478 ok( !GetClassInfoA( 0, name, &wc ), "Class found with null instance\n" );
479
480 /* creating a window with instance 0 uses the first class found */
481 cls.hInstance = (HINSTANCE)0xdeadbeef;
482 cls.lpszMenuName = "deadbeef";
483 cls.style = 3;
484 ok( RegisterClassA( &cls ), "Failed to register local class for deadbeef\n" );
485 hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
486 ok( GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == 0xdeadbeef,
487 "Didn't get deadbeef class for null instance\n" );
488 DestroyWindow( hwnd2 );
489 ok( UnregisterClassA( name, (HINSTANCE)0xdeadbeef ), "Unregister failed for deadbeef\n" );
490
491 hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
492 ok( (HINSTANCE)GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == kernel32,
493 "Didn't get kernel32 class for null instance\n" );
494 DestroyWindow( hwnd2 );
495
496 r = GetClassNameA( hwnd, buffer, 4 );
497 ok( r == 3, "expected 3, got %d\n", r );
498 ok( !strcmp( buffer, "__t"), "name wrong: %s\n", buffer );
499
500 ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
501
502 hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
503 ok( GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == 0x12345678,
504 "Didn't get 12345678 class for null instance\n" );
505 DestroyWindow( hwnd2 );
506
507 SetClassLongPtrA( hwnd, GCLP_HMODULE, (LONG_PTR)main_module );
509
510 /* null handle means the same thing as main module */
511 cls.lpszMenuName = "null";
512 cls.hInstance = 0;
513 ok( !RegisterClassA( &cls ), "Succeeded registering local class for null instance\n" );
514 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %d\n", GetLastError() );
515 ok( UnregisterClassA( name, main_module ), "Unregister failed for main module\n" );
516
517 ok( RegisterClassA( &cls ), "Failed to register local class for null instance\n" );
518 /* must be found with main module handle */
519 check_class( main_module, name, "null" );
520 check_instance( name, main_module, main_module, main_module );
521 check_thread_instance( name, main_module, main_module, main_module );
522 ok( !GetClassInfoA( 0, name, &wc ), "Class found with null instance\n" );
523 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %d\n", GetLastError() );
524 ok( UnregisterClassA( name, 0 ), "Unregister failed for null instance\n" );
525
526 /* registering for user32 always fails */
527 cls.lpszMenuName = "user32";
528 cls.hInstance = user32;
529 ok( !RegisterClassA( &cls ), "Succeeded registering local class for user32\n" );
530 ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error code %d\n", GetLastError() );
531 cls.style |= CS_GLOBALCLASS;
532 ok( !RegisterClassA( &cls ), "Succeeded registering global class for user32\n" );
533 ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error code %d\n", GetLastError() );
534
535 /* unregister is OK though */
536 cls.hInstance = main_module;
537 ok( RegisterClassA( &cls ), "Failed to register global class for main module\n" );
538 ok( UnregisterClassA( name, user32 ), "Unregister failed for user32\n" );
539
540 /* instance doesn't matter for global class */
541 cls.style |= CS_GLOBALCLASS;
542 cls.lpszMenuName = "main_module";
543 cls.hInstance = main_module;
544 ok( RegisterClassA( &cls ), "Failed to register global class for main module\n" );
545 cls.lpszMenuName = "kernel32";
546 cls.hInstance = kernel32;
547 ok( !RegisterClassA( &cls ), "Succeeded registering local class for kernel32\n" );
548 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %d\n", GetLastError() );
549 /* even if global flag is cleared */
550 hwnd = CreateWindowExA( 0, name, "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
552 ok( !RegisterClassA( &cls ), "Succeeded registering local class for kernel32\n" );
553 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %d\n", GetLastError() );
554
555 check_class( main_module, name, "main_module" );
556 check_class( kernel32, name, "main_module" );
557 check_class( 0, name, "main_module" );
558 check_class( (HINSTANCE)0x12345678, name, "main_module" );
559 check_instance( name, main_module, main_module, main_module );
560 check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, main_module );
561 check_thread_instance( name, main_module, main_module, main_module );
562 check_thread_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, main_module );
563
564 /* changing the instance for global class doesn't make much difference */
565 SetClassLongPtrA( hwnd, GCLP_HMODULE, 0xdeadbeef );
566 check_instance( name, main_module, main_module, (HINSTANCE)0xdeadbeef );
567 check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef );
568 check_thread_instance( name, main_module, main_module, (HINSTANCE)0xdeadbeef );
569 check_thread_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef );
570
572 ok( UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister failed for main module global\n" );
573 ok( !UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister succeeded the second time\n" );
574 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %d\n", GetLastError() );
575
576 cls.hInstance = (HINSTANCE)0x12345678;
577 ok( RegisterClassA( &cls ), "Failed to register global class for dummy instance\n" );
578 check_instance( name, main_module, main_module, (HINSTANCE)0x12345678 );
579 check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0x12345678 );
580 check_thread_instance( name, main_module, main_module, (HINSTANCE)0x12345678 );
581 check_thread_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0x12345678 );
582 ok( UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister failed for main module global\n" );
583
584 /* check system classes */
585
586 /* we cannot register a global class with the name of a system class */
587 cls.style |= CS_GLOBALCLASS;
588 cls.lpszMenuName = "button_main_module";
589 cls.lpszClassName = "BUTTON";
590 cls.hInstance = main_module;
591 ok( !RegisterClassA( &cls ), "Succeeded registering global button class for main module\n" );
592 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %d\n", GetLastError() );
593 cls.hInstance = kernel32;
594 ok( !RegisterClassA( &cls ), "Succeeded registering global button class for kernel32\n" );
595 ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %d\n", GetLastError() );
596
597 /* local class is OK however */
598 cls.style &= ~CS_GLOBALCLASS;
599 cls.lpszMenuName = "button_main_module";
600 cls.hInstance = main_module;
601 ok( RegisterClassA( &cls ), "Failed to register local button class for main module\n" );
602 check_class( main_module, "BUTTON", "button_main_module" );
603 cls.lpszMenuName = "button_kernel32";
604 cls.hInstance = kernel32;
605 ok( RegisterClassA( &cls ), "Failed to register local button class for kernel32\n" );
606 check_class( kernel32, "BUTTON", "button_kernel32" );
607 check_class( main_module, "BUTTON", "button_main_module" );
608 ok( UnregisterClassA( "BUTTON", kernel32 ), "Unregister failed for kernel32 button\n" );
609 ok( UnregisterClassA( "BUTTON", main_module ), "Unregister failed for main module button\n" );
610 /* GetClassInfo sets instance to passed value for global classes */
611 check_instance( "BUTTON", 0, 0, user32 );
612 check_instance( "BUTTON", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
613 check_instance( "BUTTON", user32, zero_instance, user32 );
614 check_thread_instance( "BUTTON", 0, 0, user32 );
615 check_thread_instance( "BUTTON", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
616 check_thread_instance( "BUTTON", user32, zero_instance, user32 );
617
618 /* we can unregister system classes */
619 ok( GetClassInfoA( 0, "BUTTON", &wc ), "Button class not found with null instance\n" );
620 ok( GetClassInfoA( kernel32, "BUTTON", &wc ), "Button class not found with kernel32\n" );
621 ok( UnregisterClassA( "BUTTON", (HINSTANCE)0x12345678 ), "Failed to unregister button\n" );
622 ok( !UnregisterClassA( "BUTTON", (HINSTANCE)0x87654321 ), "Unregistered button a second time\n" );
623 ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %d\n", GetLastError() );
624 ok( !GetClassInfoA( 0, "BUTTON", &wc ), "Button still exists\n" );
625 /* last error not set reliably */
626
627 /* we can change the instance of a system class */
628 check_instance( "EDIT", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
629 check_thread_instance( "EDIT", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
630 hwnd = CreateWindowExA( 0, "EDIT", "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
631 SetClassLongPtrA( hwnd, GCLP_HMODULE, 0xdeadbeef );
632 check_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef );
633 check_thread_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef );
635}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
static void check_thread_instance(const char *name, HINSTANCE inst, HINSTANCE info_inst, HINSTANCE gcl_inst)
Definition: class.c:331
#define check_class(inst, name, menu)
Definition: class.c:289
#define check_instance(name, inst, info_inst, gcl_inst)
Definition: class.c:314
int cbWndExtra
Definition: winuser.h:3166
int cbClsExtra
Definition: winuser.h:3165
#define ERROR_CLASS_ALREADY_EXISTS
Definition: winerror.h:891
#define ERROR_CLASS_DOES_NOT_EXIST
Definition: winerror.h:892
#define SetClassLongPtrA
Definition: winuser.h:5264
DWORD WINAPI SetClassLongA(_In_ HWND, _In_ int, _In_ LONG)
#define GCL_STYLE
Definition: winuser.h:670

Referenced by START_TEST().

◆ test_styles()

static void test_styles ( void  )
static

Definition at line 253 of file class.c.

254{
255 /* check style bits */
256 check_style( "Button", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
257 check_style( "ComboBox", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
258 check_style( "Edit", 1, CS_PARENTDC | CS_DBLCLKS, 0 );
259 check_style( "ListBox", 1, CS_PARENTDC | CS_DBLCLKS, CS_PARENTDC /*FIXME*/ );
260 check_style( "MDIClient", 1, 0, 0 );
261 check_style( "ScrollBar", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
262 check_style( "Static", 1, CS_PARENTDC | CS_DBLCLKS, 0 );
263 check_style( "ComboLBox", 1, CS_SAVEBITS | CS_DBLCLKS, 0 );
264 check_style( "DDEMLEvent", 0, 0, 0 );
265 check_style( "Message", 0, 0, 0 );
266 check_style( "#32768", 1, CS_DROPSHADOW | CS_SAVEBITS | CS_DBLCLKS, CS_DROPSHADOW ); /* menu */
267 check_style( "#32769", 1, CS_DBLCLKS, 0 ); /* desktop */
268 check_style( "#32770", 1, CS_SAVEBITS | CS_DBLCLKS, 0 ); /* dialog */
269 todo_wine { check_style( "#32771", 1, CS_SAVEBITS | CS_HREDRAW | CS_VREDRAW, 0 ); } /* task switch */
270 check_style( "#32772", 1, 0, 0 ); /* icon title */
271}
#define todo_wine
Definition: custom.c:79
static void check_style(const char *name, int must_exist, UINT style, UINT ignore)
Definition: class.c:237
#define CS_DROPSHADOW
Definition: winuser.h:660
#define CS_DBLCLKS
Definition: winuser.h:651
#define CS_SAVEBITS
Definition: winuser.h:657
#define CS_PARENTDC
Definition: winuser.h:656

Referenced by START_TEST().

◆ TestDlgProc()

static LRESULT WINAPI TestDlgProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 879 of file class.c.

880{
881 return DefDlgProcA(hWnd, uMsg, wParam, lParam);
882}
LRESULT WINAPI DefDlgProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by RegisterTestDialog().

◆ thread_proc()

static DWORD WINAPI thread_proc ( void param)
static

Definition at line 322 of file class.c.

323{
324 struct class_info *class_info = param;
325
327
328 return 0;
329}
GLfloat param
Definition: glext.h:5796

Referenced by check_thread_instance().

Variable Documentation

◆ badvalue

int badvalue

Definition at line 929 of file class.c.

Referenced by _TIFFVSetField(), and test_extra_values().

◆ comctl32_manifest

const char comctl32_manifest[]
static
Initial value:
=
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n"
" <assemblyIdentity\n"
" type=\"win32\"\n"
" name=\"Wine.User32.Tests\"\n"
" version=\"1.0.0.0\"\n"
" processorArchitecture=\"" ARCH "\"\n"
" />\n"
"<description>Wine comctl32 test suite</description>\n"
"<dependency>\n"
" <dependentAssembly>\n"
" <assemblyIdentity\n"
" type=\"win32\"\n"
" name=\"microsoft.windows.common-controls\"\n"
" version=\"6.0.0.0\"\n"
" processorArchitecture=\"" ARCH "\"\n"
" publicKeyToken=\"6595b64144ccf1df\"\n"
" language=\"*\"\n"
" />\n"
"</dependentAssembly>\n"
"</dependency>\n"
"</assembly>\n"
#define ARCH
Definition: class.c:47

Definition at line 50 of file class.c.

Referenced by test_comctl32_class().

◆ 

const struct { ... } extra_values[]
Initial value:
=
{
{"#32770",30,30},
{"Edit",6,8},
}

Referenced by test_extra_values().

◆ name

Definition at line 927 of file class.c.

◆ value

Definition at line 928 of file class.c.