2 * PROJECT: ReactOS user32.dll
3 * COPYRIGHT: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/user32/windows/class.c
5 * PURPOSE: Window classes
6 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 09-05-2001 CSH Created
13 #include <wine/debug.h>
14 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
26 UNICODE_STRING ClassName
= {0};
30 TRACE("%p class/atom: %s/%04x %p\n", hInstance
,
31 IS_ATOM(lpszClass
) ? NULL
: lpszClass
,
32 IS_ATOM(lpszClass
) ? lpszClass
: 0,
35 //HACKHACK: This is ROS-specific and should go away
36 lpwcx
->cbSize
= sizeof(*lpwcx
);
38 if (hInstance
== User32Instance
)
43 if (lpszClass
== NULL
)
45 SetLastError(ERROR_INVALID_PARAMETER
);
49 if (!RegisterDefaultClasses
)
51 ERR("GetClassInfoExA RegisterSystemControls\n");
52 RegisterSystemControls();
55 if (IS_ATOM(lpszClass
))
57 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
61 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
64 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
69 Ret
= NtUserGetClassInfo(hInstance
,
72 (LPWSTR
*)&pszMenuName
,
76 lpwcx
->lpszClassName
= lpszClass
;
77 // lpwcx->lpszMenuName = pszMenuName;
80 if (!IS_ATOM(lpszClass
))
82 RtlFreeUnicodeString(&ClassName
);
99 UNICODE_STRING ClassName
= {0};
103 TRACE("%p class/atom: %S/%04x %p\n", hInstance
,
104 IS_ATOM(lpszClass
) ? NULL
: lpszClass
,
105 IS_ATOM(lpszClass
) ? lpszClass
: 0,
108 //HACKHACK: This is ROS-specific and should go away
109 lpwcx
->cbSize
= sizeof(*lpwcx
);
111 if (hInstance
== User32Instance
)
116 if (lpszClass
== NULL
)
118 SetLastError(ERROR_INVALID_PARAMETER
);
122 if (!RegisterDefaultClasses
)
124 ERR("GetClassInfoExW RegisterSystemControls\n");
125 RegisterSystemControls();
128 if (IS_ATOM(lpszClass
))
130 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
134 RtlInitUnicodeString(&ClassName
,
138 Ret
= NtUserGetClassInfo( hInstance
,
145 lpwcx
->lpszClassName
= lpszClass
;
146 // lpwcx->lpszMenuName = pszMenuName;
160 LPWNDCLASSA lpWndClass
)
165 retval
= GetClassInfoExA(hInstance
, lpClassName
, &wcex
);
168 lpWndClass
->style
= wcex
.style
;
169 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
170 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
171 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
172 lpWndClass
->hInstance
= wcex
.hInstance
;
173 lpWndClass
->hIcon
= wcex
.hIcon
;
174 lpWndClass
->hCursor
= wcex
.hCursor
;
175 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
176 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
177 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
191 LPWNDCLASSW lpWndClass
)
196 retval
= GetClassInfoExW(hInstance
, lpClassName
, &wcex
);
199 lpWndClass
->style
= wcex
.style
;
200 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
201 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
202 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
203 lpWndClass
->hInstance
= wcex
.hInstance
;
204 lpWndClass
->hIcon
= wcex
.hIcon
;
205 lpWndClass
->hCursor
= wcex
.hCursor
;
206 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
207 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
208 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
214 // Based on find_winproc... Fixes many whine tests......
217 IntGetClsWndProc(PWND pWnd
, PCLS Class
, BOOL Ansi
)
220 ULONG_PTR gcpd
, Ret
= 0;
221 // If server side, sweep through proc list and return the client side proc.
222 if (Class
->CSF_flags
& CSF_SERVERSIDEPROC
)
223 { // Always scan through the list due to wine class "deftest".
224 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
226 if (GETPFNSERVER(i
) == Class
->lpfnWndProc
)
229 Ret
= (ULONG_PTR
)GETPFNCLIENTA(i
);
231 Ret
= (ULONG_PTR
)GETPFNCLIENTW(i
);
237 Ret
= (ULONG_PTR
)Class
->lpfnWndProc
;
238 // Return the proc if one of the FnId default class type.
239 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
242 { // If match return the right proc by type.
243 if (GETPFNCLIENTW(Class
->fnid
) == Class
->lpfnWndProc
)
244 Ret
= (ULONG_PTR
)GETPFNCLIENTA(Class
->fnid
);
248 if (GETPFNCLIENTA(Class
->fnid
) == Class
->lpfnWndProc
)
249 Ret
= (ULONG_PTR
)GETPFNCLIENTW(Class
->fnid
);
252 // Return on change or Ansi/Unicode proc equal.
253 if ( Ret
!= (ULONG_PTR
)Class
->lpfnWndProc
||
254 Ansi
== !!(Class
->CSF_flags
& CSF_ANSIPROC
) )
257 /* We have an Ansi and Unicode swap! If Ansi create Unicode proc handle.
258 This will force CallWindowProc to deal with it. */
259 gcpd
= NtUserGetCPD( UserHMGetHandle(pWnd
),
260 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWndtoCls
,
263 return (gcpd
? gcpd
: Ret
);
267 // Based on IntGetClsWndProc
270 IntGetWndProc(PWND pWnd
, BOOL Ansi
)
273 ULONG_PTR gcpd
, Ret
= 0;
274 PCLS Class
= DesktopPtrToUser(pWnd
->pcls
);
276 if (!Class
) return Ret
;
278 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
280 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
282 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
285 Ret
= (ULONG_PTR
)GETPFNCLIENTA(i
);
287 Ret
= (ULONG_PTR
)GETPFNCLIENTW(i
);
293 /* Edit controls are special - they return a wndproc handle when
294 GetWindowLongPtr is called with a different A/W.
295 On the other hand there is no W->A->W conversion so this control
296 is treated specially.
298 if (Class
->fnid
== FNID_EDIT
)
299 Ret
= (ULONG_PTR
)pWnd
->lpfnWndProc
;
303 Ret
= (ULONG_PTR
)pWnd
->lpfnWndProc
;
305 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
309 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
310 Ret
= (ULONG_PTR
)GETPFNCLIENTA(Class
->fnid
);
314 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
315 Ret
= (ULONG_PTR
)GETPFNCLIENTW(Class
->fnid
);
318 // Return on the change.
319 if ( Ret
!= (ULONG_PTR
)pWnd
->lpfnWndProc
)
323 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
326 gcpd
= NtUserGetCPD( UserHMGetHandle(pWnd
),
327 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
330 return (gcpd
? gcpd
: Ret
);
337 GetClassLongA(HWND hWnd
, int nIndex
)
343 TRACE("%p %d\n", hWnd
, nIndex
);
345 Wnd
= ValidateHwnd(hWnd
);
351 Class
= DesktopPtrToUser(Wnd
->pcls
);
356 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
357 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
359 SetLastError(ERROR_INVALID_PARAMETER
);
362 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
369 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
373 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
376 case GCL_HBRBACKGROUND
:
377 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
378 if (Ret
!= 0 && Ret
< 0x4000)
379 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
383 //ERR("Cls 0x%x GCL_HMODULE 0x%x\n", Wnd->pcls, Class->hModule);
384 Ret
= (ULONG_PTR
)Class
->hModule
;
388 Ret
= (ULONG_PTR
)Class
->lpszClientAnsiMenuName
;
392 Ret
= (ULONG_PTR
)Class
->style
;
396 Ret
= (ULONG_PTR
)Class
->atomClassName
;
400 /* FIXME - get handle from pointer to CURSOR object */
401 Ret
= (ULONG_PTR
)Class
->hCursor
;
405 /* FIXME - get handle from pointer to ICON object */
406 Ret
= (ULONG_PTR
)Class
->hIcon
;
410 /* FIXME - get handle from pointer to ICON object */
411 Ret
= (ULONG_PTR
)Class
->hIconSm
;
415 Ret
= IntGetClsWndProc(Wnd
, Class
, TRUE
);
419 SetLastError(ERROR_INVALID_INDEX
);
426 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
429 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
442 GetClassLongW ( HWND hWnd
, int nIndex
)
448 TRACE("%p %d\n", hWnd
, nIndex
);
450 Wnd
= ValidateHwnd(hWnd
);
456 Class
= DesktopPtrToUser(Wnd
->pcls
);
461 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
462 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
464 SetLastError(ERROR_INVALID_PARAMETER
);
467 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
474 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
478 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
481 case GCL_HBRBACKGROUND
:
482 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
483 if (Ret
!= 0 && Ret
< 0x4000)
484 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
488 Ret
= (ULONG_PTR
)Class
->hModule
;
492 Ret
= (ULONG_PTR
)Class
->lpszClientUnicodeMenuName
;
496 Ret
= (ULONG_PTR
)Class
->style
;
500 Ret
= (ULONG_PTR
)Class
->atomClassName
;
504 /* FIXME - get handle from pointer to CURSOR object */
505 Ret
= (ULONG_PTR
)Class
->hCursor
;
509 /* FIXME - get handle from pointer to ICON object */
510 Ret
= (ULONG_PTR
)Class
->hIcon
;
514 /* FIXME - get handle from pointer to ICON object */
515 Ret
= (ULONG_PTR
)Class
->hIconSm
;
519 Ret
= IntGetClsWndProc(Wnd
, Class
, FALSE
);
523 SetLastError(ERROR_INVALID_INDEX
);
530 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
533 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
551 ANSI_STRING ClassName
;
554 ClassName
.MaximumLength
= nMaxCount
;
555 ClassName
.Buffer
= lpClassName
;
557 Result
= NtUserGetClassName(hWnd
,
558 (PUNICODE_STRING
)&ClassName
,
561 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
562 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
563 IS_ATOM(lpClassName
) ? lpClassName
: 0,
580 UNICODE_STRING ClassName
;
583 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
584 ClassName
.Buffer
= lpClassName
;
586 Result
= NtUserGetClassName(hWnd
,
590 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
591 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
592 IS_ATOM(lpClassName
) ? lpClassName
: 0,
612 if (offset
< 0) return GetClassLongA( hwnd
, offset
);
614 Wnd
= ValidateHwnd(hwnd
);
618 class = DesktopPtrToUser(Wnd
->pcls
);
619 if (class == NULL
) return 0;
621 if (offset
<= class->cbclsExtra
- sizeof(WORD
))
622 memcpy( &retvalue
, (char *)(class + 1) + offset
, sizeof(retvalue
) );
624 SetLastError( ERROR_INVALID_INDEX
);
635 GetWindowLongA ( HWND hWnd
, int nIndex
)
639 Wnd
= ValidateHwnd(hWnd
);
645 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->cbwndExtra
)
647 SetLastError(ERROR_INVALID_PARAMETER
);
650 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
661 return (LONG
)Wnd
->hModule
;
665 return Wnd
->dwUserData
;
669 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
670 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
674 if (!TestWindowProcess(Wnd
))
676 SetLastError(ERROR_ACCESS_DENIED
);
679 return IntGetWndProc(Wnd
, TRUE
);
682 SetLastError(ERROR_INVALID_PARAMETER
);
694 GetWindowLongW(HWND hWnd
, int nIndex
)
698 Wnd
= ValidateHwnd(hWnd
);
704 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->cbwndExtra
)
706 SetLastError(ERROR_INVALID_PARAMETER
);
709 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
720 return (LONG
)Wnd
->hModule
;
724 return Wnd
->dwUserData
;
728 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
729 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
733 if (!TestWindowProcess(Wnd
))
735 SetLastError(ERROR_ACCESS_DENIED
);
738 return IntGetWndProc(Wnd
, FALSE
);
741 SetLastError(ERROR_INVALID_PARAMETER
);
752 GetWindowWord(HWND hWnd
, int nIndex
)
754 return (WORD
)GetWindowLongW(hWnd
, nIndex
);
762 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
764 return (WORD
)NtUserSetWindowLong ( hWnd
, nIndex
, (LONG
)wNewWord
, TRUE
);
777 /* FIXME: Implement correct functionality of RealGetWindowClass */
778 return GetClassNameW(hwnd
,pszType
,cchType
);
792 /* FIXME: Implement correct functionality of RealGetWindowClass */
793 return GetClassNameA(hwnd
,pszType
,cchType
);
797 * Create a small icon based on a standard icon
800 CreateSmallIcon(HICON StdIcon
)
802 HICON SmallIcon
= NULL
;
806 BITMAP StdBitmapInfo
;
808 HDC hSourceDc
= NULL
;
811 HBITMAP OldSourceBitmap
= NULL
;
812 HBITMAP OldDestBitmap
= NULL
;
814 SmallInfo
.hbmColor
= NULL
;
815 SmallInfo
.hbmMask
= NULL
;
817 /* We need something to work with... */
823 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
824 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
825 if (! GetIconInfo(StdIcon
, &StdInfo
))
827 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
830 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
832 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
833 StdIcon
, StdInfo
.hbmColor
);
836 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
837 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
839 /* Icon already has the correct dimensions */
843 /* Get a handle to a info DC and handles to DCs which can be used to
844 select a bitmap into. This is done to avoid triggering a switch to
845 graphics mode (if we're currently in text/blue screen mode) */
846 hInfoDc
= CreateICW(NULL
, NULL
, NULL
, NULL
);
849 ERR("Failed to create info DC\n");
852 hSourceDc
= CreateCompatibleDC(NULL
);
853 if (NULL
== hSourceDc
)
855 ERR("Failed to create source DC\n");
858 hDestDc
= CreateCompatibleDC(NULL
);
861 ERR("Failed to create dest DC\n");
865 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
866 if (NULL
== OldSourceBitmap
)
868 ERR("Failed to select source color bitmap\n");
871 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hInfoDc
, SmallIconWidth
,
873 if (NULL
== SmallInfo
.hbmColor
)
875 ERR("Failed to create color bitmap\n");
878 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
879 if (NULL
== OldDestBitmap
)
881 ERR("Failed to select dest color bitmap\n");
884 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
885 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
886 StdBitmapInfo
.bmHeight
, SRCCOPY
))
888 ERR("Failed to stretch color bitmap\n");
892 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
894 ERR("Failed to select source mask bitmap\n");
897 SmallInfo
.hbmMask
= CreateBitmap(SmallIconWidth
, SmallIconHeight
, 1, 1,
899 if (NULL
== SmallInfo
.hbmMask
)
901 ERR("Failed to create mask bitmap\n");
904 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
906 ERR("Failed to select dest mask bitmap\n");
909 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
910 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
911 StdBitmapInfo
.bmHeight
, SRCCOPY
))
913 ERR("Failed to stretch mask bitmap\n");
917 SmallInfo
.fIcon
= TRUE
;
918 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
919 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
920 SmallIcon
= CreateIconIndirect(&SmallInfo
);
921 if (NULL
== SmallIcon
)
923 ERR("Failed to create icon\n");
928 if (NULL
!= SmallInfo
.hbmMask
)
930 DeleteObject(SmallInfo
.hbmMask
);
932 if (NULL
!= OldDestBitmap
)
934 SelectObject(hDestDc
, OldDestBitmap
);
936 if (NULL
!= SmallInfo
.hbmColor
)
938 DeleteObject(SmallInfo
.hbmColor
);
944 if (NULL
!= OldSourceBitmap
)
946 SelectObject(hSourceDc
, OldSourceBitmap
);
948 if (NULL
!= hSourceDc
)
962 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
969 WNDCLASSEXW WndClass
;
970 UNICODE_STRING ClassName
;
971 UNICODE_STRING MenuName
= {0};
972 CLSMENUNAME clsMenuName
;
973 ANSI_STRING AnsiMenuName
;
975 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
976 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
977 lpwcx
->lpszClassName
== NULL
)
979 TRACE("RegisterClassExWOWW Invalid Parameter Error!\n");
980 SetLastError(ERROR_INVALID_PARAMETER
);
986 if (!RegisterDefaultClasses
) RegisterSystemControls();
989 * On real Windows this looks more like:
990 * if (lpwcx->hInstance == User32Instance &&
991 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
992 * But since I have no idea what the magic field in the
993 * TEB structure means, I rather decided to omit that.
996 GetWin32ClientInfo()->dwExpWinVer & (WINVER == 0x400)
998 if (lpwcx
->hInstance
== User32Instance
)
1000 TRACE("RegisterClassExWOWW User32Instance!\n");
1001 SetLastError(ERROR_INVALID_PARAMETER
);
1004 /* Yes, this is correct. We should modify the passed structure. */
1005 if (lpwcx
->hInstance
== NULL
)
1006 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1008 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1010 if (NULL
== WndClass
.hIconSm
)
1012 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1015 if (WndClass
.lpszMenuName
!= NULL
)
1017 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1019 if (WndClass
.lpszMenuName
[0])
1021 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1022 RtlUnicodeStringToAnsiString( &AnsiMenuName
, &MenuName
, TRUE
);
1027 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1028 AnsiMenuName
.Buffer
= (PCHAR
)WndClass
.lpszMenuName
;
1032 if (IS_ATOM(WndClass
.lpszClassName
))
1035 ClassName
.MaximumLength
= 0;
1036 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1040 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1043 clsMenuName
.pszClientAnsiMenuName
= AnsiMenuName
.Buffer
;
1044 clsMenuName
.pwszClientUnicodeMenuName
= MenuName
.Buffer
;
1045 clsMenuName
.pusMenuName
= &MenuName
;
1047 Atom
= NtUserRegisterClassExWOW( &WndClass
,
1049 NULL
, //PUNICODE_STRING ClsNVersion,
1055 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1056 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1057 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1066 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
1069 WNDCLASSEXW WndClass
;
1070 WCHAR mname
[MAX_BUFFER_LEN
];
1071 WCHAR cname
[MAX_BUFFER_LEN
];
1073 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
1075 if (WndClass
.lpszMenuName
!= NULL
)
1077 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1079 if (WndClass
.lpszMenuName
[0])
1081 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszMenuName
, -1, mname
, MAX_ATOM_LEN
+ 1 )) return 0;
1083 WndClass
.lpszMenuName
= mname
;
1088 if (!IS_ATOM(WndClass
.lpszClassName
))
1090 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszClassName
, -1, cname
, MAX_ATOM_LEN
+ 1 )) return 0;
1092 WndClass
.lpszClassName
= cname
;
1095 Atom
= RegisterClassExWOWW( &WndClass
,
1101 TRACE("A atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1102 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1103 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1112 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
1116 Atom
= RegisterClassExWOWW( (WNDCLASSEXW
*)lpwcx
, 0, 0, 0, TRUE
);
1118 TRACE("W atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d\n",
1119 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1120 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
);
1129 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1133 if (lpWndClass
== NULL
)
1136 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1137 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1138 Class
.hIconSm
= NULL
;
1140 return RegisterClassExA(&Class
);
1147 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1151 if (lpWndClass
== NULL
)
1154 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1155 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1156 Class
.hIconSm
= NULL
;
1158 return RegisterClassExW(&Class
);
1166 SetClassLongA (HWND hWnd
,
1170 PSTR lpStr
= (PSTR
)dwNewLong
;
1171 UNICODE_STRING Value
= {0};
1172 BOOL Allocated
= FALSE
;
1175 /* FIXME - portability!!!! */
1177 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1179 if (!IS_INTRESOURCE(lpStr
))
1181 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1184 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1191 Value
.Buffer
= (PWSTR
)lpStr
;
1193 dwNewLong
= (LONG
)&Value
;
1195 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1197 if (!IS_ATOM(lpStr
))
1199 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1202 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1209 Value
.Buffer
= (PWSTR
)lpStr
;
1211 dwNewLong
= (LONG
)&Value
;
1214 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1221 RtlFreeUnicodeString(&Value
);
1233 SetClassLongW(HWND hWnd
,
1237 PWSTR lpStr
= (PWSTR
)dwNewLong
;
1238 UNICODE_STRING Value
= {0};
1240 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1242 /* FIXME - portability!!!! */
1244 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1246 if (!IS_INTRESOURCE(lpStr
))
1248 RtlInitUnicodeString(&Value
,
1252 Value
.Buffer
= lpStr
;
1254 dwNewLong
= (LONG
)&Value
;
1256 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1258 if (!IS_ATOM(lpStr
))
1260 RtlInitUnicodeString(&Value
,
1264 Value
.Buffer
= lpStr
;
1266 dwNewLong
= (LONG
)&Value
;
1269 return (DWORD
)NtUserSetClassLong(hWnd
,
1286 * NOTE: Obsoleted in 32-bit windows
1289 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1292 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1306 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1320 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1331 HINSTANCE hInstance
)
1333 UNICODE_STRING ClassName
= {0};
1336 TRACE("class/atom: %s/%04x %p\n",
1337 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1338 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1341 if (!IS_ATOM(lpClassName
))
1343 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1346 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1351 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1353 Ret
= NtUserUnregisterClass(&ClassName
,
1357 if (!IS_ATOM(lpClassName
))
1358 RtlFreeUnicodeString(&ClassName
);
1370 LPCWSTR lpClassName
,
1371 HINSTANCE hInstance
)
1373 UNICODE_STRING ClassName
= {0};
1375 TRACE("class/atom: %S/%04x %p\n",
1376 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1377 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1380 if (!IS_ATOM(lpClassName
))
1382 RtlInitUnicodeString(&ClassName
,
1386 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1388 return NtUserUnregisterClass(&ClassName
,