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,
37 SetLastError( ERROR_NOACCESS
);
41 if (hInstance
== User32Instance
)
46 if (lpszClass
== NULL
)
48 SetLastError(ERROR_INVALID_PARAMETER
);
52 if (!RegisterDefaultClasses
)
54 ERR("GetClassInfoExA RegisterSystemControls\n");
55 RegisterSystemControls();
58 if (IS_ATOM(lpszClass
))
60 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
64 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
67 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
72 Ret
= NtUserGetClassInfo(hInstance
,
75 (LPWSTR
*)&pszMenuName
,
79 lpwcx
->lpszClassName
= lpszClass
;
80 // lpwcx->lpszMenuName = pszMenuName;
83 if (!IS_ATOM(lpszClass
))
85 RtlFreeUnicodeString(&ClassName
);
102 UNICODE_STRING ClassName
= {0};
106 TRACE("%p class/atom: %S/%04x %p\n", hInstance
,
107 IS_ATOM(lpszClass
) ? NULL
: lpszClass
,
108 IS_ATOM(lpszClass
) ? lpszClass
: 0,
111 /* From wine, for speed only, ReactOS supports the correct return in
112 * Win32k. cbSize is ignored.
116 SetLastError( ERROR_NOACCESS
);
120 if (hInstance
== User32Instance
)
125 if (lpszClass
== NULL
)
127 SetLastError(ERROR_INVALID_PARAMETER
);
131 if (!RegisterDefaultClasses
)
133 ERR("GetClassInfoExW RegisterSystemControls\n");
134 RegisterSystemControls();
137 if (IS_ATOM(lpszClass
))
139 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
143 RtlInitUnicodeString(&ClassName
,
147 Ret
= NtUserGetClassInfo( hInstance
,
154 lpwcx
->lpszClassName
= lpszClass
;
155 // lpwcx->lpszMenuName = pszMenuName;
169 LPWNDCLASSA lpWndClass
)
174 retval
= GetClassInfoExA(hInstance
, lpClassName
, &wcex
);
177 lpWndClass
->style
= wcex
.style
;
178 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
179 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
180 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
181 lpWndClass
->hInstance
= wcex
.hInstance
;
182 lpWndClass
->hIcon
= wcex
.hIcon
;
183 lpWndClass
->hCursor
= wcex
.hCursor
;
184 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
185 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
186 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
200 LPWNDCLASSW lpWndClass
)
205 retval
= GetClassInfoExW(hInstance
, lpClassName
, &wcex
);
208 lpWndClass
->style
= wcex
.style
;
209 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
210 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
211 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
212 lpWndClass
->hInstance
= wcex
.hInstance
;
213 lpWndClass
->hIcon
= wcex
.hIcon
;
214 lpWndClass
->hCursor
= wcex
.hCursor
;
215 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
216 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
217 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
223 // Based on find_winproc... Fixes many whine tests......
226 IntGetClsWndProc(PWND pWnd
, PCLS Class
, BOOL Ansi
)
229 ULONG_PTR gcpd
, Ret
= 0;
230 // If server side, sweep through proc list and return the client side proc.
231 if (Class
->CSF_flags
& CSF_SERVERSIDEPROC
)
232 { // Always scan through the list due to wine class "deftest".
233 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
235 if (GETPFNSERVER(i
) == Class
->lpfnWndProc
)
238 Ret
= (ULONG_PTR
)GETPFNCLIENTA(i
);
240 Ret
= (ULONG_PTR
)GETPFNCLIENTW(i
);
246 Ret
= (ULONG_PTR
)Class
->lpfnWndProc
;
247 // Return the proc if one of the FnId default class type.
248 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
251 { // If match return the right proc by type.
252 if (GETPFNCLIENTW(Class
->fnid
) == Class
->lpfnWndProc
)
253 Ret
= (ULONG_PTR
)GETPFNCLIENTA(Class
->fnid
);
257 if (GETPFNCLIENTA(Class
->fnid
) == Class
->lpfnWndProc
)
258 Ret
= (ULONG_PTR
)GETPFNCLIENTW(Class
->fnid
);
261 // Return on change or Ansi/Unicode proc equal.
262 if ( Ret
!= (ULONG_PTR
)Class
->lpfnWndProc
||
263 Ansi
== !!(Class
->CSF_flags
& CSF_ANSIPROC
) )
266 /* We have an Ansi and Unicode swap! If Ansi create Unicode proc handle.
267 This will force CallWindowProc to deal with it. */
268 gcpd
= NtUserGetCPD( UserHMGetHandle(pWnd
),
269 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWndtoCls
,
272 return (gcpd
? gcpd
: Ret
);
276 // Based on IntGetClsWndProc
279 IntGetWndProc(PWND pWnd
, BOOL Ansi
)
282 WNDPROC gcpd
, Ret
= 0;
283 PCLS Class
= DesktopPtrToUser(pWnd
->pcls
);
285 if (!Class
) return Ret
;
287 if (pWnd
->state
& WNDS_SERVERSIDEWINDOWPROC
)
289 for ( i
= FNID_FIRST
; i
<= FNID_SWITCH
; i
++)
291 if (GETPFNSERVER(i
) == pWnd
->lpfnWndProc
)
294 Ret
= GETPFNCLIENTA(i
);
296 Ret
= GETPFNCLIENTW(i
);
302 /* Edit controls are special - they return a wndproc handle when
303 GetWindowLongPtr is called with a different A/W.
304 On the other hand there is no W->A->W conversion so this control
305 is treated specially.
307 if (Class
->fnid
== FNID_EDIT
)
308 Ret
= pWnd
->lpfnWndProc
;
312 Ret
= pWnd
->lpfnWndProc
;
314 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
318 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
319 Ret
= GETPFNCLIENTA(Class
->fnid
);
323 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
324 Ret
= GETPFNCLIENTW(Class
->fnid
);
327 // Return on the change.
328 if ( Ret
!= pWnd
->lpfnWndProc
)
332 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
335 gcpd
= (WNDPROC
)NtUserGetCPD( UserHMGetHandle(pWnd
),
336 (Ansi
? UserGetCPDA2U
: UserGetCPDU2A
)|UserGetCPDWindow
,
339 return (gcpd
? gcpd
: Ret
);
342 static ULONG_PTR FASTCALL
343 IntGetClassLongA(PWND Wnd
, PCLS Class
, int nIndex
)
349 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
350 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
352 SetLastError(ERROR_INVALID_PARAMETER
);
355 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
362 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
366 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
369 case GCL_HBRBACKGROUND
:
370 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
371 if (Ret
!= 0 && Ret
< 0x4000)
372 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
376 //ERR("Cls 0x%x GCL_HMODULE 0x%x\n", Wnd->pcls, Class->hModule);
377 Ret
= (ULONG_PTR
)Class
->hModule
;
381 Ret
= (ULONG_PTR
)Class
->lpszClientAnsiMenuName
;
385 Ret
= (ULONG_PTR
)Class
->style
;
389 Ret
= (ULONG_PTR
)Class
->atomClassName
;
393 /* FIXME - get handle from pointer to CURSOR object */
394 Ret
= (ULONG_PTR
)Class
->hCursor
;
398 /* FIXME - get handle from pointer to ICON object */
399 Ret
= (ULONG_PTR
)Class
->hIcon
;
403 /* FIXME - get handle from pointer to ICON object */
404 Ret
= (ULONG_PTR
)Class
->hIconSm
;
408 Ret
= IntGetClsWndProc(Wnd
, Class
, TRUE
);
412 SetLastError(ERROR_INVALID_INDEX
);
420 static ULONG_PTR FASTCALL
421 IntGetClassLongW (PWND Wnd
, PCLS Class
, int nIndex
)
427 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
428 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
430 SetLastError(ERROR_INVALID_PARAMETER
);
433 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
440 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
444 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
447 case GCLP_HBRBACKGROUND
:
448 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
449 if (Ret
!= 0 && Ret
< 0x4000)
450 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
454 Ret
= (ULONG_PTR
)Class
->hModule
;
458 Ret
= (ULONG_PTR
)Class
->lpszClientUnicodeMenuName
;
462 Ret
= (ULONG_PTR
)Class
->style
;
466 Ret
= (ULONG_PTR
)Class
->atomClassName
;
470 /* FIXME - get handle from pointer to CURSOR object */
471 Ret
= (ULONG_PTR
)Class
->hCursor
;
475 /* FIXME - get handle from pointer to ICON object */
476 Ret
= (ULONG_PTR
)Class
->hIcon
;
480 /* FIXME - get handle from pointer to ICON object */
481 Ret
= (ULONG_PTR
)Class
->hIconSm
;
485 Ret
= IntGetClsWndProc(Wnd
, Class
, FALSE
);
489 SetLastError(ERROR_INVALID_INDEX
);
501 GetClassLongA(HWND hWnd
, int nIndex
)
507 TRACE("%p %d\n", hWnd
, nIndex
);
509 Wnd
= ValidateHwnd(hWnd
);
515 Class
= DesktopPtrToUser(Wnd
->pcls
);
521 case GCLP_HBRBACKGROUND
:
528 SetLastError(ERROR_INVALID_INDEX
);
532 Ret
= IntGetClassLongA(Wnd
, Class
, nIndex
);
536 Ret
= IntGetClassLongA(Wnd
, Class
, nIndex
);
541 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
544 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
557 GetClassLongW ( HWND hWnd
, int nIndex
)
563 TRACE("%p %d\n", hWnd
, nIndex
);
565 Wnd
= ValidateHwnd(hWnd
);
571 Class
= DesktopPtrToUser(Wnd
->pcls
);
577 case GCLP_HBRBACKGROUND
:
584 SetLastError(ERROR_INVALID_INDEX
);
588 Ret
= IntGetClassLongW(Wnd
, Class
, nIndex
);
592 Ret
= IntGetClassLongW(Wnd
, Class
, nIndex
);
597 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
600 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
615 GetClassLongPtrA(HWND hWnd
,
622 TRACE("%p %d\n", hWnd
, nIndex
);
624 Wnd
= ValidateHwnd(hWnd
);
630 Class
= DesktopPtrToUser(Wnd
->pcls
);
633 Ret
= IntGetClassLongA(Wnd
, Class
, nIndex
);
637 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
640 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
654 GetClassLongPtrW(HWND hWnd
,
661 TRACE("%p %d\n", hWnd
, nIndex
);
663 Wnd
= ValidateHwnd(hWnd
);
669 Class
= DesktopPtrToUser(Wnd
->pcls
);
672 Ret
= IntGetClassLongW(Wnd
, Class
, nIndex
);
676 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
679 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
699 ANSI_STRING ClassName
;
702 ClassName
.MaximumLength
= nMaxCount
;
703 ClassName
.Buffer
= lpClassName
;
705 Result
= NtUserGetClassName(hWnd
,
706 (PUNICODE_STRING
)&ClassName
,
709 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
710 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
711 IS_ATOM(lpClassName
) ? lpClassName
: 0,
728 UNICODE_STRING ClassName
;
731 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
732 ClassName
.Buffer
= lpClassName
;
734 Result
= NtUserGetClassName(hWnd
,
738 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
739 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
740 IS_ATOM(lpClassName
) ? lpClassName
: 0,
760 if (offset
< 0) return GetClassLongA( hwnd
, offset
);
762 Wnd
= ValidateHwnd(hwnd
);
766 class = DesktopPtrToUser(Wnd
->pcls
);
767 if (class == NULL
) return 0;
769 if (offset
<= class->cbclsExtra
- sizeof(WORD
))
770 memcpy( &retvalue
, (char *)(class + 1) + offset
, sizeof(retvalue
) );
772 SetLastError( ERROR_INVALID_INDEX
);
778 LONG_PTR
IntGetWindowLong( HWND hwnd
, INT offset
, UINT size
, BOOL unicode
)
780 LONG_PTR retvalue
= 0;
783 if (offset
== GWLP_HWNDPARENT
)
785 HWND parent
= GetAncestor( hwnd
, GA_PARENT
);
786 if (parent
== GetDesktopWindow()) parent
= GetWindow( hwnd
, GW_OWNER
);
787 return (ULONG_PTR
)parent
;
790 if (!(wndPtr
= ValidateHwnd( hwnd
)))
792 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
798 if (offset
> (int)(wndPtr
->cbwndExtra
- size
))
800 WARN("Invalid offset %d\n", offset
);
801 SetLastError( ERROR_INVALID_INDEX
);
804 retvalue
= *((LONG_PTR
*)((PCHAR
)(wndPtr
+ 1) + offset
));
806 /* WINE: special case for dialog window procedure */
807 //if ((offset == DWLP_DLGPROC) && (size == sizeof(LONG_PTR)) && (wndPtr->flags & WIN_ISDIALOG))
808 // retvalue = (LONG_PTR)IntGetWndProc( (WNDPROC)retvalue, unicode );
814 case GWLP_USERDATA
: retvalue
= wndPtr
->dwUserData
; break;
815 case GWL_STYLE
: retvalue
= wndPtr
->style
; break;
816 case GWL_EXSTYLE
: retvalue
= wndPtr
->ExStyle
; break;
817 case GWLP_ID
: retvalue
= wndPtr
->IDMenu
; break;
818 case GWLP_HINSTANCE
: retvalue
= (ULONG_PTR
)wndPtr
->hModule
; break;
821 if (!TestWindowProcess(wndPtr
))
823 SetLastError(ERROR_ACCESS_DENIED
);
826 retvalue
= (ULONG_PTR
)IntGetWndProc(wndPtr
, !unicode
);
830 WARN("Unknown offset %d\n", offset
);
831 SetLastError( ERROR_INVALID_INDEX
);
842 GetWindowLongA ( HWND hWnd
, int nIndex
)
844 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), FALSE
);
852 GetWindowLongW(HWND hWnd
, int nIndex
)
854 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), TRUE
);
863 GetWindowLongPtrA(HWND hWnd
,
866 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), FALSE
);
874 GetWindowLongPtrW(HWND hWnd
,
877 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), TRUE
);
887 GetWindowWord(HWND hWnd
, int nIndex
)
893 case GWLP_HWNDPARENT
:
898 WARN("Invalid offset %d\n", nIndex
);
899 SetLastError( ERROR_INVALID_INDEX
);
904 return IntGetWindowLong( hWnd
, nIndex
, sizeof(WORD
), FALSE
);
917 /* FIXME: Implement correct functionality of RealGetWindowClass */
918 return GetClassNameW(hwnd
,pszType
,cchType
);
932 /* FIXME: Implement correct functionality of RealGetWindowClass */
933 return GetClassNameA(hwnd
,pszType
,cchType
);
937 * Create a small icon based on a standard icon
940 CreateSmallIcon(HICON StdIcon
)
942 HICON SmallIcon
= NULL
;
946 BITMAP StdBitmapInfo
;
947 HDC hSourceDc
= NULL
;
950 HBITMAP OldSourceBitmap
= NULL
;
951 HBITMAP OldDestBitmap
= NULL
;
953 SmallInfo
.hbmColor
= NULL
;
954 SmallInfo
.hbmMask
= NULL
;
956 /* We need something to work with... */
962 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
963 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
964 if (! GetIconInfo(StdIcon
, &StdInfo
))
966 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
969 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
971 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
972 StdIcon
, StdInfo
.hbmColor
);
975 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
976 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
978 /* Icon already has the correct dimensions */
982 hSourceDc
= CreateCompatibleDC(NULL
);
983 if (NULL
== hSourceDc
)
985 ERR("Failed to create source DC\n");
988 hDestDc
= CreateCompatibleDC(NULL
);
991 ERR("Failed to create dest DC\n");
995 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
996 if (NULL
== OldSourceBitmap
)
998 ERR("Failed to select source color bitmap\n");
1001 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hSourceDc
, SmallIconWidth
,
1003 if (NULL
== SmallInfo
.hbmColor
)
1005 ERR("Failed to create color bitmap\n");
1008 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
1009 if (NULL
== OldDestBitmap
)
1011 ERR("Failed to select dest color bitmap\n");
1014 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
1015 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
1016 StdBitmapInfo
.bmHeight
, SRCCOPY
))
1018 ERR("Failed to stretch color bitmap\n");
1022 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
1024 ERR("Failed to select source mask bitmap\n");
1027 SmallInfo
.hbmMask
= CreateCompatibleBitmap(hSourceDc
, SmallIconWidth
, SmallIconHeight
);
1028 if (NULL
== SmallInfo
.hbmMask
)
1030 ERR("Failed to create mask bitmap\n");
1033 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
1035 ERR("Failed to select dest mask bitmap\n");
1038 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
1039 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
1040 StdBitmapInfo
.bmHeight
, SRCCOPY
))
1042 ERR("Failed to stretch mask bitmap\n");
1046 SmallInfo
.fIcon
= TRUE
;
1047 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
1048 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
1049 SmallIcon
= CreateIconIndirect(&SmallInfo
);
1050 if (NULL
== SmallIcon
)
1052 ERR("Failed to create icon\n");
1057 if (NULL
!= SmallInfo
.hbmMask
)
1059 DeleteObject(SmallInfo
.hbmMask
);
1061 if (NULL
!= OldDestBitmap
)
1063 SelectObject(hDestDc
, OldDestBitmap
);
1065 if (NULL
!= SmallInfo
.hbmColor
)
1067 DeleteObject(SmallInfo
.hbmColor
);
1069 if (NULL
!= hDestDc
)
1073 if (NULL
!= OldSourceBitmap
)
1075 SelectObject(hSourceDc
, OldSourceBitmap
);
1077 if (NULL
!= hSourceDc
)
1079 DeleteDC(hSourceDc
);
1087 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
1094 WNDCLASSEXW WndClass
;
1095 UNICODE_STRING ClassName
;
1096 UNICODE_STRING MenuName
= {0};
1097 CLSMENUNAME clsMenuName
;
1098 ANSI_STRING AnsiMenuName
;
1100 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
1101 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
1102 lpwcx
->lpszClassName
== NULL
)
1104 TRACE("RegisterClassExWOWW Invalid Parameter Error!\n");
1105 SetLastError(ERROR_INVALID_PARAMETER
);
1111 if (!RegisterDefaultClasses
) RegisterSystemControls();
1114 * On real Windows this looks more like:
1115 * if (lpwcx->hInstance == User32Instance &&
1116 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
1117 * But since I have no idea what the magic field in the
1118 * TEB structure means, I rather decided to omit that.
1121 GetWin32ClientInfo()->dwExpWinVer & (WINVER == 0x400)
1123 if (lpwcx
->hInstance
== User32Instance
)
1125 TRACE("RegisterClassExWOWW User32Instance!\n");
1126 SetLastError(ERROR_INVALID_PARAMETER
);
1129 /* Yes, this is correct. We should modify the passed structure. */
1130 if (lpwcx
->hInstance
== NULL
)
1131 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1133 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1135 if (NULL
== WndClass
.hIconSm
)
1137 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1140 if (WndClass
.lpszMenuName
!= NULL
)
1142 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1144 if (WndClass
.lpszMenuName
[0])
1146 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1147 RtlUnicodeStringToAnsiString( &AnsiMenuName
, &MenuName
, TRUE
);
1152 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1153 AnsiMenuName
.Buffer
= (PCHAR
)WndClass
.lpszMenuName
;
1157 if (IS_ATOM(WndClass
.lpszClassName
))
1160 ClassName
.MaximumLength
= 0;
1161 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1165 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1168 clsMenuName
.pszClientAnsiMenuName
= AnsiMenuName
.Buffer
;
1169 clsMenuName
.pwszClientUnicodeMenuName
= MenuName
.Buffer
;
1170 clsMenuName
.pusMenuName
= &MenuName
;
1172 Atom
= NtUserRegisterClassExWOW( &WndClass
,
1174 NULL
, //PUNICODE_STRING ClsNVersion,
1180 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1181 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1182 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1191 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
1194 WNDCLASSEXW WndClass
;
1195 WCHAR mname
[MAX_BUFFER_LEN
];
1196 WCHAR cname
[MAX_BUFFER_LEN
];
1198 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
1200 if (WndClass
.lpszMenuName
!= NULL
)
1202 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1204 if (WndClass
.lpszMenuName
[0])
1206 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszMenuName
, -1, mname
, MAX_ATOM_LEN
+ 1 )) return 0;
1208 WndClass
.lpszMenuName
= mname
;
1213 if (!IS_ATOM(WndClass
.lpszClassName
))
1215 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszClassName
, -1, cname
, MAX_ATOM_LEN
+ 1 )) return 0;
1217 WndClass
.lpszClassName
= cname
;
1220 Atom
= RegisterClassExWOWW( &WndClass
,
1226 TRACE("A atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1227 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1228 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1237 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
1241 Atom
= RegisterClassExWOWW( (WNDCLASSEXW
*)lpwcx
, 0, 0, 0, TRUE
);
1243 TRACE("W atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d\n",
1244 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1245 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
);
1254 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1258 if (lpWndClass
== NULL
)
1261 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1262 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1263 Class
.hIconSm
= NULL
;
1265 return RegisterClassExA(&Class
);
1272 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1276 if (lpWndClass
== NULL
)
1279 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1280 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1281 Class
.hIconSm
= NULL
;
1283 return RegisterClassExW(&Class
);
1291 SetClassLongA (HWND hWnd
,
1295 PSTR lpStr
= (PSTR
)(ULONG_PTR
)dwNewLong
;
1296 UNICODE_STRING Value
= {0};
1297 BOOL Allocated
= FALSE
;
1300 /* FIXME - portability!!!! */
1302 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1304 if (!IS_INTRESOURCE(lpStr
))
1306 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1309 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1316 Value
.Buffer
= (PWSTR
)lpStr
;
1318 dwNewLong
= (LONG_PTR
)&Value
;
1320 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1322 if (!IS_ATOM(lpStr
))
1324 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1327 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1334 Value
.Buffer
= (PWSTR
)lpStr
;
1336 dwNewLong
= (LONG_PTR
)&Value
;
1339 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1346 RtlFreeUnicodeString(&Value
);
1358 SetClassLongW(HWND hWnd
,
1362 PWSTR lpStr
= (PWSTR
)(ULONG_PTR
)dwNewLong
;
1363 UNICODE_STRING Value
= {0};
1365 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1367 /* FIXME - portability!!!! */
1369 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1371 if (!IS_INTRESOURCE(lpStr
))
1373 RtlInitUnicodeString(&Value
,
1377 Value
.Buffer
= lpStr
;
1379 dwNewLong
= (LONG_PTR
)&Value
;
1381 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1383 if (!IS_ATOM(lpStr
))
1385 RtlInitUnicodeString(&Value
,
1389 Value
.Buffer
= lpStr
;
1391 dwNewLong
= (LONG_PTR
)&Value
;
1394 return (DWORD
)NtUserSetClassLong(hWnd
,
1406 SetClassLongPtrA(HWND hWnd
,
1419 SetClassLongPtrW(HWND hWnd
,
1438 * NOTE: Obsoleted in 32-bit windows
1441 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1444 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1452 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
1457 case GWLP_HINSTANCE
:
1458 case GWLP_HWNDPARENT
:
1463 WARN("Invalid offset %d\n", nIndex
);
1464 SetLastError( ERROR_INVALID_INDEX
);
1469 return NtUserSetWindowLong( hWnd
, nIndex
, wNewWord
, FALSE
);
1482 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1495 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1504 SetWindowLongPtrA(HWND hWnd
,
1508 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1516 SetWindowLongPtrW(HWND hWnd
,
1520 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1531 HINSTANCE hInstance
)
1533 UNICODE_STRING ClassName
= {0};
1536 TRACE("class/atom: %s/%04x %p\n",
1537 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1538 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1541 if (!IS_ATOM(lpClassName
))
1543 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1546 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1551 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1553 Ret
= NtUserUnregisterClass(&ClassName
,
1557 if (!IS_ATOM(lpClassName
))
1558 RtlFreeUnicodeString(&ClassName
);
1570 LPCWSTR lpClassName
,
1571 HINSTANCE hInstance
)
1573 UNICODE_STRING ClassName
= {0};
1575 TRACE("class/atom: %S/%04x %p\n",
1576 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1577 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1580 if (!IS_ATOM(lpClassName
))
1582 RtlInitUnicodeString(&ClassName
,
1586 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1588 return NtUserUnregisterClass(&ClassName
,