From 1717987643448066735cdae731de367a1e18b6b1 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Mon, 18 Aug 2003 23:52:03 +0000 Subject: [PATCH] fixed GetClassInfoExA/W() and CreateWindowExA/W() svn path=/trunk/; revision=5659 --- reactos/lib/user32/windows/class.c | 52 +++++++++++++++++++--------- reactos/lib/user32/windows/window.c | 22 +++++++++++- reactos/subsys/win32k/ntuser/class.c | 7 ++-- 3 files changed, 61 insertions(+), 20 deletions(-) diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c index c877816e09e..cf2902ccf55 100644 --- a/reactos/lib/user32/windows/class.c +++ b/reactos/lib/user32/windows/class.c @@ -1,4 +1,4 @@ -/* $Id: class.c,v 1.29 2003/08/14 20:25:52 royce Exp $ +/* $Id: class.c,v 1.30 2003/08/18 23:52:03 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -27,7 +27,7 @@ GetClassInfoExA( LPWNDCLASSEXA lpwcx) { LPWSTR str; - PUNICODE_STRING str2; + UNICODE_STRING str2; WNDCLASSEXW w; BOOL retval; NTSTATUS Status; @@ -37,18 +37,27 @@ GetClassInfoExA( SetLastError (RtlNtStatusToDosError(Status)); return 0; } - retval = (BOOL)NtUserGetClassInfo(hinst,str,&w,TRUE,0); - if (str) + + str2.Length = 0; + str2.MaximumLength = 255; + str2.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), 0, + str2.MaximumLength * sizeof(WCHAR)); + if(!str2.Buffer) { - HEAP_free(str); + SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY)); + return 0; } - RtlCopyMemory (&w,lpwcx,sizeof(WNDCLASSEXW)); + + w.lpszMenuName = (LPCWSTR)&str2; + retval = (BOOL)NtUserGetClassInfo(hinst, str, &w, TRUE, 0); + HEAP_free(str); + RtlCopyMemory ( lpwcx, &w, sizeof(WNDCLASSEXW) ); + if (!IS_INTRESOURCE(w.lpszMenuName)) { - str = (LPWSTR)w.lpszMenuName; - str2 = (PUNICODE_STRING)str; - lpwcx->lpszMenuName = heap_string_poolA (str2->Buffer, str2->Length); + lpwcx->lpszMenuName = heap_string_poolA (str2.Buffer, str2.Length); } + RtlFreeHeap(RtlGetProcessHeap(), 0, str2.Buffer); return retval; } @@ -64,22 +73,31 @@ GetClassInfoExW( LPWNDCLASSEXW lpwcx) { LPWSTR str; - PUNICODE_STRING str2; + UNICODE_STRING str2; WNDCLASSEXW w; WINBOOL retval; str = HEAP_strdupW (lpszClass, wcslen(lpszClass) ); - retval = (BOOL)NtUserGetClassInfo(hinst,lpszClass,&w,FALSE,0); - if (str) + + str2.Length = 0; + str2.MaximumLength = 255; + str2.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), 0, + str2.MaximumLength * sizeof(WCHAR)); + if(!str2.Buffer) { - HEAP_free(str); + SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY)); + return 0; } - RtlCopyMemory (&w,lpwcx,sizeof(WNDCLASSEXW)); + + w.lpszMenuName = (LPCWSTR)&str2; + retval = (BOOL)NtUserGetClassInfo(hinst, str, &w, TRUE, 0); + HEAP_free(str); + RtlCopyMemory ( lpwcx, &w, sizeof(WNDCLASSEXW) ); + if (!IS_INTRESOURCE(w.lpszMenuName) ) { - str = (LPWSTR)w.lpszMenuName; - str2 = (PUNICODE_STRING)str; - lpwcx->lpszMenuName = heap_string_poolW (str2->Buffer, str2->Length); + lpwcx->lpszMenuName = heap_string_poolW (str2.Buffer, str2.Length); } + RtlFreeHeap(RtlGetProcessHeap(), 0, str2.Buffer); return retval; } diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index c0df20ac030..35b805cf0d7 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.65 2003/08/18 00:11:17 weiden Exp $ +/* $Id: window.c,v 1.66 2003/08/18 23:52:03 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -508,6 +508,7 @@ CreateWindowExA(DWORD dwExStyle, { UNICODE_STRING WindowName; UNICODE_STRING ClassName; + WNDCLASSEXA wce; HWND Handle; INT sw; @@ -593,6 +594,15 @@ CreateWindowExA(DWORD dwExStyle, } } } + + if(!hMenu) + { + wce.cbSize = sizeof(WNDCLASSEXA); + if(GetClassInfoExA(hInstance, lpClassName, &wce) && wce.lpszMenuName) + { + hMenu = LoadMenuA(hInstance, wce.lpszMenuName); + } + } Handle = NtUserCreateWindowEx(dwExStyle, &ClassName, @@ -640,6 +650,7 @@ CreateWindowExW(DWORD dwExStyle, { UNICODE_STRING WindowName; UNICODE_STRING ClassName; + WNDCLASSEXW wce; HANDLE Handle; UINT sw; @@ -711,6 +722,15 @@ CreateWindowExW(DWORD dwExStyle, } } } + + if(!hMenu) + { + wce.cbSize = sizeof(WNDCLASSEXW); + if(GetClassInfoExW(hInstance, lpClassName, &wce) && wce.lpszMenuName) + { + hMenu = LoadMenuW(hInstance, wce.lpszMenuName); + } + } Handle = NtUserCreateWindowEx(dwExStyle, &ClassName, diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c index 3572bcd23dc..836b8e6e2f6 100644 --- a/reactos/subsys/win32k/ntuser/class.c +++ b/reactos/subsys/win32k/ntuser/class.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: class.c,v 1.30 2003/08/14 01:38:19 royce Exp $ +/* $Id: class.c,v 1.31 2003/08/18 23:52:03 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -181,9 +181,12 @@ NtUserGetClassInfo(HINSTANCE hInst, wcex->hIcon = Class->hIcon; wcex->hCursor = Class->hCursor; wcex->hbrBackground = Class->hbrBackground; - wcex->lpszMenuName = (LPCWSTR)Class->lpszMenuName; + //wcex->lpszMenuName = (LPCWSTR)Class->lpszMenuName; wcex->lpszClassName = (LPCWSTR)Class->lpszClassName; wcex->hIconSm = Class->hIconSm; + DbgPrint("Copying string...\n"); + RtlCopyUnicodeString((PUNICODE_STRING)wcex->lpszMenuName, Class->lpszMenuName); + DbgPrint("Copied string...\n"); return 1; }