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};
29 TRACE("%p class/atom: %s/%04x %p\n", hInstance
,
30 IS_ATOM(lpszClass
) ? NULL
: lpszClass
,
31 IS_ATOM(lpszClass
) ? lpszClass
: 0,
34 //HACKHACK: This is ROS-specific and should go away
35 lpwcx
->cbSize
= sizeof(*lpwcx
);
37 if (hInstance
== User32Instance
)
42 if (lpszClass
== NULL
)
44 SetLastError(ERROR_INVALID_PARAMETER
);
48 if (IS_ATOM(lpszClass
))
50 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
54 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
57 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
62 Ret
= NtUserGetClassInfo(hInstance
,
68 if (!IS_ATOM(lpszClass
))
70 RtlFreeUnicodeString(&ClassName
);
87 UNICODE_STRING ClassName
= {0};
89 TRACE("%p class/atom: %S/%04x %p\n", hInstance
,
90 IS_ATOM(lpszClass
) ? NULL
: lpszClass
,
91 IS_ATOM(lpszClass
) ? lpszClass
: 0,
94 //HACKHACK: This is ROS-specific and should go away
95 lpwcx
->cbSize
= sizeof(*lpwcx
);
97 if (hInstance
== User32Instance
)
102 if (lpszClass
== NULL
)
104 SetLastError(ERROR_INVALID_PARAMETER
);
108 if (IS_ATOM(lpszClass
))
110 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpszClass
);
114 RtlInitUnicodeString(&ClassName
,
118 return NtUserGetClassInfo(hInstance
,
134 LPWNDCLASSA lpWndClass
)
139 retval
= GetClassInfoExA(hInstance
, lpClassName
, &wcex
);
142 lpWndClass
->style
= wcex
.style
;
143 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
144 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
145 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
146 lpWndClass
->hInstance
= wcex
.hInstance
;
147 lpWndClass
->hIcon
= wcex
.hIcon
;
148 lpWndClass
->hCursor
= wcex
.hCursor
;
149 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
150 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
151 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
165 LPWNDCLASSW lpWndClass
)
170 retval
= GetClassInfoExW(hInstance
, lpClassName
, &wcex
);
173 lpWndClass
->style
= wcex
.style
;
174 lpWndClass
->lpfnWndProc
= wcex
.lpfnWndProc
;
175 lpWndClass
->cbClsExtra
= wcex
.cbClsExtra
;
176 lpWndClass
->cbWndExtra
= wcex
.cbWndExtra
;
177 lpWndClass
->hInstance
= wcex
.hInstance
;
178 lpWndClass
->hIcon
= wcex
.hIcon
;
179 lpWndClass
->hCursor
= wcex
.hCursor
;
180 lpWndClass
->hbrBackground
= wcex
.hbrBackground
;
181 lpWndClass
->lpszMenuName
= wcex
.lpszMenuName
;
182 lpWndClass
->lpszClassName
= wcex
.lpszClassName
;
191 GetClassLongA(HWND hWnd
, int nIndex
)
197 TRACE("%p %d\n", hWnd
, nIndex
);
199 Wnd
= ValidateHwnd(hWnd
);
205 Class
= DesktopPtrToUser(Wnd
->Class
);
210 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
211 nIndex
+ sizeof(ULONG_PTR
) > Class
->ClsExtra
)
213 SetLastError(ERROR_INVALID_PARAMETER
);
216 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
223 Ret
= (ULONG_PTR
)Class
->WndExtra
;
227 Ret
= (ULONG_PTR
)Class
->ClsExtra
;
230 case GCL_HBRBACKGROUND
:
231 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
232 if (Ret
!= 0 && Ret
< 0x4000)
233 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
237 Ret
= (ULONG_PTR
)Class
->hInstance
;
241 Ret
= (ULONG_PTR
)Class
->AnsiMenuName
;
245 Ret
= (ULONG_PTR
)Class
->Style
;
249 Ret
= (ULONG_PTR
)Class
->Atom
;
253 /* FIXME - get handle from pointer to CURSOR object */
254 Ret
= (ULONG_PTR
)Class
->hCursor
;
258 /* FIXME - get handle from pointer to ICON object */
259 Ret
= (ULONG_PTR
)Class
->hIcon
;
263 /* FIXME - get handle from pointer to ICON object */
264 Ret
= (ULONG_PTR
)Class
->hIconSm
;
268 /* We need to make a call to win32k as it may be required to
269 create a callproc handle */
274 SetLastError(ERROR_INVALID_INDEX
);
281 /* This is a race condition! Call win32k to make sure we're getting
282 the correct result */
283 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
285 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
288 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
290 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
295 Ret
= NtUserGetClassLong(hWnd
, nIndex
, TRUE
);
304 GetClassLongW ( HWND hWnd
, int nIndex
)
310 TRACE("%p %d\n", hWnd
, nIndex
);
312 Wnd
= ValidateHwnd(hWnd
);
318 Class
= DesktopPtrToUser(Wnd
->Class
);
323 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
324 nIndex
+ sizeof(ULONG_PTR
) > Class
->ClsExtra
)
326 SetLastError(ERROR_INVALID_PARAMETER
);
329 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
336 Ret
= (ULONG_PTR
)Class
->WndExtra
;
340 Ret
= (ULONG_PTR
)Class
->ClsExtra
;
343 case GCL_HBRBACKGROUND
:
344 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
345 if (Ret
!= 0 && Ret
< 0x4000)
346 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
350 Ret
= (ULONG_PTR
)Class
->hInstance
;
354 Ret
= (ULONG_PTR
)Class
->MenuName
;
358 Ret
= (ULONG_PTR
)Class
->Style
;
362 Ret
= (ULONG_PTR
)Class
->Atom
;
366 /* FIXME - get handle from pointer to CURSOR object */
367 Ret
= (ULONG_PTR
)Class
->hCursor
;
371 /* FIXME - get handle from pointer to ICON object */
372 Ret
= (ULONG_PTR
)Class
->hIcon
;
376 /* FIXME - get handle from pointer to ICON object */
377 Ret
= (ULONG_PTR
)Class
->hIconSm
;
381 /* We need to make a call to win32k as it may be required to
382 create a callproc handle */
387 SetLastError(ERROR_INVALID_INDEX
);
394 /* This is a race condition! Call win32k to make sure we're getting
395 the correct result */
396 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
398 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
401 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
403 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
408 Ret
= NtUserGetClassLong(hWnd
, nIndex
, FALSE
);
419 GetClassLongPtrA(HWND hWnd
,
431 GetClassLongPtrW(HWND hWnd
,
449 ANSI_STRING ClassName
;
452 ClassName
.MaximumLength
= nMaxCount
;
453 ClassName
.Buffer
= lpClassName
;
455 Result
= NtUserGetClassName(hWnd
,
456 (PUNICODE_STRING
)&ClassName
,
459 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
460 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
461 IS_ATOM(lpClassName
) ? lpClassName
: 0,
478 UNICODE_STRING ClassName
;
481 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
482 ClassName
.Buffer
= lpClassName
;
484 Result
= NtUserGetClassName(hWnd
,
488 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
489 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
490 IS_ATOM(lpClassName
) ? lpClassName
: 0,
506 * NOTE: Obsoleted in 32-bit windows
509 TRACE("%p %x\n", hWnd
, nIndex
);
511 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
514 return (WORD
) NtUserGetClassLong ( hWnd
, nIndex
, TRUE
);
523 GetWindowLongA ( HWND hWnd
, int nIndex
)
527 Wnd
= ValidateHwnd(hWnd
);
533 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->ExtraDataSize
)
535 SetLastError(ERROR_INVALID_PARAMETER
);
539 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
550 return (LONG
)Wnd
->Instance
;
554 return Wnd
->UserData
;
558 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
559 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
563 /* Call win32k for this as a callproc handle may need
565 return NtUserGetWindowLong(hWnd
, nIndex
, TRUE
);
568 SetLastError(ERROR_INVALID_PARAMETER
);
580 GetWindowLongW(HWND hWnd
, int nIndex
)
584 Wnd
= ValidateHwnd(hWnd
);
590 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->ExtraDataSize
)
592 SetLastError(ERROR_INVALID_PARAMETER
);
596 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
607 return (LONG
)Wnd
->Instance
;
611 return Wnd
->UserData
;
615 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
616 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
620 /* Call win32k for this as a callproc handle may need
622 return NtUserGetWindowLong(hWnd
, nIndex
, FALSE
);
625 SetLastError(ERROR_INVALID_PARAMETER
);
637 GetWindowLongPtrA(HWND hWnd
,
649 GetWindowLongPtrW(HWND hWnd
,
662 GetWindowWord(HWND hWnd
, int nIndex
)
664 return (WORD
)GetWindowLongW(hWnd
, nIndex
);
672 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
674 return (WORD
)NtUserSetWindowLong ( hWnd
, nIndex
, (LONG
)wNewWord
, TRUE
);
687 /* FIXME: Implement correct functionality of RealGetWindowClass */
688 return GetClassNameW(hwnd
,pszType
,cchType
);
702 /* FIXME: Implement correct functionality of RealGetWindowClass */
703 return GetClassNameA(hwnd
,pszType
,cchType
);
707 * Create a small icon based on a standard icon
710 CreateSmallIcon(HICON StdIcon
)
712 HICON SmallIcon
= NULL
;
716 BITMAP StdBitmapInfo
;
718 HDC hSourceDc
= NULL
;
721 HBITMAP OldSourceBitmap
= NULL
;
722 HBITMAP OldDestBitmap
= NULL
;
724 SmallInfo
.hbmColor
= NULL
;
725 SmallInfo
.hbmMask
= NULL
;
727 /* We need something to work with... */
733 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
734 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
735 if (! GetIconInfo(StdIcon
, &StdInfo
))
737 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
740 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
742 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
743 StdIcon
, StdInfo
.hbmColor
);
746 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
747 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
749 /* Icon already has the correct dimensions */
753 /* Get a handle to a info DC and handles to DCs which can be used to
754 select a bitmap into. This is done to avoid triggering a switch to
755 graphics mode (if we're currently in text/blue screen mode) */
756 hInfoDc
= CreateICW(NULL
, NULL
, NULL
, NULL
);
759 ERR("Failed to create info DC\n");
762 hSourceDc
= CreateCompatibleDC(NULL
);
763 if (NULL
== hSourceDc
)
765 ERR("Failed to create source DC\n");
768 hDestDc
= CreateCompatibleDC(NULL
);
771 ERR("Failed to create dest DC\n");
775 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
776 if (NULL
== OldSourceBitmap
)
778 ERR("Failed to select source color bitmap\n");
781 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hInfoDc
, SmallIconWidth
,
783 if (NULL
== SmallInfo
.hbmColor
)
785 ERR("Failed to create color bitmap\n");
788 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
789 if (NULL
== OldDestBitmap
)
791 ERR("Failed to select dest color bitmap\n");
794 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
795 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
796 StdBitmapInfo
.bmHeight
, SRCCOPY
))
798 ERR("Failed to stretch color bitmap\n");
802 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
804 ERR("Failed to select source mask bitmap\n");
807 SmallInfo
.hbmMask
= CreateBitmap(SmallIconWidth
, SmallIconHeight
, 1, 1,
809 if (NULL
== SmallInfo
.hbmMask
)
811 ERR("Failed to create mask bitmap\n");
814 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
816 ERR("Failed to select dest mask bitmap\n");
819 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
820 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
821 StdBitmapInfo
.bmHeight
, SRCCOPY
))
823 ERR("Failed to stretch mask bitmap\n");
827 SmallInfo
.fIcon
= TRUE
;
828 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
829 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
830 SmallIcon
= CreateIconIndirect(&SmallInfo
);
831 if (NULL
== SmallIcon
)
833 ERR("Failed to create icon\n");
838 if (NULL
!= SmallInfo
.hbmMask
)
840 DeleteObject(SmallInfo
.hbmMask
);
842 if (NULL
!= OldDestBitmap
)
844 SelectObject(hDestDc
, OldDestBitmap
);
846 if (NULL
!= SmallInfo
.hbmColor
)
848 DeleteObject(SmallInfo
.hbmColor
);
854 if (NULL
!= OldSourceBitmap
)
856 SelectObject(hSourceDc
, OldSourceBitmap
);
858 if (NULL
!= hSourceDc
)
872 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
885 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
888 WNDCLASSEXA WndClass
;
889 UNICODE_STRING ClassName
;
890 UNICODE_STRING MenuName
= {0};
893 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXA
) ||
894 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
895 lpwcx
->lpszClassName
== NULL
)
897 SetLastError(ERROR_INVALID_PARAMETER
);
902 * On real Windows this looks more like:
903 * if (lpwcx->hInstance == User32Instance &&
904 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
905 * But since I have no idea what the magic field in the
906 * TEB structure means, I rather decided to omit that.
909 if (lpwcx
->hInstance
== User32Instance
)
911 SetLastError(ERROR_INVALID_PARAMETER
);
915 /* Yes, this is correct. We should modify the passed structure. */
916 if (lpwcx
->hInstance
== NULL
)
917 ((WNDCLASSEXA
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
919 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
921 if (NULL
== WndClass
.hIconSm
)
923 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
926 if (WndClass
.lpszMenuName
!= NULL
)
928 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
930 if (WndClass
.lpszMenuName
[0])
932 RtlCreateUnicodeStringFromAsciiz(&MenuName
, WndClass
.lpszMenuName
);
937 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
940 if (MenuName
.Buffer
!= NULL
)
941 hMenu
= LoadMenuA(WndClass
.hInstance
, WndClass
.lpszMenuName
);
944 if (IS_ATOM(WndClass
.lpszClassName
))
947 ClassName
.MaximumLength
= 0;
948 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
952 RtlCreateUnicodeStringFromAsciiz(&ClassName
, WndClass
.lpszClassName
);
955 Atom
= NtUserRegisterClassEx((WNDCLASSEXW
*)&WndClass
,
962 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
963 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
964 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
966 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
967 RtlFreeUnicodeString(&MenuName
);
968 if (!IS_ATOM(WndClass
.lpszClassName
))
969 RtlFreeUnicodeString(&ClassName
);
978 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
981 WNDCLASSEXW WndClass
;
982 UNICODE_STRING ClassName
;
983 UNICODE_STRING MenuName
= {0};
986 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
987 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
988 lpwcx
->lpszClassName
== NULL
)
990 SetLastError(ERROR_INVALID_PARAMETER
);
995 * On real Windows this looks more like:
996 * if (lpwcx->hInstance == User32Instance &&
997 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
998 * But since I have no idea what the magic field in the
999 * TEB structure means, I rather decided to omit that.
1002 if (lpwcx
->hInstance
== User32Instance
)
1004 SetLastError(ERROR_INVALID_PARAMETER
);
1008 /* Yes, this is correct. We should modify the passed structure. */
1009 if (lpwcx
->hInstance
== NULL
)
1010 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1012 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1014 if (NULL
== WndClass
.hIconSm
)
1016 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1019 if (WndClass
.lpszMenuName
!= NULL
)
1021 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1023 if (WndClass
.lpszMenuName
[0])
1025 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1030 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1033 if (MenuName
.Buffer
!= NULL
)
1034 hMenu
= LoadMenuW(WndClass
.hInstance
, WndClass
.lpszMenuName
);
1037 if (IS_ATOM(WndClass
.lpszClassName
))
1040 ClassName
.MaximumLength
= 0;
1041 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1045 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1048 Atom
= (ATOM
)NtUserRegisterClassEx(&WndClass
,
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 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1070 if (lpWndClass
== NULL
)
1073 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1074 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1075 Class
.hIconSm
= NULL
;
1077 return RegisterClassExA(&Class
);
1084 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1088 if (lpWndClass
== NULL
)
1091 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1092 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1093 Class
.hIconSm
= NULL
;
1095 return RegisterClassExW(&Class
);
1103 SetClassLongA (HWND hWnd
,
1107 PSTR lpStr
= (PSTR
)dwNewLong
;
1108 UNICODE_STRING Value
= {0};
1109 BOOL Allocated
= FALSE
;
1112 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1114 /* FIXME - portability!!!! */
1116 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1118 if (!IS_INTRESOURCE(lpStr
))
1120 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1123 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1130 Value
.Buffer
= (PWSTR
)lpStr
;
1132 dwNewLong
= (LONG
)&Value
;
1134 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1136 if (!IS_ATOM(lpStr
))
1138 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1141 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1148 Value
.Buffer
= (PWSTR
)lpStr
;
1150 dwNewLong
= (LONG
)&Value
;
1153 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1160 RtlFreeUnicodeString(&Value
);
1172 SetClassLongW(HWND hWnd
,
1176 PWSTR lpStr
= (PWSTR
)dwNewLong
;
1177 UNICODE_STRING Value
= {0};
1179 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1181 /* FIXME - portability!!!! */
1183 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1185 if (!IS_INTRESOURCE(lpStr
))
1187 RtlInitUnicodeString(&Value
,
1191 Value
.Buffer
= lpStr
;
1193 dwNewLong
= (LONG
)&Value
;
1195 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1197 if (!IS_ATOM(lpStr
))
1199 RtlInitUnicodeString(&Value
,
1203 Value
.Buffer
= lpStr
;
1205 dwNewLong
= (LONG
)&Value
;
1208 return (DWORD
)NtUserSetClassLong(hWnd
,
1220 SetClassLongPtrA(HWND hWnd
,
1233 SetClassLongPtrW(HWND hWnd
,
1252 * NOTE: Obsoleted in 32-bit windows
1255 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1258 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1272 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1286 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1295 SetWindowLongPtrA(HWND hWnd
,
1308 SetWindowLongPtrW(HWND hWnd
,
1324 HINSTANCE hInstance
)
1326 UNICODE_STRING ClassName
= {0};
1329 TRACE("class/atom: %s/%04x %p\n",
1330 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1331 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1334 if (!IS_ATOM(lpClassName
))
1336 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1339 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1344 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1346 Ret
= NtUserUnregisterClass(&ClassName
,
1350 if (!IS_ATOM(lpClassName
))
1351 RtlFreeUnicodeString(&ClassName
);
1363 LPCWSTR lpClassName
,
1364 HINSTANCE hInstance
)
1366 UNICODE_STRING ClassName
= {0};
1368 TRACE("class/atom: %S/%04x %p\n",
1369 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1370 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1373 if (!IS_ATOM(lpClassName
))
1375 RtlInitUnicodeString(&ClassName
,
1379 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1381 return NtUserUnregisterClass(&ClassName
,