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
);
346 GetClassLongA(HWND hWnd
, int nIndex
)
352 TRACE("%p %d\n", hWnd
, nIndex
);
354 Wnd
= ValidateHwnd(hWnd
);
360 Class
= DesktopPtrToUser(Wnd
->pcls
);
365 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
366 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
368 SetLastError(ERROR_INVALID_PARAMETER
);
371 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
378 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
382 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
385 case GCL_HBRBACKGROUND
:
386 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
387 if (Ret
!= 0 && Ret
< 0x4000)
388 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
392 //ERR("Cls 0x%x GCL_HMODULE 0x%x\n", Wnd->pcls, Class->hModule);
393 Ret
= (ULONG_PTR
)Class
->hModule
;
397 Ret
= (ULONG_PTR
)Class
->lpszClientAnsiMenuName
;
401 Ret
= (ULONG_PTR
)Class
->style
;
405 Ret
= (ULONG_PTR
)Class
->atomClassName
;
409 /* FIXME - get handle from pointer to CURSOR object */
410 Ret
= (ULONG_PTR
)Class
->hCursor
;
414 /* FIXME - get handle from pointer to ICON object */
415 Ret
= (ULONG_PTR
)Class
->hIcon
;
419 /* FIXME - get handle from pointer to ICON object */
420 Ret
= (ULONG_PTR
)Class
->hIconSm
;
424 Ret
= IntGetClsWndProc(Wnd
, Class
, TRUE
);
428 SetLastError(ERROR_INVALID_INDEX
);
435 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
438 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
451 GetClassLongW ( HWND hWnd
, int nIndex
)
457 TRACE("%p %d\n", hWnd
, nIndex
);
459 Wnd
= ValidateHwnd(hWnd
);
465 Class
= DesktopPtrToUser(Wnd
->pcls
);
470 if (nIndex
+ sizeof(ULONG_PTR
) < nIndex
||
471 nIndex
+ sizeof(ULONG_PTR
) > Class
->cbclsExtra
)
473 SetLastError(ERROR_INVALID_PARAMETER
);
476 Ret
= *(PULONG_PTR
)((ULONG_PTR
)(Class
+ 1) + nIndex
);
483 Ret
= (ULONG_PTR
)Class
->cbwndExtra
;
487 Ret
= (ULONG_PTR
)Class
->cbclsExtra
;
490 case GCL_HBRBACKGROUND
:
491 Ret
= (ULONG_PTR
)Class
->hbrBackground
;
492 if (Ret
!= 0 && Ret
< 0x4000)
493 Ret
= (ULONG_PTR
)GetSysColorBrush((ULONG
)Ret
- 1);
497 Ret
= (ULONG_PTR
)Class
->hModule
;
501 Ret
= (ULONG_PTR
)Class
->lpszClientUnicodeMenuName
;
505 Ret
= (ULONG_PTR
)Class
->style
;
509 Ret
= (ULONG_PTR
)Class
->atomClassName
;
513 /* FIXME - get handle from pointer to CURSOR object */
514 Ret
= (ULONG_PTR
)Class
->hCursor
;
518 /* FIXME - get handle from pointer to ICON object */
519 Ret
= (ULONG_PTR
)Class
->hIcon
;
523 /* FIXME - get handle from pointer to ICON object */
524 Ret
= (ULONG_PTR
)Class
->hIconSm
;
528 Ret
= IntGetClsWndProc(Wnd
, Class
, FALSE
);
532 SetLastError(ERROR_INVALID_INDEX
);
539 WARN("Invalid class for hwnd 0x%p!\n", hWnd
);
542 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
556 GetClassLongPtrA(HWND hWnd
,
568 GetClassLongPtrW(HWND hWnd
,
586 ANSI_STRING ClassName
;
589 ClassName
.MaximumLength
= nMaxCount
;
590 ClassName
.Buffer
= lpClassName
;
592 Result
= NtUserGetClassName(hWnd
,
593 (PUNICODE_STRING
)&ClassName
,
596 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
597 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
598 IS_ATOM(lpClassName
) ? lpClassName
: 0,
615 UNICODE_STRING ClassName
;
618 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
619 ClassName
.Buffer
= lpClassName
;
621 Result
= NtUserGetClassName(hWnd
,
625 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
626 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
627 IS_ATOM(lpClassName
) ? lpClassName
: 0,
647 if (offset
< 0) return GetClassLongA( hwnd
, offset
);
649 Wnd
= ValidateHwnd(hwnd
);
653 class = DesktopPtrToUser(Wnd
->pcls
);
654 if (class == NULL
) return 0;
656 if (offset
<= class->cbclsExtra
- sizeof(WORD
))
657 memcpy( &retvalue
, (char *)(class + 1) + offset
, sizeof(retvalue
) );
659 SetLastError( ERROR_INVALID_INDEX
);
665 LONG_PTR
IntGetWindowLong( HWND hwnd
, INT offset
, UINT size
, BOOL unicode
)
667 LONG_PTR retvalue
= 0;
670 if (offset
== GWLP_HWNDPARENT
)
672 HWND parent
= GetAncestor( hwnd
, GA_PARENT
);
673 if (parent
== GetDesktopWindow()) parent
= GetWindow( hwnd
, GW_OWNER
);
674 return (ULONG_PTR
)parent
;
677 if (!(wndPtr
= ValidateHwnd( hwnd
)))
679 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
685 if (offset
> (int)(wndPtr
->cbwndExtra
- size
))
687 WARN("Invalid offset %d\n", offset
);
688 SetLastError( ERROR_INVALID_INDEX
);
691 retvalue
= *((LONG_PTR
*)((PCHAR
)(wndPtr
+ 1) + offset
));
693 /* WINE: special case for dialog window procedure */
694 //if ((offset == DWLP_DLGPROC) && (size == sizeof(LONG_PTR)) && (wndPtr->flags & WIN_ISDIALOG))
695 // retvalue = (LONG_PTR)IntGetWndProc( (WNDPROC)retvalue, unicode );
701 case GWLP_USERDATA
: retvalue
= wndPtr
->dwUserData
; break;
702 case GWL_STYLE
: retvalue
= wndPtr
->style
; break;
703 case GWL_EXSTYLE
: retvalue
= wndPtr
->ExStyle
; break;
704 case GWLP_ID
: retvalue
= wndPtr
->IDMenu
; break;
705 case GWLP_HINSTANCE
: retvalue
= (ULONG_PTR
)wndPtr
->hModule
; break;
708 if (!TestWindowProcess(wndPtr
))
710 SetLastError(ERROR_ACCESS_DENIED
);
713 retvalue
= (ULONG_PTR
)IntGetWndProc(wndPtr
, !unicode
);
717 WARN("Unknown offset %d\n", offset
);
718 SetLastError( ERROR_INVALID_INDEX
);
729 GetWindowLongA ( HWND hWnd
, int nIndex
)
731 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), FALSE
);
739 GetWindowLongW(HWND hWnd
, int nIndex
)
741 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), TRUE
);
750 GetWindowLongPtrA(HWND hWnd
,
753 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), FALSE
);
761 GetWindowLongPtrW(HWND hWnd
,
764 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), TRUE
);
774 GetWindowWord(HWND hWnd
, int nIndex
)
780 case GWLP_HWNDPARENT
:
785 WARN("Invalid offset %d\n", nIndex
);
786 SetLastError( ERROR_INVALID_INDEX
);
791 return IntGetWindowLong( hWnd
, nIndex
, sizeof(WORD
), FALSE
);
804 /* FIXME: Implement correct functionality of RealGetWindowClass */
805 return GetClassNameW(hwnd
,pszType
,cchType
);
819 /* FIXME: Implement correct functionality of RealGetWindowClass */
820 return GetClassNameA(hwnd
,pszType
,cchType
);
824 * Create a small icon based on a standard icon
827 CreateSmallIcon(HICON StdIcon
)
829 HICON SmallIcon
= NULL
;
833 BITMAP StdBitmapInfo
;
834 HDC hSourceDc
= NULL
;
837 HBITMAP OldSourceBitmap
= NULL
;
838 HBITMAP OldDestBitmap
= NULL
;
840 SmallInfo
.hbmColor
= NULL
;
841 SmallInfo
.hbmMask
= NULL
;
843 /* We need something to work with... */
849 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
850 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
851 if (! GetIconInfo(StdIcon
, &StdInfo
))
853 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
856 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
858 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
859 StdIcon
, StdInfo
.hbmColor
);
862 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
863 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
865 /* Icon already has the correct dimensions */
869 hSourceDc
= CreateCompatibleDC(NULL
);
870 if (NULL
== hSourceDc
)
872 ERR("Failed to create source DC\n");
875 hDestDc
= CreateCompatibleDC(NULL
);
878 ERR("Failed to create dest DC\n");
882 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
883 if (NULL
== OldSourceBitmap
)
885 ERR("Failed to select source color bitmap\n");
888 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hSourceDc
, SmallIconWidth
,
890 if (NULL
== SmallInfo
.hbmColor
)
892 ERR("Failed to create color bitmap\n");
895 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
896 if (NULL
== OldDestBitmap
)
898 ERR("Failed to select dest color bitmap\n");
901 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
902 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
903 StdBitmapInfo
.bmHeight
, SRCCOPY
))
905 ERR("Failed to stretch color bitmap\n");
909 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
911 ERR("Failed to select source mask bitmap\n");
914 SmallInfo
.hbmMask
= CreateCompatibleBitmap(hSourceDc
, SmallIconWidth
, SmallIconHeight
);
915 if (NULL
== SmallInfo
.hbmMask
)
917 ERR("Failed to create mask bitmap\n");
920 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
922 ERR("Failed to select dest mask bitmap\n");
925 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
926 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
927 StdBitmapInfo
.bmHeight
, SRCCOPY
))
929 ERR("Failed to stretch mask bitmap\n");
933 SmallInfo
.fIcon
= TRUE
;
934 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
935 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
936 SmallIcon
= CreateIconIndirect(&SmallInfo
);
937 if (NULL
== SmallIcon
)
939 ERR("Failed to create icon\n");
944 if (NULL
!= SmallInfo
.hbmMask
)
946 DeleteObject(SmallInfo
.hbmMask
);
948 if (NULL
!= OldDestBitmap
)
950 SelectObject(hDestDc
, OldDestBitmap
);
952 if (NULL
!= SmallInfo
.hbmColor
)
954 DeleteObject(SmallInfo
.hbmColor
);
960 if (NULL
!= OldSourceBitmap
)
962 SelectObject(hSourceDc
, OldSourceBitmap
);
964 if (NULL
!= hSourceDc
)
974 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
981 WNDCLASSEXW WndClass
;
982 UNICODE_STRING ClassName
;
983 UNICODE_STRING MenuName
= {0};
984 CLSMENUNAME clsMenuName
;
985 ANSI_STRING AnsiMenuName
;
987 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
988 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
989 lpwcx
->lpszClassName
== NULL
)
991 TRACE("RegisterClassExWOWW Invalid Parameter Error!\n");
992 SetLastError(ERROR_INVALID_PARAMETER
);
998 if (!RegisterDefaultClasses
) RegisterSystemControls();
1001 * On real Windows this looks more like:
1002 * if (lpwcx->hInstance == User32Instance &&
1003 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
1004 * But since I have no idea what the magic field in the
1005 * TEB structure means, I rather decided to omit that.
1008 GetWin32ClientInfo()->dwExpWinVer & (WINVER == 0x400)
1010 if (lpwcx
->hInstance
== User32Instance
)
1012 TRACE("RegisterClassExWOWW User32Instance!\n");
1013 SetLastError(ERROR_INVALID_PARAMETER
);
1016 /* Yes, this is correct. We should modify the passed structure. */
1017 if (lpwcx
->hInstance
== NULL
)
1018 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1020 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1022 if (NULL
== WndClass
.hIconSm
)
1024 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1027 if (WndClass
.lpszMenuName
!= NULL
)
1029 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1031 if (WndClass
.lpszMenuName
[0])
1033 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1034 RtlUnicodeStringToAnsiString( &AnsiMenuName
, &MenuName
, TRUE
);
1039 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1040 AnsiMenuName
.Buffer
= (PCHAR
)WndClass
.lpszMenuName
;
1044 if (IS_ATOM(WndClass
.lpszClassName
))
1047 ClassName
.MaximumLength
= 0;
1048 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1052 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1055 clsMenuName
.pszClientAnsiMenuName
= AnsiMenuName
.Buffer
;
1056 clsMenuName
.pwszClientUnicodeMenuName
= MenuName
.Buffer
;
1057 clsMenuName
.pusMenuName
= &MenuName
;
1059 Atom
= NtUserRegisterClassExWOW( &WndClass
,
1061 NULL
, //PUNICODE_STRING ClsNVersion,
1067 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1068 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1069 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1078 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
1081 WNDCLASSEXW WndClass
;
1082 WCHAR mname
[MAX_BUFFER_LEN
];
1083 WCHAR cname
[MAX_BUFFER_LEN
];
1085 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
1087 if (WndClass
.lpszMenuName
!= NULL
)
1089 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1091 if (WndClass
.lpszMenuName
[0])
1093 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszMenuName
, -1, mname
, MAX_ATOM_LEN
+ 1 )) return 0;
1095 WndClass
.lpszMenuName
= mname
;
1100 if (!IS_ATOM(WndClass
.lpszClassName
))
1102 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszClassName
, -1, cname
, MAX_ATOM_LEN
+ 1 )) return 0;
1104 WndClass
.lpszClassName
= cname
;
1107 Atom
= RegisterClassExWOWW( &WndClass
,
1113 TRACE("A atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1114 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1115 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1124 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
1128 Atom
= RegisterClassExWOWW( (WNDCLASSEXW
*)lpwcx
, 0, 0, 0, TRUE
);
1130 TRACE("W atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d\n",
1131 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1132 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
);
1141 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1145 if (lpWndClass
== NULL
)
1148 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1149 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1150 Class
.hIconSm
= NULL
;
1152 return RegisterClassExA(&Class
);
1159 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1163 if (lpWndClass
== NULL
)
1166 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1167 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1168 Class
.hIconSm
= NULL
;
1170 return RegisterClassExW(&Class
);
1178 SetClassLongA (HWND hWnd
,
1182 PSTR lpStr
= (PSTR
)(ULONG_PTR
)dwNewLong
;
1183 UNICODE_STRING Value
= {0};
1184 BOOL Allocated
= FALSE
;
1187 /* FIXME - portability!!!! */
1189 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1191 if (!IS_INTRESOURCE(lpStr
))
1193 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1196 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1203 Value
.Buffer
= (PWSTR
)lpStr
;
1205 dwNewLong
= (LONG_PTR
)&Value
;
1207 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1209 if (!IS_ATOM(lpStr
))
1211 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1214 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1221 Value
.Buffer
= (PWSTR
)lpStr
;
1223 dwNewLong
= (LONG_PTR
)&Value
;
1226 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1233 RtlFreeUnicodeString(&Value
);
1245 SetClassLongW(HWND hWnd
,
1249 PWSTR lpStr
= (PWSTR
)(ULONG_PTR
)dwNewLong
;
1250 UNICODE_STRING Value
= {0};
1252 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1254 /* FIXME - portability!!!! */
1256 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1258 if (!IS_INTRESOURCE(lpStr
))
1260 RtlInitUnicodeString(&Value
,
1264 Value
.Buffer
= lpStr
;
1266 dwNewLong
= (LONG_PTR
)&Value
;
1268 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1270 if (!IS_ATOM(lpStr
))
1272 RtlInitUnicodeString(&Value
,
1276 Value
.Buffer
= lpStr
;
1278 dwNewLong
= (LONG_PTR
)&Value
;
1281 return (DWORD
)NtUserSetClassLong(hWnd
,
1293 SetClassLongPtrA(HWND hWnd
,
1306 SetClassLongPtrW(HWND hWnd
,
1325 * NOTE: Obsoleted in 32-bit windows
1328 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1331 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1339 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
1344 case GWLP_HINSTANCE
:
1345 case GWLP_HWNDPARENT
:
1350 WARN("Invalid offset %d\n", nIndex
);
1351 SetLastError( ERROR_INVALID_INDEX
);
1356 return NtUserSetWindowLong( hWnd
, nIndex
, wNewWord
, FALSE
);
1369 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1382 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1391 SetWindowLongPtrA(HWND hWnd
,
1395 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1403 SetWindowLongPtrW(HWND hWnd
,
1407 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1418 HINSTANCE hInstance
)
1420 UNICODE_STRING ClassName
= {0};
1423 TRACE("class/atom: %s/%04x %p\n",
1424 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1425 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1428 if (!IS_ATOM(lpClassName
))
1430 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1433 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1438 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1440 Ret
= NtUserUnregisterClass(&ClassName
,
1444 if (!IS_ATOM(lpClassName
))
1445 RtlFreeUnicodeString(&ClassName
);
1457 LPCWSTR lpClassName
,
1458 HINSTANCE hInstance
)
1460 UNICODE_STRING ClassName
= {0};
1462 TRACE("class/atom: %S/%04x %p\n",
1463 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1464 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1467 if (!IS_ATOM(lpClassName
))
1469 RtlInitUnicodeString(&ClassName
,
1473 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1475 return NtUserUnregisterClass(&ClassName
,