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 /* This is a race condition! Call win32k to make sure we're getting
427 the correct result */
428 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
430 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
433 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
435 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
440 Ret
= NtUserGetClassLong(hWnd
, nIndex
, TRUE
);
449 GetClassLongW ( HWND hWnd
, int nIndex
)
455 TRACE("%p %d\n", hWnd
, nIndex
);
457 Wnd
= ValidateHwnd(hWnd
);
463 Class
= DesktopPtrToUser(Wnd
->pcls
);
468 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
469 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
471 SetLastError(ERROR_INVALID_PARAMETER
);
474 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
481 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
485 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
488 case GCL_HBRBACKGROUND
:
489 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
490 if (Ret
!= 0 && Ret
< 0x4000)
491 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
495 Ret
= (ULONG_PTR
)Class
->hModule
;
499 Ret
= (ULONG_PTR
)Class
->lpszClientUnicodeMenuName
;
503 Ret
= (ULONG_PTR
)Class
->style
;
507 Ret
= (ULONG_PTR
)Class
->atomClassName
;
511 /* FIXME - get handle from pointer to CURSOR object */
512 Ret
= (ULONG_PTR
)Class
->hCursor
;
516 /* FIXME - get handle from pointer to ICON object */
517 Ret
= (ULONG_PTR
)Class
->hIcon
;
521 /* FIXME - get handle from pointer to ICON object */
522 Ret
= (ULONG_PTR
)Class
->hIconSm
;
526 Ret
= IntGetClsWndProc(Wnd
, Class
, FALSE
);
530 SetLastError(ERROR_INVALID_INDEX
);
537 /* This is a race condition! Call win32k to make sure we're getting
538 the correct result */
539 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
541 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
544 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
546 Wnd
= NULL
; /* Make sure we call NtUserGetClassLong */
551 Ret
= NtUserGetClassLong(hWnd
, nIndex
, FALSE
);
562 GetClassLongPtrA(HWND hWnd
,
574 GetClassLongPtrW(HWND hWnd
,
592 ANSI_STRING ClassName
;
595 ClassName
.MaximumLength
= nMaxCount
;
596 ClassName
.Buffer
= lpClassName
;
598 Result
= NtUserGetClassName(hWnd
,
599 (PUNICODE_STRING
)&ClassName
,
602 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
603 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
604 IS_ATOM(lpClassName
) ? lpClassName
: 0,
621 UNICODE_STRING ClassName
;
624 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
625 ClassName
.Buffer
= lpClassName
;
627 Result
= NtUserGetClassName(hWnd
,
631 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
632 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
633 IS_ATOM(lpClassName
) ? lpClassName
: 0,
649 * NOTE: Obsoleted in 32-bit windows
652 TRACE("%p %x\n", hWnd
, nIndex
);
654 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
657 return (WORD
) NtUserGetClassLong ( hWnd
, nIndex
, TRUE
);
666 GetWindowLongA ( HWND hWnd
, int nIndex
)
670 Wnd
= ValidateHwnd(hWnd
);
676 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->cbwndExtra
)
678 SetLastError(ERROR_INVALID_PARAMETER
);
681 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
692 return (LONG
)Wnd
->hModule
;
696 return Wnd
->dwUserData
;
700 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
701 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
705 if (!TestWindowProcess(Wnd
))
707 SetLastError(ERROR_ACCESS_DENIED
);
710 return IntGetWndProc(Wnd
, TRUE
);
713 SetLastError(ERROR_INVALID_PARAMETER
);
725 GetWindowLongW(HWND hWnd
, int nIndex
)
729 Wnd
= ValidateHwnd(hWnd
);
735 if ((DWORD
)nIndex
+ sizeof(LONG
) > Wnd
->cbwndExtra
)
737 SetLastError(ERROR_INVALID_PARAMETER
);
740 return *((LONG
*)((PCHAR
)(Wnd
+ 1) + nIndex
));
751 return (LONG
)Wnd
->hModule
;
755 return Wnd
->dwUserData
;
759 HWND parent
= GetAncestor( hWnd
, GA_PARENT
);
760 if (parent
== GetDesktopWindow()) parent
= GetWindow( hWnd
, GW_OWNER
);
764 if (!TestWindowProcess(Wnd
))
766 SetLastError(ERROR_ACCESS_DENIED
);
769 return IntGetWndProc(Wnd
, FALSE
);
772 SetLastError(ERROR_INVALID_PARAMETER
);
784 GetWindowLongPtrA(HWND hWnd
,
796 GetWindowLongPtrW(HWND hWnd
,
809 GetWindowWord(HWND hWnd
, int nIndex
)
811 return (WORD
)GetWindowLongW(hWnd
, nIndex
);
819 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
821 return (WORD
)NtUserSetWindowLong ( hWnd
, nIndex
, (LONG
)wNewWord
, TRUE
);
834 /* FIXME: Implement correct functionality of RealGetWindowClass */
835 return GetClassNameW(hwnd
,pszType
,cchType
);
849 /* FIXME: Implement correct functionality of RealGetWindowClass */
850 return GetClassNameA(hwnd
,pszType
,cchType
);
854 * Create a small icon based on a standard icon
857 CreateSmallIcon(HICON StdIcon
)
859 HICON SmallIcon
= NULL
;
863 BITMAP StdBitmapInfo
;
865 HDC hSourceDc
= NULL
;
868 HBITMAP OldSourceBitmap
= NULL
;
869 HBITMAP OldDestBitmap
= NULL
;
871 SmallInfo
.hbmColor
= NULL
;
872 SmallInfo
.hbmMask
= NULL
;
874 /* We need something to work with... */
880 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
881 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
882 if (! GetIconInfo(StdIcon
, &StdInfo
))
884 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
887 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
889 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
890 StdIcon
, StdInfo
.hbmColor
);
893 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
894 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
896 /* Icon already has the correct dimensions */
900 /* Get a handle to a info DC and handles to DCs which can be used to
901 select a bitmap into. This is done to avoid triggering a switch to
902 graphics mode (if we're currently in text/blue screen mode) */
903 hInfoDc
= CreateICW(NULL
, NULL
, NULL
, NULL
);
906 ERR("Failed to create info DC\n");
909 hSourceDc
= CreateCompatibleDC(NULL
);
910 if (NULL
== hSourceDc
)
912 ERR("Failed to create source DC\n");
915 hDestDc
= CreateCompatibleDC(NULL
);
918 ERR("Failed to create dest DC\n");
922 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
923 if (NULL
== OldSourceBitmap
)
925 ERR("Failed to select source color bitmap\n");
928 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hInfoDc
, SmallIconWidth
,
930 if (NULL
== SmallInfo
.hbmColor
)
932 ERR("Failed to create color bitmap\n");
935 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
936 if (NULL
== OldDestBitmap
)
938 ERR("Failed to select dest color bitmap\n");
941 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
942 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
943 StdBitmapInfo
.bmHeight
, SRCCOPY
))
945 ERR("Failed to stretch color bitmap\n");
949 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
951 ERR("Failed to select source mask bitmap\n");
954 SmallInfo
.hbmMask
= CreateBitmap(SmallIconWidth
, SmallIconHeight
, 1, 1,
956 if (NULL
== SmallInfo
.hbmMask
)
958 ERR("Failed to create mask bitmap\n");
961 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
963 ERR("Failed to select dest mask bitmap\n");
966 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
967 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
968 StdBitmapInfo
.bmHeight
, SRCCOPY
))
970 ERR("Failed to stretch mask bitmap\n");
974 SmallInfo
.fIcon
= TRUE
;
975 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
976 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
977 SmallIcon
= CreateIconIndirect(&SmallInfo
);
978 if (NULL
== SmallIcon
)
980 ERR("Failed to create icon\n");
985 if (NULL
!= SmallInfo
.hbmMask
)
987 DeleteObject(SmallInfo
.hbmMask
);
989 if (NULL
!= OldDestBitmap
)
991 SelectObject(hDestDc
, OldDestBitmap
);
993 if (NULL
!= SmallInfo
.hbmColor
)
995 DeleteObject(SmallInfo
.hbmColor
);
1001 if (NULL
!= OldSourceBitmap
)
1003 SelectObject(hSourceDc
, OldSourceBitmap
);
1005 if (NULL
!= hSourceDc
)
1007 DeleteDC(hSourceDc
);
1009 if (NULL
!= hInfoDc
)
1019 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
1026 WNDCLASSEXW WndClass
;
1027 UNICODE_STRING ClassName
;
1028 UNICODE_STRING MenuName
= {0};
1029 CLSMENUNAME clsMenuName
;
1030 ANSI_STRING AnsiMenuName
;
1032 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
1033 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
1034 lpwcx
->lpszClassName
== NULL
)
1036 ERR("RegisterClassExWOWW Invalid Parameter Error!\n");
1037 SetLastError(ERROR_INVALID_PARAMETER
);
1043 if (!RegisterDefaultClasses
) RegisterSystemControls();
1046 * On real Windows this looks more like:
1047 * if (lpwcx->hInstance == User32Instance &&
1048 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
1049 * But since I have no idea what the magic field in the
1050 * TEB structure means, I rather decided to omit that.
1053 GetWin32ClientInfo()->dwExpWinVer & (WINVER == 0x400)
1055 if (lpwcx
->hInstance
== User32Instance
)
1057 ERR("RegisterClassExWOWW User32Instance!\n");
1058 SetLastError(ERROR_INVALID_PARAMETER
);
1061 /* Yes, this is correct. We should modify the passed structure. */
1062 if (lpwcx
->hInstance
== NULL
)
1063 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1065 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1067 if (NULL
== WndClass
.hIconSm
)
1069 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1072 if (WndClass
.lpszMenuName
!= NULL
)
1074 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1076 if (WndClass
.lpszMenuName
[0])
1078 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1079 RtlUnicodeStringToAnsiString( &AnsiMenuName
, &MenuName
, TRUE
);
1084 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1085 AnsiMenuName
.Buffer
= (PCHAR
)WndClass
.lpszMenuName
;
1089 if (IS_ATOM(WndClass
.lpszClassName
))
1092 ClassName
.MaximumLength
= 0;
1093 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1097 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1100 clsMenuName
.pszClientAnsiMenuName
= AnsiMenuName
.Buffer
;
1101 clsMenuName
.pwszClientUnicodeMenuName
= MenuName
.Buffer
;
1102 clsMenuName
.pusMenuName
= &MenuName
;
1104 Atom
= NtUserRegisterClassExWOW( &WndClass
,
1106 NULL
, //PUNICODE_STRING ClsNVersion,
1112 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1113 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1114 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1123 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
1126 WNDCLASSEXW WndClass
;
1127 WCHAR mname
[MAX_BUFFER_LEN
];
1128 WCHAR cname
[MAX_BUFFER_LEN
];
1130 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
1132 if (WndClass
.lpszMenuName
!= NULL
)
1134 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1136 if (WndClass
.lpszMenuName
[0])
1138 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszMenuName
, -1, mname
, MAX_ATOM_LEN
+ 1 )) return 0;
1140 WndClass
.lpszMenuName
= mname
;
1145 if (!IS_ATOM(WndClass
.lpszClassName
))
1147 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszClassName
, -1, cname
, MAX_ATOM_LEN
+ 1 )) return 0;
1149 WndClass
.lpszClassName
= cname
;
1152 Atom
= RegisterClassExWOWW( &WndClass
,
1158 TRACE("A atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1159 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1160 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1169 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
1173 Atom
= RegisterClassExWOWW( (WNDCLASSEXW
*)lpwcx
, 0, 0, 0, TRUE
);
1175 TRACE("W atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d\n",
1176 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1177 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
);
1186 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1190 if (lpWndClass
== NULL
)
1193 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1194 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1195 Class
.hIconSm
= NULL
;
1197 return RegisterClassExA(&Class
);
1204 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1208 if (lpWndClass
== NULL
)
1211 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1212 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1213 Class
.hIconSm
= NULL
;
1215 return RegisterClassExW(&Class
);
1223 SetClassLongA (HWND hWnd
,
1227 PSTR lpStr
= (PSTR
)dwNewLong
;
1228 UNICODE_STRING Value
= {0};
1229 BOOL Allocated
= FALSE
;
1232 /* FIXME - portability!!!! */
1234 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1236 if (!IS_INTRESOURCE(lpStr
))
1238 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1241 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1248 Value
.Buffer
= (PWSTR
)lpStr
;
1250 dwNewLong
= (LONG
)&Value
;
1252 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1254 if (!IS_ATOM(lpStr
))
1256 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1259 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1266 Value
.Buffer
= (PWSTR
)lpStr
;
1268 dwNewLong
= (LONG
)&Value
;
1271 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1278 RtlFreeUnicodeString(&Value
);
1290 SetClassLongW(HWND hWnd
,
1294 PWSTR lpStr
= (PWSTR
)dwNewLong
;
1295 UNICODE_STRING Value
= {0};
1297 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1299 /* FIXME - portability!!!! */
1301 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1303 if (!IS_INTRESOURCE(lpStr
))
1305 RtlInitUnicodeString(&Value
,
1309 Value
.Buffer
= lpStr
;
1311 dwNewLong
= (LONG
)&Value
;
1313 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1315 if (!IS_ATOM(lpStr
))
1317 RtlInitUnicodeString(&Value
,
1321 Value
.Buffer
= lpStr
;
1323 dwNewLong
= (LONG
)&Value
;
1326 return (DWORD
)NtUserSetClassLong(hWnd
,
1338 SetClassLongPtrA(HWND hWnd
,
1351 SetClassLongPtrW(HWND hWnd
,
1370 * NOTE: Obsoleted in 32-bit windows
1373 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1376 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1390 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1404 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1413 SetWindowLongPtrA(HWND hWnd
,
1426 SetWindowLongPtrW(HWND hWnd
,
1442 HINSTANCE hInstance
)
1444 UNICODE_STRING ClassName
= {0};
1447 TRACE("class/atom: %s/%04x %p\n",
1448 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1449 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1452 if (!IS_ATOM(lpClassName
))
1454 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1457 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1462 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1464 Ret
= NtUserUnregisterClass(&ClassName
,
1468 if (!IS_ATOM(lpClassName
))
1469 RtlFreeUnicodeString(&ClassName
);
1481 LPCWSTR lpClassName
,
1482 HINSTANCE hInstance
)
1484 UNICODE_STRING ClassName
= {0};
1486 TRACE("class/atom: %S/%04x %p\n",
1487 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1488 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1491 if (!IS_ATOM(lpClassName
))
1493 RtlInitUnicodeString(&ClassName
,
1497 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1499 return NtUserUnregisterClass(&ClassName
,