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 WNDPROC 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
= GETPFNCLIENTA(i
);
287 Ret
= 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
= pWnd
->lpfnWndProc
;
303 Ret
= pWnd
->lpfnWndProc
;
305 if (Class
->fnid
<= FNID_GHOST
&& Class
->fnid
>= FNID_BUTTON
)
309 if (GETPFNCLIENTW(Class
->fnid
) == pWnd
->lpfnWndProc
)
310 Ret
= GETPFNCLIENTA(Class
->fnid
);
314 if (GETPFNCLIENTA(Class
->fnid
) == pWnd
->lpfnWndProc
)
315 Ret
= GETPFNCLIENTW(Class
->fnid
);
318 // Return on the change.
319 if ( Ret
!= pWnd
->lpfnWndProc
)
323 if ( Ansi
== !!(pWnd
->state
& WNDS_ANSIWINDOWPROC
) )
326 gcpd
= (WNDPROC
)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
)
547 GetClassLongPtrA(HWND hWnd
,
559 GetClassLongPtrW(HWND hWnd
,
577 ANSI_STRING ClassName
;
580 ClassName
.MaximumLength
= nMaxCount
;
581 ClassName
.Buffer
= lpClassName
;
583 Result
= NtUserGetClassName(hWnd
,
584 (PUNICODE_STRING
)&ClassName
,
587 TRACE("%p class/atom: %s/%04x %x\n", hWnd
,
588 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
589 IS_ATOM(lpClassName
) ? lpClassName
: 0,
606 UNICODE_STRING ClassName
;
609 ClassName
.MaximumLength
= nMaxCount
* sizeof(WCHAR
);
610 ClassName
.Buffer
= lpClassName
;
612 Result
= NtUserGetClassName(hWnd
,
616 TRACE("%p class/atom: %S/%04x %x\n", hWnd
,
617 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
618 IS_ATOM(lpClassName
) ? lpClassName
: 0,
638 if (offset
< 0) return GetClassLongA( hwnd
, offset
);
640 Wnd
= ValidateHwnd(hwnd
);
644 class = DesktopPtrToUser(Wnd
->pcls
);
645 if (class == NULL
) return 0;
647 if (offset
<= class->cbclsExtra
- sizeof(WORD
))
648 memcpy( &retvalue
, (char *)(class + 1) + offset
, sizeof(retvalue
) );
650 SetLastError( ERROR_INVALID_INDEX
);
656 LONG_PTR
IntGetWindowLong( HWND hwnd
, INT offset
, UINT size
, BOOL unicode
)
658 LONG_PTR retvalue
= 0;
661 if (offset
== GWLP_HWNDPARENT
)
663 HWND parent
= GetAncestor( hwnd
, GA_PARENT
);
664 if (parent
== GetDesktopWindow()) parent
= GetWindow( hwnd
, GW_OWNER
);
665 return (ULONG_PTR
)parent
;
668 if (!(wndPtr
= ValidateHwnd( hwnd
)))
670 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
676 if (offset
> (int)(wndPtr
->cbwndExtra
- size
))
678 WARN("Invalid offset %d\n", offset
);
679 SetLastError( ERROR_INVALID_INDEX
);
682 retvalue
= *((LONG_PTR
*)((PCHAR
)(wndPtr
+ 1) + offset
));
684 /* WINE: special case for dialog window procedure */
685 //if ((offset == DWLP_DLGPROC) && (size == sizeof(LONG_PTR)) && (wndPtr->flags & WIN_ISDIALOG))
686 // retvalue = (LONG_PTR)IntGetWndProc( (WNDPROC)retvalue, unicode );
692 case GWLP_USERDATA
: retvalue
= wndPtr
->dwUserData
; break;
693 case GWL_STYLE
: retvalue
= wndPtr
->style
; break;
694 case GWL_EXSTYLE
: retvalue
= wndPtr
->ExStyle
; break;
695 case GWLP_ID
: retvalue
= wndPtr
->IDMenu
; break;
696 case GWLP_HINSTANCE
: retvalue
= (ULONG_PTR
)wndPtr
->hModule
; break;
699 if (!TestWindowProcess(wndPtr
))
701 SetLastError(ERROR_ACCESS_DENIED
);
704 retvalue
= (ULONG_PTR
)IntGetWndProc(wndPtr
, !unicode
);
708 WARN("Unknown offset %d\n", offset
);
709 SetLastError( ERROR_INVALID_INDEX
);
720 GetWindowLongA ( HWND hWnd
, int nIndex
)
722 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), FALSE
);
730 GetWindowLongW(HWND hWnd
, int nIndex
)
732 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG
), TRUE
);
741 GetWindowLongPtrA(HWND hWnd
,
744 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), FALSE
);
752 GetWindowLongPtrW(HWND hWnd
,
755 return IntGetWindowLong( hWnd
, nIndex
, sizeof(LONG_PTR
), TRUE
);
765 GetWindowWord(HWND hWnd
, int nIndex
)
771 case GWLP_HWNDPARENT
:
776 WARN("Invalid offset %d\n", nIndex
);
777 SetLastError( ERROR_INVALID_INDEX
);
782 return IntGetWindowLong( hWnd
, nIndex
, sizeof(WORD
), FALSE
);
795 /* FIXME: Implement correct functionality of RealGetWindowClass */
796 return GetClassNameW(hwnd
,pszType
,cchType
);
810 /* FIXME: Implement correct functionality of RealGetWindowClass */
811 return GetClassNameA(hwnd
,pszType
,cchType
);
815 * Create a small icon based on a standard icon
818 CreateSmallIcon(HICON StdIcon
)
820 HICON SmallIcon
= NULL
;
824 BITMAP StdBitmapInfo
;
826 HDC hSourceDc
= NULL
;
829 HBITMAP OldSourceBitmap
= NULL
;
830 HBITMAP OldDestBitmap
= NULL
;
832 SmallInfo
.hbmColor
= NULL
;
833 SmallInfo
.hbmMask
= NULL
;
835 /* We need something to work with... */
841 SmallIconWidth
= GetSystemMetrics(SM_CXSMICON
);
842 SmallIconHeight
= GetSystemMetrics(SM_CYSMICON
);
843 if (! GetIconInfo(StdIcon
, &StdInfo
))
845 ERR("Failed to get icon info for icon 0x%x\n", StdIcon
);
848 if (! GetObjectW(StdInfo
.hbmMask
, sizeof(BITMAP
), &StdBitmapInfo
))
850 ERR("Failed to get bitmap info for icon 0x%x bitmap 0x%x\n",
851 StdIcon
, StdInfo
.hbmColor
);
854 if (StdBitmapInfo
.bmWidth
== SmallIconWidth
&&
855 StdBitmapInfo
.bmHeight
== SmallIconHeight
)
857 /* Icon already has the correct dimensions */
861 /* Get a handle to a info DC and handles to DCs which can be used to
862 select a bitmap into. This is done to avoid triggering a switch to
863 graphics mode (if we're currently in text/blue screen mode) */
864 hInfoDc
= CreateICW(NULL
, NULL
, NULL
, NULL
);
867 ERR("Failed to create info DC\n");
870 hSourceDc
= CreateCompatibleDC(NULL
);
871 if (NULL
== hSourceDc
)
873 ERR("Failed to create source DC\n");
876 hDestDc
= CreateCompatibleDC(NULL
);
879 ERR("Failed to create dest DC\n");
883 OldSourceBitmap
= SelectObject(hSourceDc
, StdInfo
.hbmColor
);
884 if (NULL
== OldSourceBitmap
)
886 ERR("Failed to select source color bitmap\n");
889 SmallInfo
.hbmColor
= CreateCompatibleBitmap(hInfoDc
, SmallIconWidth
,
891 if (NULL
== SmallInfo
.hbmColor
)
893 ERR("Failed to create color bitmap\n");
896 OldDestBitmap
= SelectObject(hDestDc
, SmallInfo
.hbmColor
);
897 if (NULL
== OldDestBitmap
)
899 ERR("Failed to select dest color bitmap\n");
902 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
903 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
904 StdBitmapInfo
.bmHeight
, SRCCOPY
))
906 ERR("Failed to stretch color bitmap\n");
910 if (NULL
== SelectObject(hSourceDc
, StdInfo
.hbmMask
))
912 ERR("Failed to select source mask bitmap\n");
915 SmallInfo
.hbmMask
= CreateBitmap(SmallIconWidth
, SmallIconHeight
, 1, 1,
917 if (NULL
== SmallInfo
.hbmMask
)
919 ERR("Failed to create mask bitmap\n");
922 if (NULL
== SelectObject(hDestDc
, SmallInfo
.hbmMask
))
924 ERR("Failed to select dest mask bitmap\n");
927 if (! StretchBlt(hDestDc
, 0, 0, SmallIconWidth
, SmallIconHeight
,
928 hSourceDc
, 0, 0, StdBitmapInfo
.bmWidth
,
929 StdBitmapInfo
.bmHeight
, SRCCOPY
))
931 ERR("Failed to stretch mask bitmap\n");
935 SmallInfo
.fIcon
= TRUE
;
936 SmallInfo
.xHotspot
= SmallIconWidth
/ 2;
937 SmallInfo
.yHotspot
= SmallIconHeight
/ 2;
938 SmallIcon
= CreateIconIndirect(&SmallInfo
);
939 if (NULL
== SmallIcon
)
941 ERR("Failed to create icon\n");
946 if (NULL
!= SmallInfo
.hbmMask
)
948 DeleteObject(SmallInfo
.hbmMask
);
950 if (NULL
!= OldDestBitmap
)
952 SelectObject(hDestDc
, OldDestBitmap
);
954 if (NULL
!= SmallInfo
.hbmColor
)
956 DeleteObject(SmallInfo
.hbmColor
);
962 if (NULL
!= OldSourceBitmap
)
964 SelectObject(hSourceDc
, OldSourceBitmap
);
966 if (NULL
!= hSourceDc
)
980 RegisterClassExWOWW(WNDCLASSEXW
*lpwcx
,
987 WNDCLASSEXW WndClass
;
988 UNICODE_STRING ClassName
;
989 UNICODE_STRING MenuName
= {0};
990 CLSMENUNAME clsMenuName
;
991 ANSI_STRING AnsiMenuName
;
993 if (lpwcx
== NULL
|| lpwcx
->cbSize
!= sizeof(WNDCLASSEXW
) ||
994 lpwcx
->cbClsExtra
< 0 || lpwcx
->cbWndExtra
< 0 ||
995 lpwcx
->lpszClassName
== NULL
)
997 TRACE("RegisterClassExWOWW Invalid Parameter Error!\n");
998 SetLastError(ERROR_INVALID_PARAMETER
);
1004 if (!RegisterDefaultClasses
) RegisterSystemControls();
1007 * On real Windows this looks more like:
1008 * if (lpwcx->hInstance == User32Instance &&
1009 * *(PULONG)((ULONG_PTR)NtCurrentTeb() + 0x6D4) & 0x400)
1010 * But since I have no idea what the magic field in the
1011 * TEB structure means, I rather decided to omit that.
1014 GetWin32ClientInfo()->dwExpWinVer & (WINVER == 0x400)
1016 if (lpwcx
->hInstance
== User32Instance
)
1018 TRACE("RegisterClassExWOWW User32Instance!\n");
1019 SetLastError(ERROR_INVALID_PARAMETER
);
1022 /* Yes, this is correct. We should modify the passed structure. */
1023 if (lpwcx
->hInstance
== NULL
)
1024 ((WNDCLASSEXW
*)lpwcx
)->hInstance
= GetModuleHandleW(NULL
);
1026 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXW
));
1028 if (NULL
== WndClass
.hIconSm
)
1030 WndClass
.hIconSm
= CreateSmallIcon(WndClass
.hIcon
);
1033 if (WndClass
.lpszMenuName
!= NULL
)
1035 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1037 if (WndClass
.lpszMenuName
[0])
1039 RtlInitUnicodeString(&MenuName
, WndClass
.lpszMenuName
);
1040 RtlUnicodeStringToAnsiString( &AnsiMenuName
, &MenuName
, TRUE
);
1045 MenuName
.Buffer
= (LPWSTR
)WndClass
.lpszMenuName
;
1046 AnsiMenuName
.Buffer
= (PCHAR
)WndClass
.lpszMenuName
;
1050 if (IS_ATOM(WndClass
.lpszClassName
))
1053 ClassName
.MaximumLength
= 0;
1054 ClassName
.Buffer
= (LPWSTR
)WndClass
.lpszClassName
;
1058 RtlInitUnicodeString(&ClassName
, WndClass
.lpszClassName
);
1061 clsMenuName
.pszClientAnsiMenuName
= AnsiMenuName
.Buffer
;
1062 clsMenuName
.pwszClientUnicodeMenuName
= MenuName
.Buffer
;
1063 clsMenuName
.pusMenuName
= &MenuName
;
1065 Atom
= NtUserRegisterClassExWOW( &WndClass
,
1067 NULL
, //PUNICODE_STRING ClsNVersion,
1073 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1074 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1075 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1084 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
1087 WNDCLASSEXW WndClass
;
1088 WCHAR mname
[MAX_BUFFER_LEN
];
1089 WCHAR cname
[MAX_BUFFER_LEN
];
1091 RtlCopyMemory(&WndClass
, lpwcx
, sizeof(WNDCLASSEXA
));
1093 if (WndClass
.lpszMenuName
!= NULL
)
1095 if (!IS_INTRESOURCE(WndClass
.lpszMenuName
))
1097 if (WndClass
.lpszMenuName
[0])
1099 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszMenuName
, -1, mname
, MAX_ATOM_LEN
+ 1 )) return 0;
1101 WndClass
.lpszMenuName
= mname
;
1106 if (!IS_ATOM(WndClass
.lpszClassName
))
1108 if (!MultiByteToWideChar( CP_ACP
, 0, lpwcx
->lpszClassName
, -1, cname
, MAX_ATOM_LEN
+ 1 )) return 0;
1110 WndClass
.lpszClassName
= cname
;
1113 Atom
= RegisterClassExWOWW( &WndClass
,
1119 TRACE("A atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
1120 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1121 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
, WndClass
);
1130 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
1134 Atom
= RegisterClassExWOWW( (WNDCLASSEXW
*)lpwcx
, 0, 0, 0, TRUE
);
1136 TRACE("W atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d\n",
1137 Atom
, lpwcx
->lpfnWndProc
, lpwcx
->hInstance
, lpwcx
->hbrBackground
,
1138 lpwcx
->style
, lpwcx
->cbClsExtra
, lpwcx
->cbWndExtra
);
1147 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
1151 if (lpWndClass
== NULL
)
1154 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSA
));
1155 Class
.cbSize
= sizeof(WNDCLASSEXA
);
1156 Class
.hIconSm
= NULL
;
1158 return RegisterClassExA(&Class
);
1165 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
1169 if (lpWndClass
== NULL
)
1172 RtlCopyMemory(&Class
.style
, lpWndClass
, sizeof(WNDCLASSW
));
1173 Class
.cbSize
= sizeof(WNDCLASSEXW
);
1174 Class
.hIconSm
= NULL
;
1176 return RegisterClassExW(&Class
);
1184 SetClassLongA (HWND hWnd
,
1188 PSTR lpStr
= (PSTR
)(ULONG_PTR
)dwNewLong
;
1189 UNICODE_STRING Value
= {0};
1190 BOOL Allocated
= FALSE
;
1193 /* FIXME - portability!!!! */
1195 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1197 if (!IS_INTRESOURCE(lpStr
))
1199 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1202 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1209 Value
.Buffer
= (PWSTR
)lpStr
;
1211 dwNewLong
= (LONG_PTR
)&Value
;
1213 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1215 if (!IS_ATOM(lpStr
))
1217 if (!RtlCreateUnicodeStringFromAsciiz(&Value
,
1220 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1227 Value
.Buffer
= (PWSTR
)lpStr
;
1229 dwNewLong
= (LONG_PTR
)&Value
;
1232 Ret
= (DWORD
)NtUserSetClassLong(hWnd
,
1239 RtlFreeUnicodeString(&Value
);
1251 SetClassLongW(HWND hWnd
,
1255 PWSTR lpStr
= (PWSTR
)(ULONG_PTR
)dwNewLong
;
1256 UNICODE_STRING Value
= {0};
1258 TRACE("%p %d %lx\n", hWnd
, nIndex
, dwNewLong
);
1260 /* FIXME - portability!!!! */
1262 if (nIndex
== GCL_MENUNAME
&& lpStr
!= NULL
)
1264 if (!IS_INTRESOURCE(lpStr
))
1266 RtlInitUnicodeString(&Value
,
1270 Value
.Buffer
= lpStr
;
1272 dwNewLong
= (LONG_PTR
)&Value
;
1274 else if (nIndex
== GCW_ATOM
&& lpStr
!= NULL
)
1276 if (!IS_ATOM(lpStr
))
1278 RtlInitUnicodeString(&Value
,
1282 Value
.Buffer
= lpStr
;
1284 dwNewLong
= (LONG_PTR
)&Value
;
1287 return (DWORD
)NtUserSetClassLong(hWnd
,
1299 SetClassLongPtrA(HWND hWnd
,
1312 SetClassLongPtrW(HWND hWnd
,
1331 * NOTE: Obsoleted in 32-bit windows
1334 if ((nIndex
< 0) && (nIndex
!= GCW_ATOM
))
1337 return (WORD
) SetClassLongW ( hWnd
, nIndex
, wNewWord
);
1345 SetWindowWord ( HWND hWnd
,int nIndex
,WORD wNewWord
)
1350 case GWLP_HINSTANCE
:
1351 case GWLP_HWNDPARENT
:
1356 WARN("Invalid offset %d\n", nIndex
);
1357 SetLastError( ERROR_INVALID_INDEX
);
1362 return NtUserSetWindowLong( hWnd
, nIndex
, wNewWord
, FALSE
);
1375 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
1388 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1397 SetWindowLongPtrA(HWND hWnd
,
1401 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1409 SetWindowLongPtrW(HWND hWnd
,
1413 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);
1424 HINSTANCE hInstance
)
1426 UNICODE_STRING ClassName
= {0};
1429 TRACE("class/atom: %s/%04x %p\n",
1430 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1431 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1434 if (!IS_ATOM(lpClassName
))
1436 if (!RtlCreateUnicodeStringFromAsciiz(&ClassName
,
1439 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1444 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1446 Ret
= NtUserUnregisterClass(&ClassName
,
1450 if (!IS_ATOM(lpClassName
))
1451 RtlFreeUnicodeString(&ClassName
);
1463 LPCWSTR lpClassName
,
1464 HINSTANCE hInstance
)
1466 UNICODE_STRING ClassName
= {0};
1468 TRACE("class/atom: %S/%04x %p\n",
1469 IS_ATOM(lpClassName
) ? NULL
: lpClassName
,
1470 IS_ATOM(lpClassName
) ? lpClassName
: 0,
1473 if (!IS_ATOM(lpClassName
))
1475 RtlInitUnicodeString(&ClassName
,
1479 ClassName
.Buffer
= (PWSTR
)((ULONG_PTR
)lpClassName
);
1481 return NtUserUnregisterClass(&ClassName
,