ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2026
April
March
February
January
2025
December
November
October
September
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
----- 2026 -----
April 2026
March 2026
February 2026
January 2026
----- 2025 -----
December 2025
November 2025
October 2025
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
81390 discussions
Start a n
N
ew thread
[greatlrd] 21463: revers my last commit it was misunderstanding from my side
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: greatlrd Date: Wed Apr 5 14:46:00 2006 New Revision: 21463 URL:
http://svn.reactos.ru/svn/reactos?rev=21463&view=rev
Log: revers my last commit it was misunderstanding from my side Modified: trunk/reactos/subsystems/win32/win32k/include/class.h trunk/reactos/subsystems/win32/win32k/ntuser/class.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c Modified: trunk/reactos/subsystems/win32/win32k/include/class.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/class.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/class.h Wed Apr 5 14:46:00 2006 @@ -32,8 +32,7 @@ DestroyProcessClasses(PW32PROCESS Process ); PWINDOWCLASS -IntReferenceClass(IN OUT PWINDOWCLASS BaseClass, - IN OUT PWINDOWCLASS *ClassLink, +IntReferenceClass(IN PWINDOWCLASS BaseClass, IN PDESKTOP Desktop); VOID Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/class.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c Wed Apr 5 14:46:00 2006 @@ -361,8 +361,7 @@ } static PWINDOWCLASS -IntGetClassForDesktop(IN OUT PWINDOWCLASS BaseClass, - IN OUT PWINDOWCLASS *ClassLink, +IntGetClassForDesktop(IN PWINDOWCLASS BaseClass, IN PDESKTOP Desktop) { SIZE_T ClassSize; @@ -381,8 +380,6 @@ if (BaseClass->Desktop == NULL) { - ASSERT(BaseClass->Windows == 0); - /* Classes are also located in the shared heap when the class was created before the thread attached to a desktop. As soon as a window is created for such a class located on the shared @@ -427,22 +424,11 @@ /* update some pointers and link the class */ Class->Next = BaseClass->Clone; Class->Clone = NULL; + Class->Base = BaseClass; Class->Desktop = Desktop; Class->Windows = 0; - - if (BaseClass->Desktop == NULL) - { - /* replace the base class */ - Class->Base = BaseClass; - /* FIXME */ - } - else - { - /* link in the clone */ - Class->Base = BaseClass; - (void)InterlockedExchangePointer(&BaseClass->Clone, - Class); - } + (void)InterlockedExchangePointer(&BaseClass->Clone, + Class); } else { @@ -454,14 +440,12 @@ } PWINDOWCLASS -IntReferenceClass(IN OUT PWINDOWCLASS BaseClass, - IN OUT PWINDOWCLASS *ClassLink, +IntReferenceClass(IN PWINDOWCLASS BaseClass, IN PDESKTOP Desktop) { PWINDOWCLASS Class; Class = IntGetClassForDesktop(BaseClass, - ClassLink, Desktop); if (Class != NULL) { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Wed Apr 5 14:46:00 2006 @@ -1394,7 +1394,7 @@ BOOL bUnicodeWindow) { PWINSTATION_OBJECT WinSta; - PWINDOWCLASS *ClassLink, Class = NULL; + PWINDOWCLASS Class = NULL; RTL_ATOM ClassAtom; PWINDOW_OBJECT Window = NULL; PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow; @@ -1475,7 +1475,7 @@ hInstance, ti->kpi, &Class, - &ClassLink); + NULL); if (ClassAtom == (RTL_ATOM)0) { @@ -1493,7 +1493,6 @@ } Class = IntReferenceClass(Class, - ClassLink, ti->Desktop); if (Class == NULL) {
1
0
0
0
[greatlrd] 21462: patch from w3seek fixing windows handles
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: greatlrd Date: Wed Apr 5 14:33:55 2006 New Revision: 21462 URL:
http://svn.reactos.ru/svn/reactos?rev=21462&view=rev
Log: patch from w3seek fixing windows handles Modified: trunk/reactos/subsystems/win32/win32k/include/class.h trunk/reactos/subsystems/win32/win32k/ntuser/class.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c Modified: trunk/reactos/subsystems/win32/win32k/include/class.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/class.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/class.h Wed Apr 5 14:33:55 2006 @@ -32,7 +32,8 @@ DestroyProcessClasses(PW32PROCESS Process ); PWINDOWCLASS -IntReferenceClass(IN PWINDOWCLASS BaseClass, +IntReferenceClass(IN OUT PWINDOWCLASS BaseClass, + IN OUT PWINDOWCLASS *ClassLink, IN PDESKTOP Desktop); VOID Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/class.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c Wed Apr 5 14:33:55 2006 @@ -361,7 +361,8 @@ } static PWINDOWCLASS -IntGetClassForDesktop(IN PWINDOWCLASS BaseClass, +IntGetClassForDesktop(IN OUT PWINDOWCLASS BaseClass, + IN OUT PWINDOWCLASS *ClassLink, IN PDESKTOP Desktop) { SIZE_T ClassSize; @@ -380,6 +381,8 @@ if (BaseClass->Desktop == NULL) { + ASSERT(BaseClass->Windows == 0); + /* Classes are also located in the shared heap when the class was created before the thread attached to a desktop. As soon as a window is created for such a class located on the shared @@ -424,11 +427,22 @@ /* update some pointers and link the class */ Class->Next = BaseClass->Clone; Class->Clone = NULL; - Class->Base = BaseClass; Class->Desktop = Desktop; Class->Windows = 0; - (void)InterlockedExchangePointer(&BaseClass->Clone, - Class); + + if (BaseClass->Desktop == NULL) + { + /* replace the base class */ + Class->Base = BaseClass; + /* FIXME */ + } + else + { + /* link in the clone */ + Class->Base = BaseClass; + (void)InterlockedExchangePointer(&BaseClass->Clone, + Class); + } } else { @@ -440,12 +454,14 @@ } PWINDOWCLASS -IntReferenceClass(IN PWINDOWCLASS BaseClass, +IntReferenceClass(IN OUT PWINDOWCLASS BaseClass, + IN OUT PWINDOWCLASS *ClassLink, IN PDESKTOP Desktop) { PWINDOWCLASS Class; Class = IntGetClassForDesktop(BaseClass, + ClassLink, Desktop); if (Class != NULL) { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Wed Apr 5 14:33:55 2006 @@ -1394,7 +1394,7 @@ BOOL bUnicodeWindow) { PWINSTATION_OBJECT WinSta; - PWINDOWCLASS Class = NULL; + PWINDOWCLASS *ClassLink, Class = NULL; RTL_ATOM ClassAtom; PWINDOW_OBJECT Window = NULL; PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow; @@ -1475,7 +1475,7 @@ hInstance, ti->kpi, &Class, - NULL); + &ClassLink); if (ClassAtom == (RTL_ATOM)0) { @@ -1493,6 +1493,7 @@ } Class = IntReferenceClass(Class, + ClassLink, ti->Desktop); if (Class == NULL) {
1
0
0
0
[greatlrd] 21461: fix a memmory leak in create surface
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: greatlrd Date: Wed Apr 5 14:16:11 2006 New Revision: 21461 URL:
http://svn.reactos.ru/svn/reactos?rev=21461&view=rev
Log: fix a memmory leak in create surface Modified: trunk/reactos/dll/directx/ddraw/hal/surface_hal.c trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Modified: trunk/reactos/dll/directx/ddraw/hal/surface_hal.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/hal/surfa…
============================================================================== --- trunk/reactos/dll/directx/ddraw/hal/surface_hal.c (original) +++ trunk/reactos/dll/directx/ddraw/hal/surface_hal.c Wed Apr 5 14:16:11 2006 @@ -66,7 +66,7 @@ mDdCreateSurface.CreateSurface = This->mCallbacks.HALDD.CreateSurface; mDdCreateSurface.lpDDSurfaceDesc = &This->mddsdPrimary;//pDDSD; mDdCreateSurface.lplpSList = This->mpPrimaryLocals; //cSurfaces; - mDdCreateSurface.dwSCnt = 1 ; //ppSurfaces; + mDdCreateSurface.dwSCnt = This->mDDrawGlobal.dsList->dwIntRefCnt ; //ppSurfaces; if (This->mHALInfo.lpDDCallbacks->CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED) { @@ -138,8 +138,7 @@ if (This->mHALInfo.lpDDCallbacks->CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED) { - // derr(L"DirectDrawImpl[%08x]::__createPrimary Cannot create primary [%08x]", this, rv); - return DDERR_NOTINITIALIZED; + return DDERR_NOTINITIALIZED; } if (mDdCanCreateSurface.ddRVal != DD_OK) @@ -181,7 +180,7 @@ This->mpOverlayLocals[i] = &This->mOverlayLocal[i]; } - for (i = 0; i < cSurfaces; i++) + for ( i = 0; i < cSurfaces; i++) { UINT j = (i + 1) % cSurfaces; Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddra…
============================================================================== --- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original) +++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Wed Apr 5 14:16:11 2006 @@ -275,6 +275,7 @@ ret = Hel_DirectDraw_CreateSurface (iface, pDDSD, ppSurf, pUnkOuter); } + This->mDDrawGlobal.dsList = (LPDDRAWI_DDRAWSURFACE_INT)&This->mPrimaryLocal; // the real surface object creation
1
0
0
0
[peterw] 21460: Applied patch by: Thomas Weidenmueller - win32k window class rewrite. - http://www.reactos.org/bugzilla/show_bug.cgi?id=1366
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: peterw Date: Wed Apr 5 12:05:55 2006 New Revision: 21460 URL:
http://svn.reactos.ru/svn/reactos?rev=21460&view=rev
Log: Applied patch by: Thomas Weidenmueller - win32k window class rewrite. -
http://www.reactos.org/bugzilla/show_bug.cgi?id=1366
Added: trunk/reactos/subsystems/win32/win32k/misc/usrheap.c Modified: trunk/reactos/dll/win32/user32/controls/regcontrol.c trunk/reactos/dll/win32/user32/misc/misc.c trunk/reactos/dll/win32/user32/windows/class.c trunk/reactos/dll/win32/user32/windows/message.c trunk/reactos/dll/win32/user32/windows/window.c trunk/reactos/include/ndk/pstypes.h trunk/reactos/include/reactos/probe.h trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/lib/rtl/heap.c trunk/reactos/subsystems/win32/win32k/include/class.h trunk/reactos/subsystems/win32/win32k/include/desktop.h trunk/reactos/subsystems/win32/win32k/include/object.h trunk/reactos/subsystems/win32/win32k/include/userfuncs.h trunk/reactos/subsystems/win32/win32k/include/win32.h trunk/reactos/subsystems/win32/win32k/include/window.h trunk/reactos/subsystems/win32/win32k/main/dllmain.c trunk/reactos/subsystems/win32/win32k/misc/err.c trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c trunk/reactos/subsystems/win32/win32k/ntuser/class.c trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c trunk/reactos/subsystems/win32/win32k/ntuser/hook.c trunk/reactos/subsystems/win32/win32k/ntuser/menu.c trunk/reactos/subsystems/win32/win32k/ntuser/message.c trunk/reactos/subsystems/win32/win32k/ntuser/misc.c trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c trunk/reactos/subsystems/win32/win32k/ntuser/object.c trunk/reactos/subsystems/win32/win32k/ntuser/windc.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c trunk/reactos/subsystems/win32/win32k/w32k.h trunk/reactos/subsystems/win32/win32k/win32k.rbuild trunk/reactos/tools/nci/w32ksvc.db Modified: trunk/reactos/dll/win32/user32/controls/regcontrol.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/controls/r…
============================================================================== --- trunk/reactos/dll/win32/user32/controls/regcontrol.c (original) +++ trunk/reactos/dll/win32/user32/controls/regcontrol.c Wed Apr 5 12:05:55 2006 @@ -44,15 +44,13 @@ RtlInitUnicodeString(&ClassName, Descr->name); } - NtUserRegisterClassExWOW( + NtUserRegisterClassEx( &wc, - &ClassName, &ClassName, &MenuName, Descr->procA, REGISTERCLASS_SYSTEM, - 0, - 0); + NULL); } /*********************************************************************** Modified: trunk/reactos/dll/win32/user32/misc/misc.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc.…
============================================================================== --- trunk/reactos/dll/win32/user32/misc/misc.c (original) +++ trunk/reactos/dll/win32/user32/misc/misc.c Wed Apr 5 12:05:55 2006 @@ -113,3 +113,34 @@ { return NtUserUpdatePerUserSystemParameters(dwReserved, bEnable); } + +PW32THREADINFO +GetW32ThreadInfo(VOID) +{ + PW32THREADINFO ti; + + ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo; + if (ti == NULL) + { + /* create the W32THREADINFO structure */ + NtUserGetThreadState(THREADSTATE_GETTHREADINFO); + ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo; + } + + return ti; +} + +PW32PROCESSINFO +GetW32ProcessInfo(VOID) +{ + PW32THREADINFO ti; + PW32PROCESSINFO pi = NULL; + + ti = GetW32ThreadInfo(); + if (ti != NULL) + { + pi = ti->pi; + } + + return pi; +} Modified: trunk/reactos/dll/win32/user32/windows/class.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/windows/cl…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/class.c (original) +++ trunk/reactos/dll/win32/user32/windows/class.c Wed Apr 5 12:05:55 2006 @@ -11,117 +11,6 @@ #include <user32.h> -static BOOL GetClassInfoExCommon( - HINSTANCE hInst, - LPCWSTR lpszClass, - LPWNDCLASSEXW lpwcx, - BOOL unicode) -{ - LPWSTR str; - UNICODE_STRING str2, str3; - WNDCLASSEXW w; - BOOL retval; - NTSTATUS Status; - - if ( !lpszClass || !lpwcx ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if(IS_ATOM(lpszClass)) - str = (LPWSTR)lpszClass; - else - { - extern BOOL ControlsInitialized; - - if (unicode) - { - str = HEAP_strdupW ( lpszClass, wcslen(lpszClass) ); - - if ( !str ) - { - SetLastError (ERROR_OUTOFMEMORY); - return FALSE; - } - } - - else - { - Status = HEAP_strdupAtoW(&str, (LPCSTR)lpszClass, NULL); - - if (! NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - } - - /* Register built-in controls if not already done */ - if ( !ControlsInitialized ) - { - ControlsInitialized = ControlsInit(str); - } - } - - str2.Length = str3.Length = 0; - str2.MaximumLength = str3.MaximumLength = 255; - str2.Buffer = (PWSTR)HEAP_alloc ( str2.MaximumLength * sizeof(WCHAR) ); - if ( !str2.Buffer ) - { - SetLastError (ERROR_OUTOFMEMORY); - if ( !IS_ATOM(str) ) - HEAP_free ( str ); - return FALSE; - } - - str3.Buffer = (PWSTR)HEAP_alloc ( str3.MaximumLength * sizeof(WCHAR) ); - if ( !str3.Buffer ) - { - SetLastError (ERROR_OUTOFMEMORY); - HEAP_free ( str2.Buffer ); - if ( !IS_ATOM(str) ) - HEAP_free ( str ); - return FALSE; - } - - w.lpszMenuName = (LPCWSTR)&str2; - w.lpszClassName = (LPCWSTR)&str3; - - /* get info about system classes? */ - if (!hInst) hInst = User32Instance; - - retval = (BOOL)NtUserGetClassInfo(hInst, str, &w, TRUE, 0); - - w.hInstance = (hInst == User32Instance) ? 0 : hInst; - - if ( !IS_ATOM(str) ) - HEAP_free(str); - - RtlCopyMemory ( lpwcx, &w, sizeof(WNDCLASSEXW) ); - - if ( !IS_INTRESOURCE(w.lpszMenuName) && w.lpszMenuName ) - { - if (unicode) - lpwcx->lpszMenuName = heap_string_poolW ( str2.Buffer, str2.Length ); - else - ((LPWNDCLASSEXA) lpwcx)->lpszMenuName = heap_string_poolA ( str2.Buffer, str2.Length ); - } - - if ( !IS_ATOM(w.lpszClassName) && w.lpszClassName ) - { - if (unicode) - lpwcx->lpszClassName = heap_string_poolW ( str3.Buffer, str3.Length ); - else - ((LPWNDCLASSEXA) lpwcx)->lpszClassName = heap_string_poolA ( str3.Buffer, str3.Length ); - } - - HEAP_free ( str2.Buffer ); - HEAP_free ( str3.Buffer ); - - return retval; -} - /* * @implemented @@ -133,7 +22,40 @@ LPCSTR lpszClass, LPWNDCLASSEXA lpwcx) { - return GetClassInfoExCommon(hinst, (LPWSTR)lpszClass, (LPWNDCLASSEXW)lpwcx, FALSE); + UNICODE_STRING ClassName = {0}; + BOOL Ret; + + if (lpszClass == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (IS_ATOM(lpszClass)) + { + ClassName.Buffer = (PWSTR)((ULONG_PTR)lpszClass); + } + else + { + if (!RtlCreateUnicodeStringFromAsciiz(&ClassName, + lpszClass)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + + Ret = NtUserGetClassInfo(hinst, + &ClassName, + (LPWNDCLASSEXW)lpwcx, + TRUE); + + if (!IS_ATOM(lpszClass)) + { + RtlFreeUnicodeString(&ClassName); + } + + return Ret; } @@ -147,7 +69,28 @@ LPCWSTR lpszClass, LPWNDCLASSEXW lpwcx) { - return GetClassInfoExCommon(hinst, lpszClass, lpwcx, TRUE); + UNICODE_STRING ClassName = {0}; + + if (lpszClass == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (IS_ATOM(lpszClass)) + { + ClassName.Buffer = (PWSTR)((ULONG_PTR)lpszClass); + } + else + { + RtlInitUnicodeString(&ClassName, + lpszClass); + } + + return NtUserGetClassInfo(hinst, + &ClassName, + lpwcx, + FALSE); } @@ -170,6 +113,7 @@ return FALSE; } + w.cbSize = sizeof(w); retval = GetClassInfoExA(hInstance,lpClassName,&w); if (retval) { @@ -197,8 +141,12 @@ return FALSE; } + w.cbSize = sizeof(w); retval = GetClassInfoExW(hInstance,lpClassName,&w); - RtlCopyMemory (lpWndClass,&w.style,sizeof(WNDCLASSW)); + if (retval) + { + RtlCopyMemory (lpWndClass,&w.style,sizeof(WNDCLASSW)); + } return retval; } @@ -275,25 +223,14 @@ LPSTR lpClassName, int nMaxCount) { - int result; - LPWSTR ClassNameW; - NTSTATUS Status; - - if(!lpClassName) - return 0; - - ClassNameW = HEAP_alloc ( (nMaxCount+1)*sizeof(WCHAR) ); - - result = NtUserGetClassName ( hWnd, ClassNameW, nMaxCount ); - - Status = HEAP_strcpyWtoA ( lpClassName, ClassNameW, result ); - - HEAP_free ( ClassNameW ); - - if ( !NT_SUCCESS(Status) ) - return 0; - - return result; + ANSI_STRING ClassName; + + ClassName.MaximumLength = nMaxCount; + ClassName.Buffer = lpClassName; + + return NtUserGetClassName(hWnd, + (PUNICODE_STRING)&ClassName, + TRUE); } @@ -307,7 +244,14 @@ LPWSTR lpClassName, int nMaxCount) { - return NtUserGetClassName(hWnd, lpClassName, nMaxCount); + UNICODE_STRING ClassName; + + ClassName.MaximumLength = nMaxCount; + ClassName.Buffer = lpClassName; + + return NtUserGetClassName(hWnd, + &ClassName, + FALSE); } @@ -573,8 +517,8 @@ RTL_ATOM Atom; WNDCLASSEXA WndClass; UNICODE_STRING ClassName; - UNICODE_STRING MenuName; - HMENU hMenu; + UNICODE_STRING MenuName = {0}; + HMENU hMenu = NULL; if (lpwcx == NULL || lpwcx->cbSize != sizeof(WNDCLASSEXA) || lpwcx->cbClsExtra < 0 || lpwcx->cbWndExtra < 0 || @@ -609,16 +553,17 @@ WndClass.hIconSm = CreateSmallIcon(WndClass.hIcon); } - if HIWORD(lpwcx->lpszMenuName) - { - hMenu = 0; - RtlCreateUnicodeStringFromAsciiz(&MenuName, WndClass.lpszMenuName); - } - else - { - MenuName.Length = - MenuName.MaximumLength = 0; - MenuName.Buffer = (LPWSTR)WndClass.lpszMenuName; + if (lpwcx->lpszMenuName != NULL) + { + if (HIWORD(lpwcx->lpszMenuName)) + { + RtlCreateUnicodeStringFromAsciiz(&MenuName, WndClass.lpszMenuName); + } + else + { + MenuName.Buffer = (LPWSTR)WndClass.lpszMenuName; + } + hMenu = LoadMenuA(WndClass.hInstance, lpwcx->lpszMenuName); } @@ -627,20 +572,18 @@ ClassName.Length = ClassName.MaximumLength = 0; ClassName.Buffer = (LPWSTR)WndClass.lpszClassName; - } else + } + else { RtlCreateUnicodeStringFromAsciiz(&ClassName, WndClass.lpszClassName); } - Atom = NtUserRegisterClassExWOW( - (WNDCLASSEXW*)&WndClass, - &ClassName, - &ClassName, - &MenuName, - NULL, - REGISTERCLASS_ANSI, - 0, - hMenu); + Atom = NtUserRegisterClassEx((WNDCLASSEXW*)&WndClass, + &ClassName, + &MenuName, + NULL, + REGISTERCLASS_ANSI, + hMenu); if (!IS_ATOM(WndClass.lpszMenuName)) RtlFreeUnicodeString(&MenuName); @@ -658,8 +601,8 @@ { WNDCLASSEXW WndClass; UNICODE_STRING ClassName; - UNICODE_STRING MenuName; - HMENU hMenu; + UNICODE_STRING MenuName = {0}; + HMENU hMenu = NULL; if (lpwcx == NULL || lpwcx->cbSize != sizeof(WNDCLASSEXW) || lpwcx->cbClsExtra < 0 || lpwcx->cbWndExtra < 0 || @@ -694,16 +637,16 @@ WndClass.hIconSm = CreateSmallIcon(WndClass.hIcon); } - if HIWORD(lpwcx->lpszMenuName) - { - hMenu = 0; - RtlInitUnicodeString(&MenuName, WndClass.lpszMenuName); - } - else - { - MenuName.Length = - MenuName.MaximumLength = 0; - MenuName.Buffer = (LPWSTR)WndClass.lpszMenuName; + if (lpwcx->lpszMenuName != NULL) + { + if (HIWORD(lpwcx->lpszMenuName)) + { + RtlInitUnicodeString(&MenuName, WndClass.lpszMenuName); + } + else + { + MenuName.Buffer = (LPWSTR)WndClass.lpszMenuName; + } hMenu = LoadMenuW(WndClass.hInstance, lpwcx->lpszMenuName); } @@ -712,20 +655,18 @@ ClassName.Length = ClassName.MaximumLength = 0; ClassName.Buffer = (LPWSTR)WndClass.lpszClassName; - } else + } + else { RtlInitUnicodeString(&ClassName, WndClass.lpszClassName); } - return (ATOM)NtUserRegisterClassExWOW( - &WndClass, - &ClassName, - &ClassName, - &MenuName, - NULL, - 0, - 0, - hMenu); + return (ATOM)NtUserRegisterClassEx(&WndClass, + &ClassName, + &MenuName, + NULL, + 0, + hMenu); } /* @@ -769,42 +710,65 @@ */ DWORD STDCALL -SetClassLongA ( - HWND hWnd, - int nIndex, - LONG dwNewLong) -{ - UNICODE_STRING str2buf; - PUNICODE_STRING str; - PUNICODE_STRING str2 = &str2buf; - - if ( nIndex != GCL_MENUNAME ) - { - return NtUserSetClassLong ( hWnd, nIndex, dwNewLong, TRUE ); - } - if ( IS_INTRESOURCE(dwNewLong) ) - { - str2 = (PUNICODE_STRING)dwNewLong; - } - else - { - RtlCreateUnicodeStringFromAsciiz ( &str2buf,(LPSTR)dwNewLong ); - } - - str = (PUNICODE_STRING)NtUserSetClassLong(hWnd, nIndex, (DWORD)str2, TRUE); - - if ( !IS_INTRESOURCE(dwNewLong) ) - { - RtlFreeUnicodeString ( str2 ); - } - if ( IS_INTRESOURCE(str) ) - { - return (DWORD)str; - } - else - { - return (DWORD)heap_string_poolA ( str->Buffer, str->Length ); - } +SetClassLongA (HWND hWnd, + int nIndex, + LONG dwNewLong) +{ + PSTR lpStr = (PSTR)dwNewLong; + UNICODE_STRING Value = {0}; + BOOL Allocated = FALSE; + DWORD Ret; + + /* FIXME - portability!!!! */ + + if (nIndex == GCL_MENUNAME && lpStr != NULL) + { + if (!IS_INTRESOURCE(lpStr)) + { + if (!RtlCreateUnicodeStringFromAsciiz(&Value, + lpStr)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + Allocated = TRUE; + } + else + Value.Buffer = (PWSTR)lpStr; + + dwNewLong = (LONG)&Value; + } + else if (nIndex == GCW_ATOM && lpStr != NULL) + { + if (!IS_ATOM(lpStr)) + { + if (!RtlCreateUnicodeStringFromAsciiz(&Value, + lpStr)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + Allocated = TRUE; + } + else + Value.Buffer = (PWSTR)lpStr; + + dwNewLong = (LONG)&Value; + } + + Ret = (DWORD)NtUserSetClassLong(hWnd, + nIndex, + dwNewLong, + TRUE); + + if (Allocated) + { + RtlFreeUnicodeString(&Value); + } + + return Ret; } @@ -813,42 +777,44 @@ */ DWORD STDCALL -SetClassLongW( - HWND hWnd, - int nIndex, - LONG dwNewLong) -{ - UNICODE_STRING str2buf; - PUNICODE_STRING str; - PUNICODE_STRING str2 = &str2buf; - - if (nIndex != GCL_MENUNAME ) - { - return NtUserSetClassLong ( hWnd, nIndex, dwNewLong, FALSE ); - } - if ( IS_INTRESOURCE(dwNewLong) ) - { - str2 = (PUNICODE_STRING)dwNewLong; - } - else - { - RtlCreateUnicodeString ( &str2buf, (LPWSTR)dwNewLong ); - } - - str = (PUNICODE_STRING)NtUserSetClassLong(hWnd, nIndex, (DWORD)str2, TRUE); - - if ( !IS_INTRESOURCE(dwNewLong) ) - { - RtlFreeUnicodeString(str2); - } - if ( IS_INTRESOURCE(str) ) - { - return (DWORD)str; - } - else - { - return (DWORD)heap_string_poolW ( str->Buffer, str->Length ); - } +SetClassLongW(HWND hWnd, + int nIndex, + LONG dwNewLong) +{ + PWSTR lpStr = (PWSTR)dwNewLong; + UNICODE_STRING Value = {0}; + + /* FIXME - portability!!!! */ + + if (nIndex == GCL_MENUNAME && lpStr != NULL) + { + if (!IS_INTRESOURCE(lpStr)) + { + RtlInitUnicodeString(&Value, + lpStr); + } + else + Value.Buffer = lpStr; + + dwNewLong = (LONG)&Value; + } + else if (nIndex == GCW_ATOM && lpStr != NULL) + { + if (!IS_ATOM(lpStr)) + { + RtlInitUnicodeString(&Value, + lpStr); + } + else + Value.Buffer = lpStr; + + dwNewLong = (LONG)&Value; + } + + return (DWORD)NtUserSetClassLong(hWnd, + nIndex, + dwNewLong, + FALSE); } @@ -868,7 +834,7 @@ if ((nIndex < 0) && (nIndex != GCW_ATOM)) return 0; - return (WORD) NtUserSetClassLong ( hWnd, nIndex, wNewWord, TRUE ); + return (WORD) SetClassLongW ( hWnd, nIndex, wNewWord ); } @@ -909,28 +875,32 @@ LPCSTR lpClassName, HINSTANCE hInstance) { - LPWSTR ClassName; - NTSTATUS Status; - BOOL Result; - - if(!IS_ATOM(lpClassName)) - { - Status = HEAP_strdupAtoW(&ClassName, lpClassName, NULL); - if(!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - } - else - ClassName = (LPWSTR)lpClassName; - - Result = (BOOL)NtUserUnregisterClass((LPCWSTR)ClassName, hInstance, 0); - - if(ClassName && !IS_ATOM(lpClassName)) - HEAP_free(ClassName); - - return Result; + UNICODE_STRING ClassName = {0}; + NTSTATUS Status; + BOOL Ret; + + if (!IS_ATOM(lpClassName)) + { + Status = HEAP_strdupAtoW(&ClassName.Buffer, lpClassName, NULL); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + RtlInitUnicodeString(&ClassName, + ClassName.Buffer); + } + else + ClassName.Buffer = (PWSTR)((ULONG_PTR)lpClassName); + + Ret = NtUserUnregisterClass(&ClassName, + hInstance); + + if(!IS_ATOM(lpClassName) && ClassName.Buffer != NULL) + HEAP_free(ClassName.Buffer); + + return Ret; } @@ -943,7 +913,18 @@ LPCWSTR lpClassName, HINSTANCE hInstance) { - return (BOOL)NtUserUnregisterClass(lpClassName, hInstance, 0); + UNICODE_STRING ClassName = {0}; + + if (!IS_ATOM(lpClassName)) + { + RtlInitUnicodeString(&ClassName, + lpClassName); + } + else + ClassName.Buffer = (PWSTR)((ULONG_PTR)lpClassName); + + return NtUserUnregisterClass(&ClassName, + hInstance); } /* EOF */ Modified: trunk/reactos/dll/win32/user32/windows/message.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/windows/me…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c (original) +++ trunk/reactos/dll/win32/user32/windows/message.c Wed Apr 5 12:05:55 2006 @@ -951,6 +951,7 @@ return FALSE; } Result = WndProc(AnsiMsg.hwnd, AnsiMsg.message, AnsiMsg.wParam, AnsiMsg.lParam); + if (! MsgiUnicodeToAnsiReply(&AnsiMsg, &UnicodeMsg, &Result)) { return FALSE; @@ -991,6 +992,7 @@ } Result = WndProc(UnicodeMsg.hwnd, UnicodeMsg.message, UnicodeMsg.wParam, UnicodeMsg.lParam); + if (! MsgiAnsiToUnicodeReply(&UnicodeMsg, &AnsiMsg, &Result)) { return FALSE; @@ -1010,20 +1012,19 @@ WPARAM wParam, LPARAM lParam) { - BOOL IsHandle; - WndProcHandle wphData; + WNDPROC_INFO wpInfo; if (lpPrevWndFunc == NULL) - lpPrevWndFunc = (WNDPROC)NtUserGetWindowLong(hWnd, GWL_WNDPROC, FALSE); - - IsHandle = NtUserDereferenceWndProcHandle(lpPrevWndFunc,&wphData); - if (! IsHandle) + lpPrevWndFunc = (WNDPROC)NtUserGetWindowLong(hWnd, GWLP_WNDPROC, FALSE); + + if (!NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc, + &wpInfo)) { return IntCallWindowProcA(TRUE, lpPrevWndFunc, hWnd, Msg, wParam, lParam); } else { - return IntCallWindowProcA(! wphData.IsUnicode, wphData.WindowProc, + return IntCallWindowProcA(!wpInfo.IsUnicode, wpInfo.WindowProc, hWnd, Msg, wParam, lParam); } } @@ -1039,17 +1040,16 @@ WPARAM wParam, LPARAM lParam) { - BOOL IsHandle; - WndProcHandle wphData; - - IsHandle = NtUserDereferenceWndProcHandle(lpPrevWndFunc,&wphData); - if (! IsHandle) + WNDPROC_INFO wpInfo; + + if (!NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc, + &wpInfo)) { return IntCallWindowProcW(FALSE, lpPrevWndFunc, hWnd, Msg, wParam, lParam); } else { - return IntCallWindowProcW(! wphData.IsUnicode, wphData.WindowProc, + return IntCallWindowProcW(!wpInfo.IsUnicode, wpInfo.WindowProc, hWnd, Msg, wParam, lParam); } } Modified: trunk/reactos/dll/win32/user32/windows/window.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/windows/wi…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/window.c (original) +++ trunk/reactos/dll/win32/user32/windows/window.c Wed Apr 5 12:05:55 2006 @@ -289,8 +289,8 @@ { wce.cbSize = sizeof(WNDCLASSEXW); if(GetClassInfoExW(hInstance, lpClassName, &wce) && wce.lpszMenuName) - { - hMenu = LoadMenuW(hInstance, wce.lpszMenuName); + {DbgPrint("LoadingMenu 0x%p %d\n", wce.lpszMenuName, IS_INTRESOURCE(wce.lpszMenuName)); + hMenu = LoadMenuW(hInstance, wce.lpszMenuName);DbgPrint("Loaded menu: 0x%p\n", hMenu); } } @@ -1449,7 +1449,7 @@ STDCALL GetFocus(VOID) { - return (HWND)NtUserGetThreadState(0); + return (HWND)NtUserGetThreadState(THREADSTATE_FOCUSWINDOW); } /* Modified: trunk/reactos/include/ndk/pstypes.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=2…
============================================================================== --- trunk/reactos/include/ndk/pstypes.h (original) +++ trunk/reactos/include/ndk/pstypes.h Wed Apr 5 12:05:55 2006 @@ -424,7 +424,7 @@ ULONG LastErrorValue; /* 34h */ ULONG CountOfOwnedCriticalSections; /* 38h */ PVOID CsrClientThread; /* 3Ch */ - struct _W32THREAD* Win32ThreadInfo; /* 40h */ + PVOID Win32ThreadInfo; /* 40h */ ULONG User32Reserved[0x1A]; /* 44h */ ULONG UserReserved[5]; /* ACh */ PVOID WOW32Reserved; /* C0h */ Modified: trunk/reactos/include/reactos/probe.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/reactos/probe.h?rev…
============================================================================== --- trunk/reactos/include/reactos/probe.h (original) +++ trunk/reactos/include/reactos/probe.h Wed Apr 5 12:05:55 2006 @@ -8,6 +8,14 @@ static const UNICODE_STRING __emptyUnicodeString = {0}; static const LARGE_INTEGER __emptyLargeInteger = {{0, 0}}; static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}}; + +#if defined(_WIN32K_) +/* + * NOTE: NTOSKRNL unfortunately doesn't export RtlRaiseStatus! + */ +VOID NTAPI W32kRaiseStatus(NTSTATUS Status); +#define RtlRaiseStatus W32kRaiseStatus +#endif /* * NOTE: Alignment of the pointers is not verified! Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/include/reactos/win32k/ntus…
============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h Wed Apr 5 12:05:55 2006 @@ -1,6 +1,75 @@ #ifndef __WIN32K_NTUSER_H #define __WIN32K_NTUSER_H +struct _W32PROCESSINFO; +struct _W32THREADINFO; + +typedef struct _DESKTOP +{ + HANDLE hKernelHeap; + WCHAR szDesktopName[1]; +} DESKTOP, *PDESKTOP; + +typedef struct _CALLPROC +{ + struct _W32PROCESSINFO *pi; + WNDPROC WndProc; + BOOL Unicode : 1; +} CALLPROC, *PCALLPROC; + +typedef struct _WINDOWCLASS +{ + struct _WINDOWCLASS *Next; + struct _WINDOWCLASS *Clone; + struct _WINDOWCLASS *Base; + PDESKTOP Desktop; + RTL_ATOM Atom; + ULONG Windows; + + UINT Style; + WNDPROC WndProc; + union + { + WNDPROC WndProcExtra; + PCALLPROC CallProc; + }; + INT ClsExtra; + INT WndExtra; + HINSTANCE hInstance; + HANDLE hIcon; /* FIXME - Use pointer! */ + HANDLE hIconSm; /* FIXME - Use pointer! */ + HANDLE hCursor; /* FIXME - Use pointer! */ + HBRUSH hbrBackground; + HANDLE hMenu; /* FIXME - Use pointer! */ + PWSTR MenuName; + PSTR AnsiMenuName; + + ULONG_PTR ClassExtraDataOffset; + + BOOL Destroying : 1; + BOOL Unicode : 1; + BOOL System : 1; + BOOL Global : 1; +} WINDOWCLASS, *PWINDOWCLASS; + +typedef struct _W32PROCESSINFO +{ + PVOID UserHandleTable; + PWINDOWCLASS LocalClassList; + PWINDOWCLASS GlobalClassList; + PWINDOWCLASS SystemClassList; +} W32PROCESSINFO, *PW32PROCESSINFO; + +typedef struct _W32THREADINFO +{ + PW32PROCESSINFO pi; /* [USER] */ + PW32PROCESSINFO kpi; /* [KERNEL] */ + PDESKTOP Desktop; + ULONG_PTR DesktopHeapDelta; +} W32THREADINFO, *PW32THREADINFO; + +PW32THREADINFO GetW32ThreadInfo(VOID); +PW32PROCESSINFO GetW32ProcessInfo(VOID); DWORD NTAPI @@ -196,8 +265,8 @@ ULONG NTAPI NtUserGetSystemMetrics(ULONG Index); -DWORD NTAPI -NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi); +ULONG_PTR NTAPI +NtUserGetClassLong(HWND hWnd, INT Offset, BOOL Ansi); LONG NTAPI NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi); @@ -785,18 +854,17 @@ NtUserGetCaretPos( LPPOINT lpPoint); -DWORD NTAPI -NtUserGetClassInfo(HINSTANCE hInst, - LPCWSTR str, +BOOL NTAPI +NtUserGetClassInfo(HINSTANCE hInstance, + PUNICODE_STRING ClassName, LPWNDCLASSEXW wcex, - BOOL Ansi, - DWORD unknown3); - -DWORD + BOOL Ansi); + +INT NTAPI NtUserGetClassName(HWND hWnd, - LPWSTR lpClassName, - ULONG nMaxCount); + PUNICODE_STRING ClassName, + BOOL Ansi); HANDLE NTAPI @@ -1041,6 +1109,7 @@ DWORD dwThreadId, DWORD Unknown1); +#define THREADSTATE_GETTHREADINFO (0) #define THREADSTATE_FOCUSWINDOW (1) #define THREADSTATE_INSENDMESSAGE (2) DWORD @@ -1355,14 +1424,12 @@ #define REGISTERCLASS_ALL (REGISTERCLASS_ANSI | REGISTERCLASS_SYSTEM) RTL_ATOM NTAPI -NtUserRegisterClassExWOW( +NtUserRegisterClassEx( CONST WNDCLASSEXW* lpwcx, PUNICODE_STRING ClassName, - PUNICODE_STRING ClassNameCopy, PUNICODE_STRING MenuName, WNDPROC wpExtra, DWORD Flags, - DWORD Unknown7, HMENU hMenu); BOOL @@ -1470,11 +1537,11 @@ HWND NTAPI NtUserGetCapture(VOID); -DWORD NTAPI +ULONG_PTR NTAPI NtUserSetClassLong( HWND hWnd, - DWORD Offset, - LONG dwNewLong, + INT Offset, + ULONG_PTR dwNewLong, BOOL Ansi ); @@ -1840,9 +1907,8 @@ BOOL NTAPI NtUserUnregisterClass( - LPCWSTR ClassNameOrAtom, - HINSTANCE hInstance, - DWORD Unknown); + PUNICODE_STRING ClassNameOrAtom, + HINSTANCE hInstance); BOOL NTAPI @@ -1951,15 +2017,15 @@ HWND NTAPI NtUserGetLastActivePopup(HWND hWnd); -typedef struct _WndProcHandle + +typedef struct _WNDPROC_INFO { - WNDPROC WindowProc; - BOOL IsUnicode; - HANDLE ProcessID; -} WndProcHandle; + WNDPROC WindowProc; + BOOL IsUnicode; +} WNDPROC_INFO, *PWNDPROC_INFO; -DWORD NTAPI -NtUserDereferenceWndProcHandle(WNDPROC wpHandle, WndProcHandle *Data); +BOOL NTAPI +NtUserDereferenceWndProcHandle(IN HANDLE wpHandle, OUT PWNDPROC_INFO wpInfo); VOID NTAPI NtUserManualGuiCheck(LONG Check); Modified: trunk/reactos/lib/rtl/heap.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=21460&r1…
============================================================================== --- trunk/reactos/lib/rtl/heap.c (original) +++ trunk/reactos/lib/rtl/heap.c Wed Apr 5 12:05:55 2006 @@ -311,7 +311,7 @@ } else { - Status = NtAllocateVirtualMemory(NtCurrentProcess(), + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &address, 0, &commitsize, @@ -570,13 +570,24 @@ /* Initialize critical section */ - RtlInitializeHeapLock( &heap->critSection ); + if (RtlpGetMode() == UserMode) + { + RtlInitializeHeapLock( &heap->critSection ); + } } /* Commit memory */ if (heap->commitRoutine) { - Status = heap->commitRoutine(heap, &address, &commitSize); + if (subheap != (SUBHEAP *)heap) + { + Status = heap->commitRoutine(heap, &address, &commitSize); + } + else + { + /* the caller is responsible for committing the first page! */ + Status = STATUS_SUCCESS; + } } else { Modified: trunk/reactos/subsystems/win32/win32k/include/class.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/class.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/class.h Wed Apr 5 12:05:55 2006 @@ -4,28 +4,19 @@ #define IS_ATOM(x) \ (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000)) -typedef struct _WNDCLASS_OBJECT -{ - UINT cbSize; - LONG refs; /* windows using this class (is 0 after class creation) */ - UINT style; - WNDPROC lpfnWndProcA; - WNDPROC lpfnWndProcW; - int cbClsExtra; - int cbWndExtra; - HANDLE hInstance; - HICON hIcon; - HCURSOR hCursor; - HBRUSH hbrBackground; - HMENU hMenu; - UNICODE_STRING lpszMenuName; - RTL_ATOM Atom; - HICON hIconSm; - BOOL Unicode; - BOOL Global; - LIST_ENTRY ListEntry; /* linked into owning process */ - PCHAR ExtraData; -} WNDCLASS_OBJECT, *PWNDCLASS_OBJECT; +VOID +DestroyCallProc(IN PDESKTOP Desktop, + IN OUT PCALLPROC CallProc); + +PCALLPROC +CloneCallProc(IN PDESKTOP Desktop, + IN PCALLPROC CallProc); + +PCALLPROC +CreateCallProc(IN PDESKTOP Desktop, + IN WNDPROC WndProc, + IN BOOL Unicode, + IN PW32PROCESSINFO pi); NTSTATUS FASTCALL InitClassImpl(VOID); @@ -33,32 +24,45 @@ NTSTATUS FASTCALL CleanupClassImpl(VOID); -void FASTCALL DestroyProcessClasses(PW32PROCESS Process ); +BOOL +UserGetCallProcInfo(IN HANDLE hCallProc, + OUT PWNDPROC_INFO wpInfo); -__inline VOID FASTCALL -ClassDerefObject(PWNDCLASS_OBJECT Class); +void FASTCALL +DestroyProcessClasses(PW32PROCESS Process ); -__inline VOID FASTCALL -ClassRefObject(PWNDCLASS_OBJECT Class); +PWINDOWCLASS +IntReferenceClass(IN PWINDOWCLASS BaseClass, + IN PDESKTOP Desktop); -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByAtom( - RTL_ATOM Atom, - HINSTANCE hInstance); +VOID +IntDereferenceClass(IN OUT PWINDOWCLASS Class, + IN PDESKTOP Desktop, + IN PW32PROCESSINFO pi); -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByName( - LPCWSTR ClassName, - HINSTANCE hInstance); +RTL_ATOM +UserRegisterClass(IN CONST WNDCLASSEXW* lpwcx, + IN PUNICODE_STRING ClassName, + IN PUNICODE_STRING MenuName, + IN HANDLE hMenu, + IN WNDPROC wpExtra, + IN DWORD dwFlags); -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByNameOrAtom( - LPCWSTR ClassNameOrAtom, - HINSTANCE hInstance); +BOOL +UserUnregisterClass(IN PUNICODE_STRING ClassName, + IN HINSTANCE hInstance); -struct _WINDOW_OBJECT; -ULONG FASTCALL -IntGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset, BOOL Ansi); +ULONG_PTR +UserGetClassLongPtr(IN PWINDOWCLASS Class, + IN INT Index, + IN BOOL Ansi); + +RTL_ATOM +IntGetClassAtom(IN PUNICODE_STRING ClassName, + IN HINSTANCE hInstance OPTIONAL, + IN PW32PROCESSINFO pi OPTIONAL, + OUT PWINDOWCLASS *BaseClass OPTIONAL, + OUT PWINDOWCLASS **Link OPTIONAL); #endif /* _WIN32K_CLASS_H */ Modified: trunk/reactos/subsystems/win32/win32k/include/desktop.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/desktop.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/desktop.h Wed Apr 5 12:05:55 2006 @@ -6,8 +6,6 @@ typedef struct _DESKTOP_OBJECT { - PVOID DesktopHeap; /* points to kmode memory! */ - CSHORT Type; CSHORT Size; LIST_ENTRY ListEntry; @@ -26,11 +24,15 @@ PVOID BlockInputThread; LIST_ENTRY ShellHookWindows; + + HANDLE hDesktopHeap; + PSECTION_OBJECT DesktopHeapSection; + PDESKTOP DesktopInfo; } DESKTOP_OBJECT, *PDESKTOP_OBJECT; extern PDESKTOP_OBJECT InputDesktop; extern HDESK InputDesktopHandle; -extern PWNDCLASS_OBJECT DesktopWindowClass; +extern PWINDOWCLASS DesktopWindowClass; extern HDC ScreenDeviceContext; extern BOOL g_PaintDesktopVersion; @@ -91,6 +93,8 @@ HDESK FASTCALL IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject); +BOOL IntSetThreadDesktop(IN PDESKTOP_OBJECT DesktopObject); + NTSTATUS FASTCALL IntValidateDesktopHandle( HDESK Desktop, @@ -115,6 +119,113 @@ #define IntIsActiveDesktop(Desktop) \ ((Desktop)->WindowStation->ActiveDesktop == (Desktop)) +static __inline PVOID +DesktopHeapAlloc(IN PDESKTOP Desktop, + IN SIZE_T Bytes) +{ + return RtlAllocateHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + Bytes); +} + +static __inline BOOL +DesktopHeapFree(IN PDESKTOP Desktop, + IN PVOID lpMem) +{ + return RtlFreeHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + lpMem); +} + +static __inline PVOID +DesktopHeapReAlloc(IN PDESKTOP Desktop, + IN PVOID lpMem, + IN SIZE_T Bytes) +{ +#if 0 + /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */ + return RtlReAllocateHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + lpMem, + Bytes); +#else + SIZE_T PrevSize; + PVOID pNew; + + PrevSize = RtlSizeHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + lpMem); + + if (PrevSize == Bytes) + return lpMem; + + pNew = RtlAllocateHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + Bytes); + if (pNew != NULL) + { + if (PrevSize < Bytes) + Bytes = PrevSize; + + RtlCopyMemory(pNew, + lpMem, + Bytes); + + RtlFreeHeap(Desktop->hKernelHeap, + HEAP_NO_SERIALIZE, + lpMem); + } + + return pNew; +#endif +} + +static __inline ULONG_PTR +DesktopHeapGetUserDelta(VOID) +{ + PW32HEAP_USER_MAPPING Mapping; + HANDLE hDesktopHeap; + ULONG_PTR Delta = 0; + + ASSERT(PsGetWin32Thread()->Desktop != NULL); + hDesktopHeap = PsGetWin32Thread()->Desktop->hDesktopHeap; + + Mapping = PsGetWin32Process()->HeapMappings.Next; + while (Mapping != NULL) + { + if (Mapping->UserMapping == (PVOID)hDesktopHeap) + { + Delta = (ULONG_PTR)Mapping->KernelMapping - (ULONG_PTR)Mapping->UserMapping; + break; + } + + Mapping = Mapping->Next; + } + + return Delta; +} + +static __inline PVOID +DesktopHeapAddressToUser(IN PDESKTOP Desktop, + PVOID lpMem) +{ + PW32HEAP_USER_MAPPING Mapping; + + Mapping = PsGetWin32Process()->HeapMappings.Next; + while (Mapping != NULL) + { + if (Mapping->KernelMapping == (PVOID)Desktop->hKernelHeap) + { + return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)Desktop->hKernelHeap) + + (ULONG_PTR)Mapping->UserMapping); + } + + Mapping = Mapping->Next; + } + + return NULL; +} + #endif /* _WIN32K_DESKTOP_H */ /* EOF */ Modified: trunk/reactos/subsystems/win32/win32k/include/object.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/object.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/object.h Wed Apr 5 12:05:55 2006 @@ -45,7 +45,7 @@ otCursorIcon, otHook, otMonitor, - otClass //fixme: remove + otCallProc } USER_OBJECT_TYPE; @@ -125,6 +125,8 @@ \ } +HANDLE FASTCALL ObmObjectToHandle(PVOID obj); + VOID FASTCALL CreateStockObjects (VOID); VOID FASTCALL CreateSysColorObjects (VOID); Modified: trunk/reactos/subsystems/win32/win32k/include/userfuncs.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/userfuncs.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/userfuncs.h Wed Apr 5 12:05:55 2006 @@ -75,7 +75,7 @@ /******************** HANDLE.C ***************/ -extern USER_HANDLE_TABLE gHandleTable; +extern PUSER_HANDLE_TABLE gHandleTable; PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle ); VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes); Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/win32.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/win32.h Wed Apr 5 12:05:55 2006 @@ -15,10 +15,18 @@ BOOLEAN IsExiting; SINGLE_LIST_ENTRY ReferencesList; + PW32THREADINFO ThreadInfo; } W32THREAD, *PW32THREAD; #include <poppack.h> +typedef struct _W32HEAP_USER_MAPPING +{ + struct _W32HEAP_USER_MAPPING *Next; + PVOID KernelMapping; + PVOID UserMapping; + ULONG Count; +} W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING; typedef struct _W32PROCESS { @@ -32,6 +40,9 @@ ULONG Flags; LONG GDIObjects; LONG UserObjects; + + W32HEAP_USER_MAPPING HeapMappings; + PW32PROCESSINFO ProcessInfo; } W32PROCESS, *PW32PROCESS; Modified: trunk/reactos/subsystems/win32/win32k/include/window.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/window.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/window.h Wed Apr 5 12:05:55 2006 @@ -26,8 +26,21 @@ typedef struct _WINDOW_OBJECT { + /* Pointer to the thread information */ + PW32THREADINFO ti; + /* Pointer to the desktop */ + PDESKTOP Desktop; + union + { + /* Pointer to a call procedure handle */ + PCALLPROC CallProc; + /* Extra Wnd proc (windows of system classes) */ + WNDPROC WndProcExtra; + }; + /* Indicates whether the window is derived from a system class */ + BOOL IsSystem; /* Pointer to the window class. */ - PWNDCLASS_OBJECT Class; + PWINDOWCLASS Class; /* Extended style. */ DWORD ExStyle; /* Window name. */ @@ -81,8 +94,7 @@ PWINDOW_SCROLLINFO Scroll; LONG UserData; BOOL Unicode; - WNDPROC WndProcA; - WNDPROC WndProcW; + WNDPROC WndProc; PETHREAD OwnerThread; HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ PINTERNALPOS InternalPos; @@ -190,10 +202,6 @@ BOOL FASTCALL IntIsWindowInDestroy(PWINDOW_OBJECT Window); -DWORD IntRemoveWndProcHandle(WNDPROC Handle); -DWORD IntRemoveProcessWndProcHandles(HANDLE ProcessID); -DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode); - BOOL FASTCALL IntShowOwnedPopups( PWINDOW_OBJECT owner, BOOL fShow ); Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mai…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/main/dllmain.c (original) +++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c Wed Apr 5 12:05:55 2006 @@ -33,6 +33,9 @@ PGDI_HANDLE_TABLE GdiHandleTable = NULL; PSECTION_OBJECT GdiTableSection = NULL; +HANDLE GlobalUserHeap = NULL; +PSECTION_OBJECT GlobalUserHeapSection = NULL; + extern ULONG_PTR Win32kSSDT[]; extern UCHAR Win32kSSPT[]; extern ULONG Win32kNumberOfSysCalls; @@ -69,7 +72,34 @@ if (Create) { + ULONG ViewSize = 0; + LARGE_INTEGER Offset; + PVOID UserBase = NULL; + NTSTATUS Status; + extern PSECTION_OBJECT GlobalUserHeapSection; DPRINT("Creating W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql()); + + /* map the global heap into the process */ + Offset.QuadPart = 0; + Status = MmMapViewOfSection(GlobalUserHeapSection, + PsGetCurrentProcess(), + &UserBase, + 0, + 0, + &Offset, + &ViewSize, + ViewUnmap, + SEC_NO_CHANGE, + PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */ + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to map the global heap! 0x%x\n", Status); + RETURN(Status); + } + Win32Process->HeapMappings.Next = NULL; + Win32Process->HeapMappings.KernelMapping = (PVOID)GlobalUserHeap; + Win32Process->HeapMappings.UserMapping = UserBase; + Win32Process->HeapMappings.Count = 1; InitializeListHead(&Win32Process->ClassList); @@ -95,7 +125,6 @@ else { DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql()); - IntRemoveProcessWndProcHandles((HANDLE)Process->UniqueProcessId); IntCleanupMenus(Process, Win32Process); IntCleanupCurIcons(Process, Win32Process); IntEngCleanupDriverObjs(Process, Win32Process); @@ -114,6 +143,12 @@ if(LogonProcess == Win32Process) { LogonProcess = NULL; + } + + if (Win32Process->ProcessInfo != NULL) + { + UserHeapFree(Win32Process->ProcessInfo); + Win32Process->ProcessInfo = NULL; } } @@ -198,17 +233,25 @@ if (hDesk != NULL) { + PDESKTOP_OBJECT DesktopObject; + Win32Thread->Desktop = NULL; Status = ObReferenceObjectByHandle(hDesk, 0, ExDesktopObjectType, KernelMode, - (PVOID*)&Win32Thread->Desktop, + (PVOID*)&DesktopObject, NULL); NtClose(hDesk); - if(!NT_SUCCESS(Status)) + if(NT_SUCCESS(Status)) + { + if (!IntSetThreadDesktop(DesktopObject)) + { + DPRINT1("Unable to set thread desktop\n"); + } + } + else { DPRINT1("Unable to reference thread desktop handle 0x%x\n", hDesk); - Win32Thread->Desktop = NULL; } } } @@ -234,11 +277,15 @@ IntBlockInput(Win32Thread, FALSE); MsqDestroyMessageQueue(Win32Thread->MessageQueue); IntCleanupThreadCallbacks(Win32Thread); - if(Win32Thread->Desktop != NULL) - { - ObDereferenceObject(Win32Thread->Desktop); - } - + + IntSetThreadDesktop(NULL); + + if (Win32Thread->ThreadInfo != NULL) + { + UserHeapFree(Win32Thread->ThreadInfo); + Win32Thread->ThreadInfo = NULL; + } + /* cleanup user object references stack */ e = PopEntryList(&Win32Thread->ReferencesList); while (e) @@ -309,6 +356,7 @@ NTSTATUS Status; BOOLEAN Result; W32_CALLOUT_DATA CalloutData; + PVOID GlobalUserHeapBase = NULL; /* * Register user mode call interface @@ -342,6 +390,16 @@ */ PsEstablishWin32Callouts(&CalloutData); + GlobalUserHeap = UserCreateHeap(&GlobalUserHeapSection, + &GlobalUserHeapBase, + 1 * 1024 * 1024); /* FIXME - 1 MB for now... */ + if (GlobalUserHeap == NULL) + { + DPRINT1("Failed to initialize the global heap!\n"); + return STATUS_UNSUCCESSFUL; + } + + Status = InitUserImpl(); if (!NT_SUCCESS(Status)) { Modified: trunk/reactos/subsystems/win32/win32k/misc/err.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mis…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/misc/err.c (original) +++ trunk/reactos/subsystems/win32/win32k/misc/err.c Wed Apr 5 12:05:55 2006 @@ -61,4 +61,22 @@ return 0; } +VOID +NTAPI +W32kRaiseStatus(NTSTATUS Status) +{ + EXCEPTION_RECORD ExceptionRecord; + + /* Create an exception record */ + ExceptionRecord.ExceptionCode = Status; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.NumberParameters = 0; + ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE; + + RtlRaiseException(&ExceptionRecord); + + /* If we returned, raise a status */ + W32kRaiseStatus(Status); +} + /* EOF */ Added: trunk/reactos/subsystems/win32/win32k/misc/usrheap.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mis…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/misc/usrheap.c (added) +++ trunk/reactos/subsystems/win32/win32k/misc/usrheap.c Wed Apr 5 12:05:55 2006 @@ -1,0 +1,216 @@ +/* + * ReactOS W32 Subsystem + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <w32k.h> + +#define NDEBUG +#include <debug.h> + + +static NTSTATUS NTAPI +IntUserHeapCommitRoutine(IN PVOID Base, + IN OUT PVOID *CommitAddress, + IN OUT PSIZE_T CommitSize) +{ + PW32PROCESS W32Process; + PW32HEAP_USER_MAPPING Mapping; + PVOID UserBase = NULL; + NTSTATUS Status; + SIZE_T Delta = (SIZE_T)((ULONG_PTR)(*CommitAddress) - (ULONG_PTR)Base); + + W32Process = PsGetWin32Process(); + + if (W32Process != NULL) + { + /* search for the mapping */ + Mapping = &W32Process->HeapMappings; + while (Mapping != NULL) + { + if (Mapping->KernelMapping == Base) + { + UserBase = Mapping->UserMapping; + break; + } + + Mapping = Mapping->Next; + } + + ASSERT(UserBase != NULL); + } + else + { + ULONG ViewSize = 0; + LARGE_INTEGER Offset; + extern PSECTION_OBJECT GlobalUserHeapSection; + + /* HACK: This needs to be handled during startup only... */ + ASSERT(Base == (PVOID)GlobalUserHeap); + + /* temporarily map it into user space */ + Offset.QuadPart = 0; + Status = MmMapViewOfSection(GlobalUserHeapSection, + PsGetCurrentProcess(), + &UserBase, + 0, + 0, + &Offset, + &ViewSize, + ViewUnmap, + SEC_NO_CHANGE, + PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */ + + if (!NT_SUCCESS(Status)) + return Status; + } + + /* commit! */ + UserBase = (PVOID)((ULONG_PTR)UserBase + Delta); + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &UserBase, + 0, + CommitSize, + MEM_COMMIT, + PAGE_EXECUTE_READ); + if (NT_SUCCESS(Status)) + { + *CommitAddress = (PVOID)((ULONG_PTR)UserBase + Delta); + } + + if (W32Process == NULL) + { + MmUnmapViewOfSection(PsGetCurrentProcess(), + UserBase); + } + + return Status; +} + +static HANDLE +IntUserHeapCreate(IN PSECTION_OBJECT SectionObject, + IN PVOID *SystemMappedBase, + IN ULONG HeapSize) +{ + PVOID MappedView = NULL; + LARGE_INTEGER Offset; + ULONG ViewSize = PAGE_SIZE; + RTL_HEAP_PARAMETERS Parameters = {0}; + HANDLE hHeap; + NTSTATUS Status; + + Offset.QuadPart = 0; + + /* Commit the first page before creating the heap! */ + Status = MmMapViewOfSection(SectionObject, + PsGetCurrentProcess(), + &MappedView, + 0, + 0, + &Offset, + &ViewSize, + ViewUnmap, + SEC_NO_CHANGE, + PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */ + if (!NT_SUCCESS(Status)) + return NULL; + + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &MappedView, + 0, + &ViewSize, + MEM_COMMIT, + PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */ + + MmUnmapViewOfSection(PsGetCurrentProcess(), + MappedView); + + if (!NT_SUCCESS(Status)) + return NULL; + + /* Create the heap, don't serialize in kmode! The caller is responsible + to synchronize the heap! */ + Parameters.Length = sizeof(Parameters); + Parameters.InitialCommit = PAGE_SIZE; + Parameters.InitialReserve = (SIZE_T)HeapSize; + Parameters.CommitRoutine = IntUserHeapCommitRoutine; + + hHeap = RtlCreateHeap(HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, + *SystemMappedBase, + (SIZE_T)HeapSize, + PAGE_SIZE, + NULL, + &Parameters); + + return hHeap; +} + +HANDLE +UserCreateHeap(OUT PSECTION_OBJECT *SectionObject, + IN OUT PVOID *SystemBase, + IN ULONG HeapSize) +{ + LARGE_INTEGER SizeHeap; + HANDLE hHeap = NULL; + NTSTATUS Status; + + SizeHeap.QuadPart = HeapSize; + + /* create the section and map it into session space */ + Status = MmCreateSection((PVOID*)SectionObject, + SECTION_ALL_ACCESS, + NULL, + &SizeHeap, + PAGE_EXECUTE_READWRITE, /* would prefer PAGE_READWRITE, but thanks to RTL heaps... */ + SEC_RESERVE, + NULL, + NULL); + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + + Status = MmMapViewInSystemSpace(*SectionObject, + SystemBase, + &HeapSize); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(*SectionObject); + *SectionObject = NULL; + + SetLastNtError(Status); + return FALSE; + } + + /* create the heap */ + hHeap = IntUserHeapCreate(*SectionObject, + SystemBase, + HeapSize); + + if (hHeap == NULL) + { + ObDereferenceObject(*SectionObject); + *SectionObject = NULL; + + SetLastNtError(STATUS_UNSUCCESSFUL); + } + + return hHeap; +} Modified: trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c Wed Apr 5 12:05:55 2006 @@ -80,7 +80,7 @@ return NULL; } - Accel= UserGetObject(&gHandleTable, hAccel, otAccel); + Accel= UserGetObject(gHandleTable, hAccel, otAccel); if (!Accel) { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); @@ -344,7 +344,7 @@ Entries, EntriesCount); UserEnterExclusive(); - Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); + Accel = ObmCreateObject(gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); if (Accel == NULL) { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/class.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c Wed Apr 5 12:05:55 2006 @@ -1,6 +1,6 @@ /* * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * Copyright (C) 1998 - 2006 ReactOS Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,9 +22,12 @@ * PROJECT: ReactOS kernel * PURPOSE: Window classes * FILE: subsys/win32k/ntuser/class.c - * PROGRAMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net) + * PROGRAMER: Thomas Weidenmueller <w3seek(a)reactos.com> * REVISION HISTORY: * 06-06-2001 CSH Created + * + * NOTE: Should classes created on a desktop heap be moved to the shared + * heap when the desktop is destroyed, or should they be unregistered? */ /* INCLUDES ******************************************************************/ @@ -33,7 +36,96 @@ #define NDEBUG #include <debug.h> -/* FUNCTIONS *****************************************************************/ +/* CALLPROC ******************************************************************/ + +VOID +DestroyCallProc(IN PDESKTOP Desktop, + IN OUT PCALLPROC CallProc) +{ + /* FIXME - use new object manager! */ + HANDLE Handle = ObmObjectToHandle(CallProc); + + ObmDeleteObject(Handle, + otCallProc); +} + +PCALLPROC +CloneCallProc(IN PDESKTOP Desktop, + IN PCALLPROC CallProc) +{ + PCALLPROC NewCallProc; + HANDLE Handle; + + /* FIXME - use new object manager! */ + NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable, + &Handle, + otCallProc, + sizeof(CALLPROC)); + if (NewCallProc != NULL) + { + NewCallProc->pi = CallProc->pi; + NewCallProc->WndProc = CallProc->WndProc; + NewCallProc->Unicode = CallProc->Unicode; + } + + return NewCallProc; +} + +PCALLPROC +CreateCallProc(IN PDESKTOP Desktop, + IN WNDPROC WndProc, + IN BOOL Unicode, + IN PW32PROCESSINFO pi) +{ + PCALLPROC NewCallProc; + HANDLE Handle; + + /* FIXME - use new object manager! */ + NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable, + &Handle, + otCallProc, + sizeof(CALLPROC)); + if (NewCallProc != NULL) + { + NewCallProc->pi = pi; + NewCallProc->WndProc = WndProc; + NewCallProc->Unicode = Unicode; + } + + return NewCallProc; +} + +BOOL +UserGetCallProcInfo(IN HANDLE hCallProc, + OUT PWNDPROC_INFO wpInfo) +{ + PCALLPROC CallProc; + + /* NOTE: Accessing the WNDPROC_INFO structure may raise an exception! */ + + /* FIXME - use new object manager! */ + CallProc = UserGetObject(gHandleTable, + hCallProc, + otCallProc); + if (CallProc == NULL) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (CallProc->pi != GetW32ProcessInfo()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + wpInfo->WindowProc = CallProc->WndProc; + wpInfo->IsUnicode = CallProc->Unicode; + + return TRUE; +} + +/* WINDOWCLASS ***************************************************************/ NTSTATUS FASTCALL InitClassImpl(VOID) @@ -47,398 +139,1673 @@ return(STATUS_SUCCESS); } - -__inline VOID FASTCALL -ClassDerefObject(PWNDCLASS_OBJECT Class) -{ - ASSERT(Class->refs >= 1); - Class->refs--; -} - - -__inline VOID FASTCALL -ClassRefObject(PWNDCLASS_OBJECT Class) -{ - ASSERT(Class->refs >= 0); - Class->refs++; -} - - -VOID FASTCALL DestroyClass(PWNDCLASS_OBJECT Class) -{ -#if defined(DBG) || defined(KDBG) - if ( Class->refs != 0 ) - { - WCHAR AtomName[256]; - ULONG AtomNameLen = sizeof(AtomName); - RtlQueryAtomInAtomTable ( gAtomTable, Class->Atom, - NULL, NULL, AtomName, &AtomNameLen ); - DPRINT1("DestroyClass(): can't delete class = '%ws', b/c refs = %lu\n", AtomName, Class->refs ); - } -#endif - ASSERT(Class->refs == 0); - - RemoveEntryList(&Class->ListEntry); - if (Class->hMenu) - UserDestroyMenu(Class->hMenu); - RtlDeleteAtomFromAtomTable(gAtomTable, Class->Atom); - ExFreePool(Class); +static VOID +IntFreeClassMenuName(IN OUT PWINDOWCLASS Class) +{ + /* free the menu name, if it was changed and allocated */ + if (Class->MenuName != NULL && !IS_INTRESOURCE(Class->MenuName) && + Class->MenuName != (PWSTR)(Class + 1)) + { + UserHeapFree(Class->MenuName); + Class->MenuName = NULL; + Class->AnsiMenuName = NULL; + } +} + +static VOID +IntDestroyClass(IN OUT PWINDOWCLASS Class) +{ + /* there shouldn't be any clones anymore */ + + ASSERT(Class->Windows == 0); + + if (Class->Desktop != NULL) + { + ASSERT(Class->Clone == NULL); + } + else if (Class->Clone != NULL) + { + /* there must not be more than one clone! This can be the case + when the base class is on the shared heap */ + ASSERT(Class->Clone->Next == NULL); + + /* free the clone */ + IntDestroyClass(Class->Clone); + Class->Clone = NULL; + } + + if (Class->Base == Class) + { + /* destruct resources shared with clones */ + if (!Class->System && Class->CallProc != NULL) + { + DestroyCallProc(Class->Desktop, + Class->CallProc); + } + + IntFreeClassMenuName(Class); + } + + /* free the structure */ + if (Class->Desktop != NULL) + { + DesktopHeapFree(Class->Desktop, + Class); + } + else + { + UserHeapFree(Class); + } } /* clean all process classes. all process windows must cleaned first!! */ void FASTCALL DestroyProcessClasses(PW32PROCESS Process ) { - PWNDCLASS_OBJECT Class; - - while (!IsListEmpty(&Process->ClassList)) - { - Class = CONTAINING_RECORD(RemoveHeadList(&Process->ClassList), WNDCLASS_OBJECT, ListEntry); - DestroyClass(Class); - } -} - - - - -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByAtom(RTL_ATOM Atom, HINSTANCE hInstance) -{ - PWNDCLASS_OBJECT Class; - PW32PROCESS Process = PsGetWin32Process(); - - LIST_FOR_EACH(Class, &Process->ClassList, WNDCLASS_OBJECT, ListEntry) - { - if (Class->Atom != Atom) continue; - - if (!hInstance || Class->Global || Class->hInstance == hInstance) return Class; - } - - return NULL; -} - - -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByName(LPCWSTR ClassName, HINSTANCE hInstance) -{ - NTSTATUS Status; - RTL_ATOM Atom; - - if (!ClassName || !PsGetWin32Thread()->Desktop) - return FALSE; - - Status = RtlLookupAtomInAtomTable( - gAtomTable, - (LPWSTR)ClassName, - &Atom); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to lookup class atom (ClassName '%S')!\n", ClassName); - return FALSE; - } - - return ClassGetClassByAtom(Atom, hInstance); -} - - -PWNDCLASS_OBJECT FASTCALL -ClassGetClassByNameOrAtom(LPCWSTR ClassNameOrAtom, HINSTANCE hInstance) -{ - if (!ClassNameOrAtom) return NULL; - - if (IS_ATOM(ClassNameOrAtom)) - return ClassGetClassByAtom((RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance); - else - return ClassGetClassByName(ClassNameOrAtom, hInstance); -} - - -static -BOOL FASTCALL -IntRegisterClass( - CONST WNDCLASSEXW *lpwcx, - DWORD Flags, - WNDPROC wpExtra, - PUNICODE_STRING MenuName, - RTL_ATOM Atom, - HMENU hMenu) -{ - PWNDCLASS_OBJECT Class; - ULONG objectSize; - BOOL Global; - - ASSERT(lpwcx); - ASSERT(Atom); - ASSERT(lpwcx->hInstance); - - Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS); - - /* Check for double registration of the class. */ - Class = ClassGetClassByAtom(Atom, lpwcx->hInstance); - if (Class && Global == Class->Global) - { - /* can max have one class of each type (global/local) */ - SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS); - return(FALSE); - } - - objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra; - - //FIXME: allocate in session heap (or possibly desktop heap) - Class = ExAllocatePool(PagedPool, objectSize); - if (!Class) - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - return(FALSE); - } - RtlZeroMemory(Class, objectSize); - - Class->cbSize = lpwcx->cbSize; - Class->style = lpwcx->style; - Class->cbClsExtra = lpwcx->cbClsExtra; - Class->cbWndExtra = lpwcx->cbWndExtra; - Class->hInstance = lpwcx->hInstance; - Class->hIcon = lpwcx->hIcon; - Class->hCursor = lpwcx->hCursor; - Class->hMenu = hMenu; - Class->hbrBackground = lpwcx->hbrBackground; - Class->Unicode = !(Flags & REGISTERCLASS_ANSI); - Class->Global = Global; - Class->hIconSm = lpwcx->hIconSm; - Class->Atom = Atom; - - if (MenuName->Length == 0) - { - Class->lpszMenuName.Length = - Class->lpszMenuName.MaximumLength = 0; - Class->lpszMenuName.Buffer = MenuName->Buffer; - } - else - { - Class->lpszMenuName.Length = - Class->lpszMenuName.MaximumLength = MenuName->MaximumLength; - Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Class->lpszMenuName.MaximumLength, TAG_STRING); - - if (Class->lpszMenuName.Buffer == NULL) - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - return(FALSE); - } - - RtlCopyUnicodeString(&Class->lpszMenuName, MenuName); - } - - if (wpExtra == NULL) - { - if (Flags & REGISTERCLASS_ANSI) - { - Class->lpfnWndProcA = lpwcx->lpfnWndProc; - Class->lpfnWndProcW = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,FALSE); - } - else - { - Class->lpfnWndProcW = lpwcx->lpfnWndProc; - Class->lpfnWndProcA = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,TRUE); - } - } - else - { - if (Flags & REGISTERCLASS_ANSI) - { - Class->lpfnWndProcA = lpwcx->lpfnWndProc; - Class->lpfnWndProcW = wpExtra; - } - else - { - Class->lpfnWndProcW = lpwcx->lpfnWndProc; - Class->lpfnWndProcA = wpExtra; - } - } - - - - /* Extra class data */ - if (Class->cbClsExtra) - Class->ExtraData = (PCHAR)(Class + 1); - - if (Global) - { - /* global classes go last (incl. system classes) */ - InsertTailList(&PsGetWin32Process()->ClassList, &Class->ListEntry); - } - else - { - /* local classes have priority so we put them first */ - InsertHeadList(&PsGetWin32Process()->ClassList, &Class->ListEntry); - } - - return TRUE; -} - - -ULONG FASTCALL -IntGetClassLong(PWINDOW_OBJECT Window, ULONG Offset, BOOL Ansi) -{ - LONG Ret; - - if ((int)Offset >= 0) - { - DPRINT("GetClassLong(%x, %d)\n", Window->hSelf, Offset); - if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - Ret = *((LONG *)(Window->Class->ExtraData + Offset)); - DPRINT("Result: %x\n", Ret); - return Ret; - } - - switch (Offset) - { - case GCL_CBWNDEXTRA: - Ret = Window->Class->cbWndExtra; - break; - case GCL_CBCLSEXTRA: - Ret = Window->Class->cbClsExtra; - break; - case GCL_HBRBACKGROUND: - Ret = (ULONG)Window->Class->hbrBackground; - break; - case GCL_HCURSOR: - Ret = (ULONG)Window->Class->hCursor; - break; - case GCL_HICON: - Ret = (ULONG)Window->Class->hIcon; - break; - case GCL_HICONSM: - Ret = (ULONG)Window->Class->hIconSm; - break; - case GCL_HMODULE: - Ret = (ULONG)Window->Class->hInstance; - break; - case GCL_MENUNAME: - Ret = (ULONG)Window->Class->lpszMenuName.Buffer; - break; - case GCL_STYLE: - Ret = Window->Class->style; - break; - case GCL_WNDPROC: - if (Ansi) - { - Ret = (ULONG)Window->Class->lpfnWndProcA; - } - else - { - Ret = (ULONG)Window->Class->lpfnWndProcW; - } - break; - case GCW_ATOM: - Ret = Window->Class->Atom; - break; - default: - Ret = 0; - break; - } - return(Ret); -} - -static -void FASTCALL -co_IntSetClassLong(PWINDOW_OBJECT Window, ULONG Offset, LONG dwNewLong, BOOL Ansi) -{ - ASSERT_REFS_CO(Window); - - if ((int)Offset >= 0) - { - DPRINT("SetClassLong(%x, %d, %x)\n", Window->hSelf, Offset, dwNewLong); - if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return; - } - *((LONG *)(Window->Class->ExtraData + Offset)) = dwNewLong; - return; - } - - switch (Offset) - { - case GCL_CBWNDEXTRA: - Window->Class->cbWndExtra = dwNewLong; - break; - case GCL_CBCLSEXTRA: - Window->Class->cbClsExtra = dwNewLong; - break; - case GCL_HBRBACKGROUND: - Window->Class->hbrBackground = (HBRUSH)dwNewLong; - break; - case GCL_HCURSOR: - Window->Class->hCursor = (HCURSOR)dwNewLong; - break; - case GCL_HICON: - Window->Class->hIcon = (HICON)dwNewLong; - - if (!IntGetOwner(Window) && !IntGetParent(Window)) - { - co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf); - } - break; - case GCL_HICONSM: - Window->Class->hIconSm = (HICON)dwNewLong; - break; - case GCL_HMODULE: - Window->Class->hInstance = (HINSTANCE)dwNewLong; - break; - case GCL_MENUNAME: - if (Window->Class->lpszMenuName.MaximumLength) - RtlFreeUnicodeString(&Window->Class->lpszMenuName); - if (!IS_INTRESOURCE(dwNewLong)) - { - Window->Class->lpszMenuName.Length = - Window->Class->lpszMenuName.MaximumLength = ((PUNICODE_STRING)dwNewLong)->MaximumLength; - Window->Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Window->Class->lpszMenuName.MaximumLength, TAG_STRING); - RtlCopyUnicodeString(&Window->Class->lpszMenuName, (PUNICODE_STRING)dwNewLong); - } - else - { - Window->Class->lpszMenuName.Length = - Window->Class->lpszMenuName.MaximumLength = 0; - Window->Class->lpszMenuName.Buffer = (LPWSTR)dwNewLong; - } - break; - case GCL_STYLE: - Window->Class->style = dwNewLong; - break; - case GCL_WNDPROC: - if (Ansi) - { - Window->Class->lpfnWndProcA = (WNDPROC)dwNewLong; - Window->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE); - Window->Class->Unicode = FALSE; - } - else - { - Window->Class->lpfnWndProcW = (WNDPROC)dwNewLong; - Window->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE); - Window->Class->Unicode = TRUE; - } - break; - } -} + PWINDOWCLASS Class; + PW32PROCESSINFO pi = Process->ProcessInfo; + + if (pi != NULL) + { + /* free all local classes */ + Class = pi->LocalClassList; + while (Class != NULL) + { + pi->LocalClassList = Class->Next; + + ASSERT(Class->Base == Class); + IntDestroyClass(Class); + + Class = pi->LocalClassList; + } + + /* free all global classes */ + Class = pi->GlobalClassList; + while (Class != NULL) + { + pi->GlobalClassList = Class->Next; + + ASSERT(Class->Base == Class); + IntDestroyClass(Class); + + Class = pi->GlobalClassList; + } + + /* free all system classes */ + Class = pi->SystemClassList; + while (Class != NULL) + { + pi->SystemClassList = Class->Next; + + ASSERT(Class->Base == Class); + IntDestroyClass(Class); + + Class = pi->SystemClassList; + } + } +} + +static BOOL +IntRegisterClassAtom(IN PUNICODE_STRING ClassName, + OUT RTL_ATOM *pAtom) +{ + WCHAR szBuf[65]; + PWSTR AtomName; + NTSTATUS Status; + + if (ClassName->Length != 0) + { + /* FIXME - Don't limit to 64 characters! use SEH when allocating memory! */ + if (ClassName->Length / sizeof(WCHAR) >= sizeof(szBuf) / sizeof(szBuf[0])) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return (RTL_ATOM)0; + } + + RtlCopyMemory(szBuf, + ClassName->Buffer, + ClassName->Length); + szBuf[ClassName->Length / sizeof(WCHAR)] = UNICODE_NULL; + AtomName = szBuf; + } + else + AtomName = ClassName->Buffer; + + Status = RtlAddAtomToAtomTable(gAtomTable, + AtomName, + pAtom); + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + + return TRUE; +} + +static VOID +IntDeregisterClassAtom(IN RTL_ATOM Atom) +{ + RtlDeleteAtomFromAtomTable(gAtomTable, + Atom); +} + +static BOOL +IntSetClassAtom(IN OUT PWINDOWCLASS Class, + IN PUNICODE_STRING ClassName) +{ + RTL_ATOM Atom = (RTL_ATOM)0; + + /* update the base class first */ + Class = Class->Base; + + if (!IntRegisterClassAtom(ClassName, + &Atom)) + { + return FALSE; + } + + IntDeregisterClassAtom(Class->Atom); + + Class->Atom = Atom; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->Atom = Atom; + + Class = Class->Next; + } + + return TRUE; +} + +static WNDPROC +IntSetClassWndProc(IN OUT PWINDOWCLASS Class, + IN WNDPROC WndProc, + IN BOOL Ansi) +{ + WNDPROC Ret = Class->WndProc; + + if (Class->System) + { + DPRINT1("Attempted to change window procedure of system window class 0x%p!\n", Class->Atom); + SetLastWin32Error(ERROR_ACCESS_DENIED); + return NULL; + } + + /* update the base class first */ + Class = Class->Base; + + Class->Unicode = !Ansi; + Class->WndProc = WndProc; + if (Class->CallProc != NULL) + { + Class->CallProc->WndProc = WndProc; + Class->CallProc->Unicode = !Ansi; + } + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->Unicode = !Ansi; + Class->WndProc = WndProc; + + Class = Class->Next; + } + + return Ret; +} + +static PWINDOWCLASS +IntGetClassForDesktop(IN PWINDOWCLASS BaseClass, + IN PDESKTOP Desktop) +{ + SIZE_T ClassSize; + PWINDOWCLASS Class; + + ASSERT(Desktop != NULL); + ASSERT(BaseClass->Base == BaseClass); + + if (BaseClass->Desktop == Desktop) + { + /* it is most likely that a window is created on the same + desktop as the window class. */ + + return BaseClass; + } + + if (BaseClass->Desktop == NULL) + { + /* Classes are also located in the shared heap when the class + was created before the thread attached to a desktop. As soon + as a window is created for such a class located on the shared + heap, the class is cloned into the desktop heap on which the + window is created. */ + Class = NULL; + } + else + { + /* The user is asking for a class object on a different desktop, + try to find one! */ + Class = BaseClass->Clone; + while (Class != NULL) + { + if (Class->Desktop == Desktop) + { + ASSERT(Class->Base == BaseClass); + ASSERT(Class->Clone == NULL); + break; + } + + Class = Class->Next; + } + } + + if (Class == NULL) + { + /* The window is created on a different desktop, we need to + clone the class object to the desktop heap of the window! */ + ClassSize = (SIZE_T)BaseClass->ClassExtraDataOffset + + (SIZE_T)BaseClass->ClsExtra; + + Class = DesktopHeapAlloc(Desktop, + ClassSize); + if (Class != NULL) + { + /* simply clone the class */ + RtlCopyMemory(Class, + BaseClass, + ClassSize); + + /* update some pointers and link the class */ + Class->Next = BaseClass->Clone; + Class->Clone = NULL; + Class->Base = BaseClass; + Class->Desktop = Desktop; + Class->Windows = 0; + (void)InterlockedExchangePointer(&BaseClass->Clone, + Class); + } + else + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + } + } + + return Class; +} + +PWINDOWCLASS +IntReferenceClass(IN PWINDOWCLASS BaseClass, + IN PDESKTOP Desktop) +{ + PWINDOWCLASS Class; + + Class = IntGetClassForDesktop(BaseClass, + Desktop); + if (Class != NULL) + { + Class->Windows++; + } + + return Class; +} + +VOID +IntDereferenceClass(IN OUT PWINDOWCLASS Class, + IN PDESKTOP Desktop, + IN PW32PROCESSINFO pi) +{ + PWINDOWCLASS *PrevLink, BaseClass, CurrentClass; + + BaseClass = Class->Base; + + if (--Class->Windows == 0) + { + if (BaseClass == Class) + { + ASSERT(Class->Base == Class); + + /* check if there are clones of the class on other desktops, + link the first clone in if possible. If there are no clones + then leave the class on the desktop heap... */ + if (BaseClass->Clone != NULL) + { + PWINDOWCLASS NewBase = BaseClass->Clone; + + /* locate the base class and unlink it */ + if (BaseClass->System) + PrevLink = &pi->SystemClassList; + else if (BaseClass->Global) + PrevLink = &pi->GlobalClassList; + else + PrevLink = &pi->LocalClassList; + + CurrentClass = *PrevLink; + while (CurrentClass != BaseClass) + { + ASSERT(CurrentClass != NULL); + + PrevLink = &CurrentClass->Next; + CurrentClass = CurrentClass->Next; + } + + ASSERT(CurrentClass == BaseClass); + + NewBase->Clone = NewBase->Next; + NewBase->Next = BaseClass->Next; + NewBase->Base = NewBase; + + /* update all clones */ + CurrentClass = NewBase->Clone; + while (CurrentClass != NULL) + { + ASSERT(CurrentClass->Clone == NULL); + + CurrentClass->Base = NewBase; + + CurrentClass = CurrentClass->Next; + } + + /* link in the new base class */ + (void)InterlockedExchangePointer(PrevLink, + NewBase); + + /* destroy the class, there's still another clone of the class + that now serves as a base class. Make sure we don't destruct + resources shared by all classes (Base = NULL)! */ + BaseClass->Base = NULL; + BaseClass->Clone = NULL; + IntDestroyClass(BaseClass); + } + } + else + { + /* locate the cloned class and unlink it */ + PrevLink = &BaseClass->Clone; + CurrentClass = BaseClass->Clone; + while (CurrentClass != Class) + { + ASSERT(CurrentClass != NULL); + + PrevLink = &CurrentClass->Next; + CurrentClass = CurrentClass->Next; + } + + ASSERT(CurrentClass == Class); + + (void)InterlockedExchangePointer(PrevLink, + Class->Next); + + ASSERT(Class->Base == BaseClass); + ASSERT(Class->Clone == NULL); + + /* the class was just a clone, we don't need it anymore */ + IntDestroyClass(Class); + } + } +} + +static PWINDOWCLASS +IntCreateClass(IN CONST WNDCLASSEXW* lpwcx, + IN PUNICODE_STRING ClassName, + IN PUNICODE_STRING MenuName, + IN WNDPROC wpExtra, + IN DWORD dwFlags, + IN PDESKTOP Desktop, + IN PW32PROCESSINFO pi) +{ + SIZE_T ClassSize; + PWINDOWCLASS Class = NULL; + RTL_ATOM Atom; + NTSTATUS Status = STATUS_SUCCESS; + + if (!IntRegisterClassAtom(ClassName, + &Atom)) + { + DPRINT1("Failed to register class atom!\n"); + return NULL; + } + + ClassSize = sizeof(WINDOWCLASS) + lpwcx->cbClsExtra; + ClassSize += ClassName->Length + sizeof(UNICODE_NULL); + ClassSize += MenuName->Length + sizeof(UNICODE_NULL); + if (ClassName->Length != 0) + ClassSize += RtlUnicodeStringToAnsiSize(ClassName); + if (MenuName->Length != 0) + ClassSize += RtlUnicodeStringToAnsiSize(MenuName); + + if (Desktop != NULL) + { + Class = DesktopHeapAlloc(Desktop, + ClassSize); + } + else + { + /* FIXME - the class was created before being connected + to a desktop. It is possible for the desktop window, + but should it be allowed for any other case? */ + Class = UserHeapAlloc(ClassSize); + } + + if (Class != NULL) + { + RtlZeroMemory(Class, + sizeof(ClassSize)); + + Class->Desktop = Desktop; + Class->Base = Class; + Class->Atom = Atom; + + if (dwFlags & REGISTERCLASS_SYSTEM) + { + dwFlags &= ~REGISTERCLASS_ANSI; + Class->WndProcExtra = wpExtra; + Class->System = TRUE; + } + + _SEH_TRY + { + PWSTR strBuf; + PSTR strBufA; + ANSI_STRING AnsiString; + + /* need to protect with SEH since accessing the WNDCLASSEX structure + and string buffers might raise an exception! We don't want to + leak memory... */ + Class->WndProc = lpwcx->lpfnWndProc; + Class->Style = lpwcx->style; + Class->ClsExtra = lpwcx->cbClsExtra; + Class->WndExtra = lpwcx->cbWndExtra; + Class->hInstance = lpwcx->hInstance; + Class->hIcon = lpwcx->hIcon; /* FIXME */ + Class->hIconSm = lpwcx->hIconSm; /* FIXME */ + Class->hCursor = lpwcx->hCursor; /* FIXME */ + Class->hbrBackground = lpwcx->hbrBackground; + + /* make a copy of the string */ + strBuf = (PWSTR)(Class + 1); + if (MenuName->Length != 0) + { + Class->MenuName = strBuf; + RtlCopyMemory(Class->MenuName, + MenuName->Buffer, + MenuName->Length); + + strBuf += (MenuName->Length / sizeof(WCHAR)) + 1; + } + else + Class->MenuName = MenuName->Buffer; + + /* save an ansi copy of the string */ + strBufA = (PSTR)strBuf; + if (MenuName->Length != 0) + { + Class->AnsiMenuName = strBufA; + AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(MenuName); + AnsiString.Buffer = strBufA; + Status = RtlUnicodeStringToAnsiString(&AnsiString, + MenuName, + FALSE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to convert unicode menu name to ansi!\n"); + + /* life would've been much prettier if ntoskrnl exported RtlRaiseStatus()... */ + _SEH_LEAVE; + } + + strBufA += AnsiString.Length + 1; + } + else + Class->AnsiMenuName = (PSTR)MenuName->Buffer; + + /* calculate the offset of the extra data */ + Class->ClassExtraDataOffset = (ULONG_PTR)strBufA - (ULONG_PTR)Class; + + if (!(dwFlags & REGISTERCLASS_ANSI)) + Class->Unicode = TRUE; + + if (Class->Style & CS_GLOBALCLASS) + Class->Global = TRUE; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed creating the class: 0x%x\n", Status); + + SetLastNtError(Status); + + DesktopHeapFree(Desktop, + Class); + Class = NULL; + + IntDeregisterClassAtom(Atom); + } + } + else + { + DPRINT1("Failed to allocate class on Desktop 0x%p\n", Desktop); + + IntDeregisterClassAtom(Atom); + + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + } + + return Class; +} + +static PWINDOWCLASS +IntFindClass(IN RTL_ATOM Atom, + IN HINSTANCE hInstance, + IN PWINDOWCLASS *ClassList, + OUT PWINDOWCLASS **Link OPTIONAL) +{ + PWINDOWCLASS Class, *PrevLink = ClassList; + + Class = *PrevLink; + while (Class != NULL) + { + if (Class->Atom == Atom && + (hInstance == NULL || Class->hInstance == hInstance) && + !Class->Destroying) + { + ASSERT(Class->Base == Class); + + if (Link != NULL) + *Link = PrevLink; + break; + } + + PrevLink = &Class->Next; + Class = Class->Next; + } + + return Class; +} + +static WNDPROC +IntGetClassWndProc(IN PWINDOWCLASS Class, + IN PW32PROCESSINFO pi, + IN BOOL Ansi) +{ + if (Class->System) + { + return (Ansi ? Class->WndProcExtra : Class->WndProc); + } + else + { + if (!Ansi == Class->Unicode) + { + return Class->WndProc; + } + else + { + if (Class->CallProc != NULL) + { + return (WNDPROC)ObmObjectToHandle(Class->CallProc); + } + else + { + PCALLPROC NewCallProc, CallProc; + + if (pi == NULL) + return NULL; + + /* NOTE: use the interlocked functions, as this operation may be done even + when only the shared lock is held! */ + NewCallProc = CreateCallProc(Class->Desktop, + Class->WndProc, + Class->Unicode, + pi); + if (NewCallProc == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + CallProc = InterlockedCompareExchangePointer(&Class->CallProc, + NewCallProc, + NULL); + if (CallProc != NULL) + { + DestroyCallProc(Class->Desktop, + NewCallProc); + } + + return (WNDPROC)ObmObjectToHandle((CallProc == NULL ? NewCallProc : CallProc)); + } + } + } +} + +RTL_ATOM +IntGetClassAtom(IN PUNICODE_STRING ClassName, + IN HINSTANCE hInstance OPTIONAL, + IN PW32PROCESSINFO pi OPTIONAL, + OUT PWINDOWCLASS *BaseClass OPTIONAL, + OUT PWINDOWCLASS **Link OPTIONAL) +{ + RTL_ATOM Atom = (RTL_ATOM)0; + + if (ClassName->Length != 0) + { + WCHAR szBuf[65]; + PWSTR AtomName; + NTSTATUS Status; + + /* NOTE: Caller has to protect the call with SEH! */ + + if (ClassName->Length != 0) + { + /* FIXME - Don't limit to 64 characters! use SEH when allocating memory! */ + if (ClassName->Length / sizeof(WCHAR) >= sizeof(szBuf) / sizeof(szBuf[0])) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return (RTL_ATOM)0; + } + + /* We need to make a local copy of the class name! The caller could + modify the buffer and we could overflow in RtlLookupAtomInAtomTable. + We're protected by SEH, but the ranges that might be accessed were + not probed... */ + RtlCopyMemory(szBuf, + ClassName->Buffer, + ClassName->Length); + szBuf[ClassName->Length / sizeof(WCHAR)] = UNICODE_NULL; + AtomName = szBuf; + } + else + AtomName = ClassName->Buffer; + + /* lookup the atom */ + Status = RtlLookupAtomInAtomTable(gAtomTable, + AtomName, + &Atom); + if (!NT_SUCCESS(Status)) + { + if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + { + SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS); + } + else + { + SetLastNtError(Status); + } + } + } + else + { + ASSERT(IS_ATOM(ClassName->Buffer)); + Atom = (RTL_ATOM)((ULONG_PTR)ClassName->Buffer); + } + + if (BaseClass != NULL && Atom != (RTL_ATOM)0) + { + PWINDOWCLASS Class; + + /* attempt to locate the class object */ + + ASSERT(pi != NULL); + + /* Step 1: try to find an exact match of locally registered classes */ + Class = IntFindClass(Atom, + hInstance, + &pi->LocalClassList, + Link); + if (Class != NULL) + { + goto FoundClass; + } + + /* Step 2: try to find any globally registered class. The hInstance + is not relevant for global classes */ + Class = IntFindClass(Atom, + NULL, + &pi->GlobalClassList, + Link); + if (Class != NULL) + { + goto FoundClass; + } + + /* Step 3: try to find a system class */ + Class = IntFindClass(Atom, + NULL, + &pi->SystemClassList, + Link); + + if (Class == NULL) + { + SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); + return (RTL_ATOM)0; + } + +FoundClass: + *BaseClass = Class; + } + + return Atom; +} + +static PWINDOWCLASS +IntClassResizeInternal(IN OUT PWINDOWCLASS Class, + IN INT ClsExtraNew, + IN PWINDOWCLASS *List) +{ + PWINDOWCLASS *PrevLink, CurrentClass, NewClass; + SIZE_T NewSize; + + /* temporarily unlink the class, as resizing it may change it's location */ + PrevLink = List; + CurrentClass = *PrevLink; + while (CurrentClass != Class) + { + ASSERT(CurrentClass != NULL); + + PrevLink = &CurrentClass->Next; + CurrentClass = CurrentClass->Next; + } + + ASSERT(CurrentClass == Class); + + (void)InterlockedExchangePointer(PrevLink, + Class->Next); + + NewSize = (SIZE_T)ClsExtraNew + Class->ClassExtraDataOffset; + if (Class->Desktop != NULL) + { + NewClass = DesktopHeapReAlloc(Class->Desktop, + Class, + NewSize); + } + else + { + NewClass = UserHeapReAlloc(Class, + NewSize); + } + + if (NewClass == NULL) + { + /* link in the class again */ + (void)InterlockedExchangePointer(PrevLink, + Class); + + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + if (Class != NewClass) + { + /* adjust the menu name pointers, if neccessary */ + if (NewClass->MenuName != NULL && !IS_INTRESOURCE(NewClass->MenuName) && + NewClass->MenuName == (PWSTR)(NewClass + 1)) + { + ULONG_PTR PtrDelta = (ULONG_PTR)NewClass - (ULONG_PTR)Class; + + NewClass->MenuName = (PWSTR)((ULONG_PTR)NewClass->MenuName + PtrDelta); + NewClass->AnsiMenuName = (PSTR)((ULONG_PTR)NewClass->MenuName + PtrDelta); + } + + Class = NewClass; + } + + if (Class->ClsExtra < ClsExtraNew) + { + /* zero the memory allocated */ + RtlZeroMemory((PVOID)((ULONG_PTR)Class + Class->ClassExtraDataOffset + Class->ClsExtra), + ClsExtraNew - Class->ClsExtra); + } + + /* link in the class again */ + (void)InterlockedExchangePointer(PrevLink, + Class); + + return Class; +} + +static BOOL +IntClassResize(IN OUT PWINDOWCLASS Class, + IN PW32PROCESSINFO pi, + IN INT ClsExtraNew) +{ + PWINDOWCLASS *List, *CloneList, NewClass, Clone, FailedResize = NULL; + BOOL FailOnResize; + + if (pi == NULL) + return FALSE; + + /* first modify the base class, then the clones */ + Class = Class->Base; + + if (ClsExtraNew < 0 || + (ULONG_PTR)ClsExtraNew + Class->ClassExtraDataOffset < Class->ClassExtraDataOffset) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (Class->System) + List = &pi->SystemClassList; + else if (Class->Global) + List = &pi->GlobalClassList; + else + List = &pi->LocalClassList; + + FailOnResize = Class->ClsExtra < ClsExtraNew; + + /* resize the base class */ + NewClass = IntClassResizeInternal(Class, + ClsExtraNew, + List); + if (NewClass == NULL) + { + if (FailOnResize) + { + DPRINT1("Failed to resize the base class\n"); + return FALSE; + } + } + else + Class = NewClass; + + /* resize the clones */ + CloneList = &Class->Clone; + Clone = Class->Clone; + while (Clone != NULL) + { + NewClass = IntClassResizeInternal(Clone, + ClsExtraNew, + CloneList); + + if (NewClass == NULL) + { + if (FailOnResize) + { + /* roll back all changes */ + FailedResize = Clone; + break; + } + } + else + Clone = NewClass; + + /* save the pointer to the base class in case it changed */ + Clone->Base = Class; + + Clone = Clone->Next; + } + + if (FailedResize != NULL) + { + /* failed to resize one clone, roll back the changes to all + other clones and to the base class */ + DPRINT1("Failed to resize the cloned class 0x%p\n", FailedResize); + + /* roll back the changes made to the base class */ + NewClass = IntClassResizeInternal(Class, + Class->ClsExtra, + List); + if (NewClass != NULL) + Class = NewClass; + + /* roll back all changes made to the class clones */ + CloneList = &Class->Clone; + Clone = Class->Clone; + while (Clone != FailedResize) + { + ASSERT(Clone != NULL); + + NewClass = IntClassResizeInternal(Clone, + Class->ClsExtra, + CloneList); + if (NewClass != NULL) + Clone = NewClass; + + /* save the pointer to the base class in case it changed */ + Clone->Base = Class; + + CloneList = &Clone->Next; + Clone = Clone->Next; + } + + return FALSE; + } + else + { + /* all classes were successfully resized, + save the new extra data size */ + Class->ClsExtra = ClsExtraNew; + Clone = Class->Clone; + while (Clone != NULL) + { + Clone->ClsExtra = ClsExtraNew; + Clone = Clone->Next; + } + + return TRUE; + } +} + +RTL_ATOM +UserRegisterClass(IN CONST WNDCLASSEXW* lpwcx, + IN PUNICODE_STRING ClassName, + IN PUNICODE_STRING MenuName, + IN HANDLE hMenu, /* FIXME */ + IN WNDPROC wpExtra, + IN DWORD dwFlags) +{ + PW32THREADINFO ti; + PW32PROCESSINFO pi; + PWINDOWCLASS Class; + RTL_ATOM ClassAtom; + RTL_ATOM Ret = (RTL_ATOM)0; + + /* NOTE: Accessing the buffers in ClassName and MenuName may raise exceptions! */ + + ti = GetW32ThreadInfo(); + if (ti == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return (RTL_ATOM)0; + } + + pi = ti->kpi; + + /* try to find a previously registered class */ + ClassAtom = IntGetClassAtom(ClassName, + NULL, + NULL, + NULL, + NULL); + if (ClassAtom != (RTL_ATOM)0) + { + Class = IntFindClass(ClassAtom, + lpwcx->hInstance, + &pi->LocalClassList, + NULL); + if (Class != NULL) + { + goto ClassAlreadyExists; + } + + /* if CS_GLOBALCLASS is set, try to find a previously registered global class. + Re-registering system classes as global classes seems to be allowed, + so we don't fail */ + if (lpwcx->style & CS_GLOBALCLASS) + { + Class = IntFindClass(ClassAtom, + NULL, + ((dwFlags & REGISTERCLASS_SYSTEM) ? + &pi->SystemClassList : &pi->GlobalClassList), + NULL); + if (Class != NULL) + { +ClassAlreadyExists: + DPRINT1("Class 0x%p does already exist!\n", ClassAtom); + SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS); + return (RTL_ATOM)0; + } + } + } + + ASSERT(ti->Desktop != NULL); + + Class = IntCreateClass(lpwcx, + ClassName, + MenuName, + wpExtra, + dwFlags, + ti->Desktop, + pi); + + if (Class != NULL) + { + PWINDOWCLASS *List; + + /* FIXME - pass the PMENU pointer to IntCreateClass instead! */ + Class->hMenu = hMenu; + + /* Register the class */ + if (Class->System) + List = &pi->SystemClassList; + else if (Class->Global) + List = &pi->GlobalClassList; + else + List = &pi->LocalClassList; + + Class->Next = *List; + (void)InterlockedExchangePointer(List, + Class); + + Ret = Class->Atom; + } + + return Ret; +} + +BOOL +UserUnregisterClass(IN PUNICODE_STRING ClassName, + IN HINSTANCE hInstance) +{ + PWINDOWCLASS *Link; + PW32PROCESSINFO pi; + RTL_ATOM ClassAtom; + PWINDOWCLASS Class; + + pi = GetW32ProcessInfo(); + if (pi == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + /* NOTE: Accessing the buffer in ClassName may raise an exception! */ + ClassAtom = IntGetClassAtom(ClassName, + hInstance, + pi, + &Class, + &Link); + if (ClassAtom == (RTL_ATOM)0) + { + return FALSE; + } + + ASSERT(Class != NULL); + + if (Class->System) + { + DPRINT1("Attempted to unregister system class 0x%p!\n", ClassAtom); + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + if (Class->Windows != 0 || + Class->Clone != NULL) + { + SetLastWin32Error(ERROR_CLASS_HAS_WINDOWS); + return FALSE; + } + + /* must be a base class! */ + ASSERT(Class->Base == Class); + + /* unlink the class */ + *Link = Class->Next; + + /* finally free the resources */ + IntDestroyClass(Class); + return TRUE; +} + +INT +UserGetClassName(IN PWINDOWCLASS Class, + IN OUT PUNICODE_STRING ClassName, + IN BOOL Ansi) +{ + NTSTATUS Status = STATUS_SUCCESS; + WCHAR szStaticTemp[32]; + PWSTR szTemp = NULL; + ULONG BufLen = sizeof(szStaticTemp); + INT Ret = 0; + + /* Note: Accessing the buffer in ClassName may raise an exception! */ + + _SEH_TRY + { + if (Ansi) + { + PANSI_STRING AnsiClassName = (PANSI_STRING)ClassName; + UNICODE_STRING UnicodeClassName; + + /* limit the size of the static buffer on the stack to the + size of the buffer provided by the caller */ + if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength) + { + BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR); + } + + /* find out how big the buffer needs to be */ + Status = RtlQueryAtomInAtomTable(gAtomTable, + Class->Atom, + NULL, + NULL, + szStaticTemp, + &BufLen); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + if (BufLen / sizeof(WCHAR) > AnsiClassName->MaximumLength) + { + /* the buffer required exceeds the ansi buffer provided, + pretend like we're using the ansi buffer and limit the + size to the buffer size provided */ + BufLen = AnsiClassName->MaximumLength * sizeof(WCHAR); + } + + /* allocate a temporary buffer that can hold the unicode class name */ + szTemp = ExAllocatePool(PagedPool, + BufLen); + if (szTemp == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + _SEH_LEAVE; + } + + /* query the class name */ + Status = RtlQueryAtomInAtomTable(gAtomTable, + Class->Atom, + NULL, + NULL, + szTemp, + &BufLen); + } + else + szTemp = szStaticTemp; + + if (NT_SUCCESS(Status)) + { + /* convert the atom name to ansi */ + + RtlInitUnicodeString(&UnicodeClassName, + szTemp); + + Status = RtlUnicodeStringToAnsiString(AnsiClassName, + &UnicodeClassName, + FALSE); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + _SEH_LEAVE; + } + } + + Ret = BufLen / sizeof(WCHAR); + } + else /* !Ansi */ + { + BufLen = ClassName->MaximumLength; + + /* query the atom name */ + Status = RtlQueryAtomInAtomTable(gAtomTable, + Class->Atom, + NULL, + NULL, + ClassName->Buffer, + &BufLen); + + if (NT_SUCCESS(Status)) + { + SetLastNtError(Status); + _SEH_LEAVE; + } + + Ret = BufLen / sizeof(WCHAR); + } + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + + if (Ansi && szTemp != NULL && szTemp != szStaticTemp) + { + ExFreePool(szTemp); + } + + return Ret; +} + +ULONG_PTR +UserGetClassLongPtr(IN PWINDOWCLASS Class, + IN INT Index, + IN BOOL Ansi) +{ + ULONG_PTR Ret = 0; + + if (Index > 0) + { + PULONG_PTR Data; + + if (Index + sizeof(ULONG_PTR) < Index || + Index + sizeof(ULONG_PTR) > Class->ClsExtra) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return 0; + } + + Data = (PULONG_PTR)((ULONG_PTR)Class + Class->ClassExtraDataOffset); + + /* FIXME - Data might be a unaligned pointer! Might be a problem on + certain architectures, maybe using RtlCopyMemory is a + better choice for those architectures! */ + return *Data; + } + + switch (Index) + { + case GCL_CBWNDEXTRA: + Ret = (ULONG_PTR)Class->WndExtra; + break; + + case GCL_CBCLSEXTRA: + Ret = (ULONG_PTR)Class->ClsExtra; + break; + + case GCLP_HBRBACKGROUND: + Ret = (ULONG_PTR)Class->hbrBackground; + break; + + case GCLP_HCURSOR: + /* FIXME - get handle from pointer to CURSOR object */ + Ret = (ULONG_PTR)Class->hCursor; + break; + + case GCLP_HICON: + /* FIXME - get handle from pointer to ICON object */ + Ret = (ULONG_PTR)Class->hIcon; + break; + + case GCLP_HICONSM: + /* FIXME - get handle from pointer to ICON object */ + Ret = (ULONG_PTR)Class->hIconSm; + break; + + case GCLP_HMODULE: + Ret = (ULONG_PTR)Class->hInstance; + break; + + case GCLP_MENUNAME: + /* NOTE: Returns pointer in kernel heap! */ + if (Ansi) + Ret = (ULONG_PTR)Class->AnsiMenuName; + else + Ret = (ULONG_PTR)Class->MenuName; + break; + + case GCL_STYLE: + Ret = (ULONG_PTR)Class->Style; + break; + + case GCLP_WNDPROC: + Ret = (ULONG_PTR)IntGetClassWndProc(Class, + GetW32ProcessInfo(), + Ansi); + break; + + case GCW_ATOM: + Ret = (ULONG_PTR)Class->Atom; + break; + + default: + SetLastWin32Error(ERROR_INVALID_INDEX); + break; + } + + return Ret; +} + +static BOOL +IntSetClassMenuName(IN PWINDOWCLASS Class, + IN PUNICODE_STRING MenuName) +{ + BOOL Ret = FALSE; + + /* change the base class first */ + Class = Class->Base; + + if (MenuName->Length != 0) + { + ANSI_STRING AnsiString; + PWSTR strBufW; + + AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(MenuName); + + strBufW = UserHeapAlloc(MenuName->Length + sizeof(UNICODE_NULL) + + AnsiString.MaximumLength); + if (strBufW != NULL) + { + _SEH_TRY + { + NTSTATUS Status; + + /* copy the unicode string */ + RtlCopyMemory(strBufW, + MenuName->Buffer, + MenuName->Length); + strBufW[MenuName->Length / sizeof(WCHAR)] = UNICODE_NULL; + + /* create an ansi copy of the string */ + AnsiString.Buffer = (PSTR)(strBufW + (MenuName->Length / sizeof(WCHAR)) + 1); + Status = RtlUnicodeStringToAnsiString(&AnsiString, + MenuName, + FALSE); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + _SEH_LEAVE; + } + + Ret = TRUE; + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + + if (Ret) + { + /* update the base class */ + IntFreeClassMenuName(Class); + Class->MenuName = strBufW; + Class->AnsiMenuName = AnsiString.Buffer; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->MenuName = strBufW; + Class->AnsiMenuName = AnsiString.Buffer; + + Class = Class->Next; + } + } + else + { + DPRINT1("Failed to copy class menu name!\n"); + UserHeapFree(strBufW); + } + } + else + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + } + else + { + ASSERT(IS_INTRESOURCE(MenuName->Buffer)); + + /* update the base class */ + IntFreeClassMenuName(Class); + Class->MenuName = MenuName->Buffer; + Class->AnsiMenuName = (PSTR)MenuName->Buffer; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->MenuName = MenuName->Buffer; + Class->AnsiMenuName = (PSTR)MenuName->Buffer; + + Class = Class->Next; + } + + Ret = TRUE; + } + + return Ret; +} + +ULONG_PTR +UserSetClassLongPtr(IN PWINDOWCLASS Class, + IN INT Index, + IN ULONG_PTR NewLong, + IN BOOL Ansi) +{ + ULONG_PTR Ret = 0; + + /* NOTE: For GCLP_MENUNAME and GCW_ATOM this function may raise an exception! */ + + /* change the information in the base class first, then update the clones */ + Class = Class->Base; + + if (Index > 0) + { + PULONG_PTR Data; + + if (Index + sizeof(ULONG_PTR) < Index || + Index + sizeof(ULONG_PTR) > Class->ClsExtra) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return 0; + } + + Data = (PULONG_PTR)((ULONG_PTR)Class + Class->ClassExtraDataOffset); + + /* FIXME - Data might be a unaligned pointer! Might be a problem on + certain architectures, maybe using RtlCopyMemory is a + better choice for those architectures! */ + Ret = *Data; + *Data = NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + *(PULONG_PTR)((ULONG_PTR)Class + Class->ClassExtraDataOffset) = NewLong; + Class = Class->Next; + } + + return Ret; + } + + switch (Index) + { + case GCL_CBWNDEXTRA: + Ret = (ULONG_PTR)Class->WndExtra; + Class->WndExtra = (INT)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->WndExtra = (INT)NewLong; + Class = Class->Next; + } + + break; + + case GCL_CBCLSEXTRA: + Ret = (ULONG_PTR)Class->ClsExtra; + if (Class->ClsExtra != (INT)NewLong) + { + if (!IntClassResize(Class, + GetW32ProcessInfo(), + (INT)NewLong)) + { + Ret = 0; + } + } + break; + + case GCLP_HBRBACKGROUND: + Ret = (ULONG_PTR)Class->hbrBackground; + Class->hbrBackground = (HBRUSH)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->hbrBackground = (HBRUSH)NewLong; + Class = Class->Next; + } + break; + + case GCLP_HCURSOR: + /* FIXME - get handle from pointer to CURSOR object */ + Ret = (ULONG_PTR)Class->hCursor; + Class->hCursor = (HANDLE)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->hCursor = (HANDLE)NewLong; + Class = Class->Next; + } + break; + + case GCLP_HICON: + /* FIXME - get handle from pointer to ICON object */ + Ret = (ULONG_PTR)Class->hIcon; + Class->hIcon = (HANDLE)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->hIcon = (HANDLE)NewLong; + Class = Class->Next; + } + break; + + case GCLP_HICONSM: + /* FIXME - get handle from pointer to ICON object */ + Ret = (ULONG_PTR)Class->hIconSm; + Class->hIconSm = (HANDLE)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->hIconSm = (HANDLE)NewLong; + Class = Class->Next; + } + break; + + case GCLP_HMODULE: + Ret = (ULONG_PTR)Class->hInstance; + Class->hInstance = (HINSTANCE)NewLong; + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->hInstance = (HINSTANCE)NewLong; + Class = Class->Next; + } + break; + + case GCLP_MENUNAME: + { + PUNICODE_STRING Value = (PUNICODE_STRING)NewLong; + + if (!IntSetClassMenuName(Class, + Value)) + { + DPRINT("Setting the class menu name failed!\n"); + } + + /* FIXME - really return NULL? Wine does so... */ + break; + } + + case GCL_STYLE: + Ret = (ULONG_PTR)Class->Style; + Class->Style = (UINT)NewLong; + + /* FIXME - what if the CS_GLOBALCLASS style is changed? should we + move the class to the appropriate list? For now, we save + the original value in Class->Global, so we can always + locate the appropriate list */ + + /* update the clones */ + Class = Class->Clone; + while (Class != NULL) + { + Class->Style = (UINT)NewLong; + Class = Class->Next; + } + break; + + case GCLP_WNDPROC: + Ret = (ULONG_PTR)IntSetClassWndProc(Class, + (WNDPROC)NewLong, + Ansi); + break; + + case GCW_ATOM: + { + PUNICODE_STRING Value = (PUNICODE_STRING)NewLong; + + Ret = (ULONG_PTR)Class->Atom; + if (!IntSetClassAtom(Class, + Value)) + { + Ret = 0; + } + break; + } + + default: + SetLastWin32Error(ERROR_INVALID_INDEX); + break; + } + + return Ret; +} + +static BOOL +UserGetClassInfo(IN PWINDOWCLASS Class, + OUT PWNDCLASSEXW lpwcx, + IN BOOL Ansi) +{ + lpwcx->style = Class->Style; + + if (Class->System) + { + lpwcx->lpfnWndProc = (!Ansi ? Class->WndProc : Class->WndProcExtra); + } + else + { + if (!Ansi == Class->Unicode) + { + lpwcx->lpfnWndProc = Class->WndProc; + } + else + { + /* FIXME - return callproc handle or function pointer? */ + lpwcx->lpfnWndProc = Class->CallProc->WndProc; + } + } + + lpwcx->cbClsExtra = Class->ClsExtra; + lpwcx->cbWndExtra = Class->WndExtra; + lpwcx->hInstance = Class->hInstance; + lpwcx->hIcon = Class->hIcon; /* FIXME - get handle from pointer */ + lpwcx->hCursor = Class->hCursor; /* FIXME - get handle from pointer */ + lpwcx->hbrBackground = Class->hbrBackground; + + if (Ansi) + ((PWNDCLASSEXA)lpwcx)->lpszMenuName = Class->AnsiMenuName; + else + lpwcx->lpszMenuName = Class->MenuName; + + lpwcx->lpszClassName = (LPCWSTR)((ULONG_PTR)Class->Atom); /* FIXME - return the string? */ + + lpwcx->hIconSm = Class->hIconSm; /* FIXME - get handle from pointer */ + + return TRUE; +} + /* SYSCALLS *****************************************************************/ -RTL_ATOM STDCALL -NtUserRegisterClassExWOW( - CONST WNDCLASSEXW* lpwcx, - PUNICODE_STRING ClassName, - PUNICODE_STRING ClassNameCopy,//huhuhuhu??? - PUNICODE_STRING MenuName, - WNDPROC wpExtra, - DWORD Flags, - DWORD Unknown7, - HMENU hMenu) +RTL_ATOM NTAPI +NtUserRegisterClassEx(IN CONST WNDCLASSEXW* lpwcx, + IN PUNICODE_STRING ClassName, + IN PUNICODE_STRING MenuName, + IN WNDPROC wpExtra, + IN DWORD Flags, + IN HMENU hMenu) /* * FUNCTION: @@ -452,149 +1819,204 @@ * Atom identifying the new class */ { - WNDCLASSEXW SafeClass; - NTSTATUS Status; - RTL_ATOM Atom; - DECLARE_RETURN(RTL_ATOM); - - DPRINT("Enter NtUserRegisterClassExWOW\n"); - UserEnterExclusive(); - - if (!lpwcx) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - RETURN( (RTL_ATOM)0); - } - - if (Flags & ~REGISTERCLASS_ALL) - { - SetLastWin32Error(ERROR_INVALID_FLAGS); - RETURN( (RTL_ATOM)0); - } - - Status = MmCopyFromCaller(&SafeClass, lpwcx, sizeof(WNDCLASSEXW)); - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - RETURN( (RTL_ATOM)0); - } - - /* Deny negative sizes */ - if (lpwcx->cbClsExtra < 0 || lpwcx->cbWndExtra < 0) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - RETURN( (RTL_ATOM)0); - } - - if (!lpwcx->hInstance) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - RETURN( (RTL_ATOM)0); - } - - //FIXME: make ClassName ptr the atom, not buffer - if (ClassName->Length > 0) - { - DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer); - /* FIXME - Safely copy/verify the buffer first!!! */ - Status = RtlAddAtomToAtomTable(gAtomTable, - ClassName->Buffer, - &Atom); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed adding class name (%S) to atom table\n", - ClassName->Buffer); - SetLastNtError(Status); - RETURN((RTL_ATOM)0); - } - } - else - { - Atom = (RTL_ATOM)(ULONG)ClassName->Buffer; - } - - if (!Atom) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - RETURN(0); - } - - if (!IntRegisterClass(&SafeClass, Flags, wpExtra, MenuName, Atom, hMenu)) - { - if (ClassName->Length) - { - RtlDeleteAtomFromAtomTable(gAtomTable, Atom); - } - DPRINT("Failed creating window class object\n"); - RETURN((RTL_ATOM)0); - } - - RETURN(Atom); - -CLEANUP: - DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - - - -DWORD STDCALL -NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi) -{ - PWINDOW_OBJECT Window; - DECLARE_RETURN(DWORD); - - DPRINT("Enter NtUserGetClassLong\n"); - UserEnterExclusive(); - - if (!(Window = UserGetWindowObject(hWnd))) - { - RETURN(0); - } - - RETURN(IntGetClassLong(Window, Offset, Ansi)); - -CLEANUP: - DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - - - -DWORD STDCALL + WNDCLASSEXW CapturedClassInfo = {0}; + UNICODE_STRING CapturedName = {0}, CapturedMenuName = {0}; + RTL_ATOM Ret = (RTL_ATOM)0; + + if (Flags & ~REGISTERCLASS_ALL) + { + SetLastWin32Error(ERROR_INVALID_FLAGS); + return Ret; + } + + UserEnterExclusive(); + + _SEH_TRY + { + /* Probe the parameters and basic parameter checks */ + if (ProbeForReadUint(&lpwcx->cbSize) != sizeof(WNDCLASSEXW)) + { + goto InvalidParameter; + } + + ProbeForRead(lpwcx, + sizeof(WNDCLASSEXW), + sizeof(ULONG)); + RtlCopyMemory(&CapturedClassInfo, + lpwcx, + sizeof(WNDCLASSEXW)); + + CapturedName = ProbeForReadUnicodeString(ClassName); + CapturedMenuName = ProbeForReadUnicodeString(MenuName); + + if (CapturedName.Length & 1 || CapturedMenuName.Length & 1 || + CapturedClassInfo.cbClsExtra < 0 || + CapturedClassInfo.cbClsExtra + CapturedName.Length + + CapturedMenuName.Length + sizeof(WINDOWCLASS) < CapturedClassInfo.cbClsExtra || + CapturedClassInfo.cbWndExtra < 0 || + CapturedClassInfo.hInstance == NULL) + { + goto InvalidParameter; + } + + if (CapturedName.Length != 0) + { + ProbeForRead(CapturedName.Buffer, + CapturedName.Length, + sizeof(WCHAR)); + } + else + { + if (!IS_ATOM(CapturedName.Buffer)) + { + goto InvalidParameter; + } + } + + if (CapturedMenuName.Length != 0) + { + ProbeForRead(CapturedMenuName.Buffer, + CapturedMenuName.Length, + sizeof(WCHAR)); + } + else if (CapturedMenuName.Buffer != NULL && + !IS_INTRESOURCE(CapturedMenuName.Buffer)) + { +InvalidParameter: + SetLastWin32Error(ERROR_INVALID_PARAMETER); + _SEH_LEAVE; + } + + /* Register the class */ + Ret = UserRegisterClass(&CapturedClassInfo, + &CapturedName, + &CapturedMenuName, + hMenu, /* FIXME - pass pointer */ + wpExtra, + Flags); + + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + + UserLeave(); + + return Ret; +} + + + +ULONG_PTR NTAPI +NtUserGetClassLong(IN HWND hWnd, + IN INT Offset, + IN BOOL Ansi) +{ + PWINDOW_OBJECT Window; + ULONG_PTR Ret = 0; + + UserEnterShared(); + + Window = UserGetWindowObject(hWnd); + if (Window != NULL) + { + Ret = UserGetClassLongPtr(Window->Class, + Offset, + Ansi); + + if (Ret != 0 && Offset == GCLP_MENUNAME && !IS_INTRESOURCE(Ret)) + { + Ret = (ULONG_PTR)DesktopHeapAddressToUser(Window->Class->Desktop, + (PVOID)Ret); + } + } + + UserLeave(); + + return Ret; +} + + + +ULONG_PTR STDCALL NtUserSetClassLong(HWND hWnd, - DWORD Offset, - LONG dwNewLong, + INT Offset, + ULONG_PTR dwNewLong, BOOL Ansi) { - PWINDOW_OBJECT Window; - LONG Ret; - USER_REFERENCE_ENTRY Ref; - DECLARE_RETURN(DWORD); - - DPRINT("Enter NtUserSetClassLong\n"); - UserEnterExclusive(); - - if (!(Window = UserGetWindowObject(hWnd))) - { - RETURN(0); - } - - UserRefObjectCo(Window, &Ref); - - Ret = IntGetClassLong(Window, Offset, Ansi); - co_IntSetClassLong(Window, Offset, dwNewLong, Ansi); - - UserDerefObjectCo(Window); - - RETURN(Ret); - -CLEANUP: - DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; + PW32PROCESSINFO pi; + PWINDOW_OBJECT Window; + ULONG_PTR Ret = 0; + + UserEnterExclusive(); + + pi = GetW32ProcessInfo(); + if (pi == NULL) + goto Cleanup; + + Window = UserGetWindowObject(hWnd); + if (Window != NULL) + { + if (Window->ti->kpi != pi) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + goto Cleanup; + } + + _SEH_TRY + { + UNICODE_STRING Value; + + /* probe the parameters */ + if (Offset == GCW_ATOM || Offset == GCLP_MENUNAME) + { + Value = ProbeForReadUnicodeString((PUNICODE_STRING)dwNewLong); + if (Value.Length & 1) + { + goto InvalidParameter; + } + + if (Value.Length != 0) + { + ProbeForRead(Value.Buffer, + Value.Length, + sizeof(WCHAR)); + } + else + { + if (Offset == GCW_ATOM && !IS_ATOM(Value.Buffer)) + { + goto InvalidParameter; + } + else if (Offset == GCLP_MENUNAME && !IS_INTRESOURCE(Value.Buffer)) + { +InvalidParameter: + SetLastWin32Error(ERROR_INVALID_PARAMETER); + _SEH_LEAVE; + } + } + + dwNewLong = (ULONG_PTR)&Value; + } + + Ret = UserSetClassLongPtr(Window->Class, + Offset, + dwNewLong, + Ansi); + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + } + +Cleanup: + UserLeave(); + + return Ret; } DWORD STDCALL @@ -602,164 +2024,232 @@ DWORD Unknown1, DWORD Unknown2) { - UNIMPLEMENTED; return(0); } +BOOL NTAPI +NtUserUnregisterClass(IN PUNICODE_STRING ClassNameOrAtom, + IN HINSTANCE hInstance) +{ + UNICODE_STRING CapturedClassName; + BOOL Ret = FALSE; + + UserEnterExclusive(); + + _SEH_TRY + { + /* probe the paramters */ + CapturedClassName = ProbeForReadUnicodeString(ClassNameOrAtom); + if (CapturedClassName.Length & 1) + { + goto InvalidParameter; + } + + if (CapturedClassName.Length != 0) + { + ProbeForRead(CapturedClassName.Buffer, + CapturedClassName.Length, + sizeof(WCHAR)); + } + else + { + if (!IS_ATOM(CapturedClassName.Buffer)) + { +InvalidParameter: + SetLastWin32Error(ERROR_INVALID_PARAMETER); + _SEH_LEAVE; + } + } + + /* unregister the class */ + Ret = UserUnregisterClass(&CapturedClassName, + hInstance); + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + + UserLeave(); + + return Ret; +} + +/* NOTE: for system classes hInstance is not NULL here, but User32Instance */ BOOL STDCALL -NtUserUnregisterClass( - LPCWSTR ClassNameOrAtom, - HINSTANCE hInstance, /* can be 0 */ - DWORD Unknown) -{ - PWNDCLASS_OBJECT Class; - DECLARE_RETURN(BOOL); - - DPRINT("Enter NtUserUnregisterClass(%S)\n", ClassNameOrAtom); - UserEnterExclusive(); - - if (!ClassNameOrAtom) - { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - RETURN(FALSE); - } - - if (!(Class = ClassGetClassByNameOrAtom(ClassNameOrAtom, hInstance))) - { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - RETURN(FALSE); - } - - if (Class->refs) - { - /* NOTE: the class will not be freed when its refs become 0 ie. no more - * windows are using it. I dunno why that is but its how Windows does it (and Wine). - * The class will hang around until the process exit. -Gunnar - */ - SetLastWin32Error(ERROR_CLASS_HAS_WINDOWS); - RETURN(FALSE); - } - - DestroyClass(Class); - - RETURN(TRUE); - -CLEANUP: - DPRINT("Leave NtUserUnregisterClass, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - -/* NOTE: for system classes hInstance is not NULL here, but User32Instance */ -DWORD STDCALL NtUserGetClassInfo( HINSTANCE hInstance, - LPCWSTR lpClassName, + PUNICODE_STRING ClassName, LPWNDCLASSEXW lpWndClassEx, - BOOL Ansi, - DWORD unknown3) -{ - PWNDCLASS_OBJECT Class; - RTL_ATOM Atom; - DECLARE_RETURN(DWORD); - - if (IS_ATOM(lpClassName)) - DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance); - else - DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance); - - UserEnterExclusive(); - - if (!hInstance) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - RETURN(0); - } - - if (!(Class = ClassGetClassByNameOrAtom(lpClassName, hInstance))) - { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - RETURN(0); - } - - lpWndClassEx->cbSize = sizeof(WNDCLASSEXW); - lpWndClassEx->style = Class->style; - if (Ansi) - lpWndClassEx->lpfnWndProc = Class->lpfnWndProcA; - else - lpWndClassEx->lpfnWndProc = Class->lpfnWndProcW; - lpWndClassEx->cbClsExtra = Class->cbClsExtra; - lpWndClassEx->cbWndExtra = Class->cbWndExtra; - /* This is not typo, we're really not going to use Class->hInstance here. */ - /* Well, i think its wrong so i changed it -Gunnar */ - lpWndClassEx->hInstance = Class->hInstance; - lpWndClassEx->hIcon = Class->hIcon; - lpWndClassEx->hCursor = Class->hCursor; - lpWndClassEx->hbrBackground = Class->hbrBackground; - if (Class->lpszMenuName.MaximumLength) - RtlCopyUnicodeString((PUNICODE_STRING)lpWndClassEx->lpszMenuName, &Class->lpszMenuName); - else - lpWndClassEx->lpszMenuName = Class->lpszMenuName.Buffer; - lpWndClassEx->lpszClassName = lpClassName; - lpWndClassEx->hIconSm = Class->hIconSm; - Atom = Class->Atom; - - RETURN(Atom); - -CLEANUP: - DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - - - -DWORD STDCALL -NtUserGetClassName ( - HWND hWnd, - LPWSTR lpClassName, - ULONG nMaxCount /* in TCHARS */ - ) -{ - PWINDOW_OBJECT Window; - DECLARE_RETURN(DWORD); - NTSTATUS Status; - - UserEnterShared(); - DPRINT("Enter NtUserGetClassName\n"); - - if (!(Window = UserGetWindowObject(hWnd))) - { - RETURN(0); - } - - nMaxCount *= sizeof(WCHAR); - - //FIXME: wrap in SEH to protect lpClassName access - Status = RtlQueryAtomInAtomTable(gAtomTable, - Window->Class->Atom, NULL, NULL, - lpClassName, &nMaxCount); - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - RETURN(0); - } - - RETURN(nMaxCount / sizeof(WCHAR)); - -CLEANUP: - DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; + BOOL Ansi) +{ + UNICODE_STRING CapturedClassName; + PWINDOWCLASS Class; + RTL_ATOM ClassAtom; + PW32PROCESSINFO pi; + BOOL Ret = FALSE; + + UserEnterShared(); + + pi = GetW32ProcessInfo(); + if (pi == NULL) + { + goto Cleanup; + } + + _SEH_TRY + { + /* probe the paramters */ + CapturedClassName = ProbeForReadUnicodeString(ClassName); + if (CapturedClassName.Length & 1) + { + goto InvalidParameter; + } + + if (CapturedClassName.Length != 0) + { + ProbeForRead(CapturedClassName.Buffer, + CapturedClassName.Length, + sizeof(WCHAR)); + } + else + { + if (!IS_ATOM(CapturedClassName.Buffer)) + { + goto InvalidParameter; + } + } + + if (ProbeForReadUint(&lpWndClassEx->cbSize) != sizeof(WNDCLASSEXW)) + { +InvalidParameter: + SetLastWin32Error(ERROR_INVALID_PARAMETER); + _SEH_LEAVE; + } + + ProbeForWrite(lpWndClassEx, + sizeof(WNDCLASSEXW), + sizeof(ULONG)); + + ClassAtom = IntGetClassAtom(&CapturedClassName, + hInstance, + pi, + &Class, + NULL); + if (ClassAtom != (RTL_ATOM)0) + { + Ret = UserGetClassInfo(Class, + lpWndClassEx, + Ansi); + + if (Ret) + { + lpWndClassEx->lpszClassName = CapturedClassName.Buffer; + + /* FIXME - handle Class->Desktop == NULL!!!!! */ + + if (Class->MenuName != NULL && + !IS_INTRESOURCE(Class->MenuName)) + { + lpWndClassEx->lpszMenuName = DesktopHeapAddressToUser(Class->Desktop, + (Ansi ? + (PVOID)Class->AnsiMenuName : + (PVOID)Class->MenuName)); + } + } + } + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + +Cleanup: + UserLeave(); + + return Ret; +} + + + +INT NTAPI +NtUserGetClassName (IN HWND hWnd, + OUT PUNICODE_STRING ClassName, + IN BOOL Ansi) +{ + PWINDOW_OBJECT Window; + UNICODE_STRING CapturedClassName; + INT Ret = 0; + + UserEnterShared(); + + Window = UserGetWindowObject(hWnd); + if (Window != NULL) + { + _SEH_TRY + { + ProbeForWriteUnicodeString(ClassName); + CapturedClassName = *ClassName; + + /* get the class name */ + Ret = UserGetClassName(Window->Class, + &CapturedClassName, + Ansi); + + if (Ret != 0) + { + /* update the Length field */ + ClassName->Length = CapturedClassName.Length; + } + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + } + + UserLeave(); + + return Ret; } DWORD STDCALL NtUserGetWOWClass(DWORD Unknown0, DWORD Unknown1) { - UNIMPLEMENTED; return(0); } +BOOL NTAPI +NtUserDereferenceWndProcHandle(IN HANDLE wpHandle, + OUT PWNDPROC_INFO wpInfo) +{ + BOOL Ret = FALSE; + + UserEnterShared(); + + _SEH_TRY + { + ProbeForWrite(wpInfo, + sizeof(WNDPROC_INFO), + sizeof(ULONG)); + + Ret = UserGetCallProcInfo(wpHandle, + wpInfo); + } + _SEH_HANDLE + { + SetLastWin32Error(_SEH_GetExceptionCode()); + } + _SEH_END; + + UserLeave(); + + return Ret; +} + /* EOF */ Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c Wed Apr 5 12:05:55 2006 @@ -83,7 +83,7 @@ return NULL; } - CurIcon = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hCurIcon, otCursorIcon); + CurIcon = (PCURICON_OBJECT)UserGetObject(gHandleTable, hCurIcon, otCursorIcon); if (!CurIcon) { /* we never set ERROR_INVALID_ICON_HANDLE. lets hope noone ever checks for it */ @@ -397,7 +397,7 @@ PCURICON_OBJECT CurIcon; HANDLE hCurIcon; - CurIcon = ObmCreateObject(&gHandleTable, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); + CurIcon = ObmCreateObject(gHandleTable, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); if(!CurIcon) { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c Wed Apr 5 12:05:55 2006 @@ -43,6 +43,8 @@ BOOL g_PaintDesktopVersion = FALSE; +static VOID IntFreeDesktopHeap(IN OUT PDESKTOP_OBJECT Desktop); + /* INITALIZATION FUNCTIONS ****************************************************/ static GENERIC_MAPPING IntDesktopMapping = @@ -121,6 +123,8 @@ RemoveEntryList(&Desktop->ListEntry); RtlFreeUnicodeString(&Desktop->Name); + + IntFreeDesktopHeap(Desktop); } /* PRIVATE FUNCTIONS **********************************************************/ @@ -723,7 +727,15 @@ return FALSE; } - +static VOID +IntFreeDesktopHeap(IN OUT PDESKTOP_OBJECT Desktop) +{ + if (Desktop->DesktopHeapSection != NULL) + { + ObDereferenceObject(Desktop->DesktopHeapSection); + Desktop->DesktopHeapSection = NULL; + } +} /* SYSCALLS *******************************************************************/ @@ -776,6 +788,8 @@ NTSTATUS Status; HDESK Desktop; CSR_API_MESSAGE Request; + PVOID DesktopHeapSystemBase = NULL; + SIZE_T DesktopInfoSize; DECLARE_RETURN(HDESK); DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName); @@ -857,6 +871,39 @@ SetLastNtError(STATUS_UNSUCCESSFUL); RETURN( NULL); } + + DesktopObject->DesktopHeapSection = NULL; + DesktopObject->hDesktopHeap = UserCreateHeap(&DesktopObject->DesktopHeapSection, + &DesktopHeapSystemBase, + 4 * 1024 * 1024); /* FIXME */ + if (DesktopObject->hDesktopHeap == NULL) + { + ObDereferenceObject(DesktopObject); + DPRINT1("Failed to create desktop heap!\n"); + RETURN(NULL); + } + + DesktopInfoSize = FIELD_OFFSET(DESKTOP, + szDesktopName[(lpszDesktopName->Length / sizeof(WCHAR)) + 1]); + + DesktopObject->DesktopInfo = RtlAllocateHeap(DesktopObject->hDesktopHeap, + HEAP_NO_SERIALIZE, + DesktopInfoSize); + + if (DesktopObject->DesktopInfo == NULL) + { + ObDereferenceObject(DesktopObject); + DPRINT1("Failed to create the DESKTOP structure!\n"); + RETURN(NULL); + } + + RtlZeroMemory(DesktopObject->DesktopInfo, + DesktopInfoSize); + + DesktopObject->DesktopInfo->hKernelHeap = DesktopObject->hDesktopHeap; + RtlCopyMemory(DesktopObject->DesktopInfo->szDesktopName, + lpszDesktopName->Buffer, + lpszDesktopName->Length); // init desktop area DesktopObject->WorkArea.left = 0; @@ -1216,7 +1263,7 @@ RETURN(FALSE); } - DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE); //fixme: verify retval + DesktopBrush = (HBRUSH)UserGetClassLongPtr(WndDesktop->Class, GCL_HBRBACKGROUND, FALSE); /* @@ -1560,6 +1607,183 @@ END_CLEANUP; } +static NTSTATUS +IntUnmapDesktopView(IN PDESKTOP_OBJECT DesktopObject) +{ + PW32THREADINFO ti; + PW32HEAP_USER_MAPPING HeapMapping, *PrevLink = &PsGetWin32Process()->HeapMappings.Next; + NTSTATUS Status = STATUS_SUCCESS; + + /* unmap if we're the last thread using the desktop */ + HeapMapping = *PrevLink; + while (HeapMapping != NULL) + { + if (HeapMapping->KernelMapping == (PVOID)DesktopObject->hDesktopHeap) + { + if (--HeapMapping->Count == 0) + { + *PrevLink = HeapMapping->Next; + + Status = MmUnmapViewOfSection(PsGetCurrentProcess(), + HeapMapping->UserMapping); + + ObDereferenceObject(DesktopObject); + + UserHeapFree(HeapMapping); + break; + } + } + + PrevLink = &HeapMapping->Next; + HeapMapping = HeapMapping->Next; + } + + ti = GetW32ThreadInfo(); + if (ti != NULL) + { + if (ti->Desktop == DesktopObject->DesktopInfo) + { + ti->Desktop = NULL; + ti->DesktopHeapDelta = 0; + } + } + + return Status; +} + +static NTSTATUS +IntMapDesktopView(IN PDESKTOP_OBJECT DesktopObject) +{ + PW32THREADINFO ti; + PW32HEAP_USER_MAPPING HeapMapping, *PrevLink = &PsGetWin32Process()->HeapMappings.Next; + PVOID UserBase = NULL; + ULONG ViewSize = 0; + LARGE_INTEGER Offset; + NTSTATUS Status; + + /* find out if another thread already mapped the desktop heap */ + HeapMapping = *PrevLink; + while (HeapMapping != NULL) + { + if (HeapMapping->KernelMapping == (PVOID)DesktopObject->hDesktopHeap) + { + HeapMapping->Count++; + return STATUS_SUCCESS; + } + + PrevLink = &HeapMapping->Next; + HeapMapping = HeapMapping->Next; + } + + /* we're the first, map the heap */ + Offset.QuadPart = 0; + Status = MmMapViewOfSection(DesktopObject->DesktopHeapSection, + PsGetCurrentProcess(), + &UserBase, + 0, + 0, + &Offset, + &ViewSize, + ViewUnmap, + SEC_NO_CHANGE, + PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */ + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to map desktop\n"); + return Status; + } + + /* add the mapping */ + HeapMapping = UserHeapAlloc(sizeof(W32HEAP_USER_MAPPING)); + if (HeapMapping == NULL) + { + MmUnmapViewOfSection(PsGetCurrentProcess(), + UserBase); + return STATUS_NO_MEMORY; + } + + HeapMapping->Next = NULL; + HeapMapping->KernelMapping = (PVOID)DesktopObject->hDesktopHeap; + HeapMapping->UserMapping = UserBase; + HeapMapping->Count = 1; + + ObReferenceObject(DesktopObject); + + /* create a W32THREADINFO structure if not already done, or update it */ + ti = GetW32ThreadInfo(); + if (ti != NULL) + { + if (ti->Desktop == NULL) + { + ti->Desktop = DesktopObject->DesktopInfo; + ti->DesktopHeapDelta = DesktopHeapGetUserDelta(); + } + } + + return STATUS_SUCCESS; +} + +BOOL +IntSetThreadDesktop(IN PDESKTOP_OBJECT DesktopObject) +{ + PDESKTOP_OBJECT OldDesktop; + PW32THREAD W32Thread; + NTSTATUS Status; + BOOL MapHeap; + + MapHeap = (PsGetCurrentProcess() != PsInitialSystemProcess); + W32Thread = PsGetWin32Thread(); + + if (W32Thread->Desktop != DesktopObject) + { + OldDesktop = W32Thread->Desktop; + + W32Thread->Desktop = DesktopObject; + + if (MapHeap && DesktopObject != NULL) + { + Status = IntMapDesktopView(DesktopObject); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + } + + if (DesktopObject != NULL) + { + ObReferenceObject(DesktopObject); + } + + if (OldDesktop != NULL) + { + if (MapHeap) + { + IntUnmapDesktopView(OldDesktop); + } + + ObDereferenceObject(OldDesktop); + + if (W32Thread != NULL && W32Thread->ThreadInfo != NULL && + W32Thread->ThreadInfo->Desktop != (DesktopObject != NULL ? DesktopObject->DesktopInfo : NULL)) + { + if (DesktopObject != NULL) + { + W32Thread->ThreadInfo->Desktop = DesktopObject->DesktopInfo; + W32Thread->ThreadInfo->DesktopHeapDelta = DesktopHeapGetUserDelta(); + } + else + { + W32Thread->ThreadInfo->Desktop = NULL; + W32Thread->ThreadInfo->DesktopHeapDelta = 0; + } + } + } + } + + return TRUE; +} + /* * NtUserSetThreadDesktop * @@ -1570,7 +1794,6 @@ BOOL STDCALL NtUserSetThreadDesktop(HDESK hDesktop) { - PW32THREAD W32Thread; PDESKTOP_OBJECT DesktopObject; NTSTATUS Status; DECLARE_RETURN(BOOL); @@ -1591,17 +1814,12 @@ RETURN(FALSE); } - W32Thread = PsGetWin32Thread(); - /* FIXME: Should check here to see if the thread has any windows. */ - if (W32Thread->Desktop != NULL) - { - ObDereferenceObject(W32Thread->Desktop); - } - - W32Thread->Desktop = DesktopObject; - W32Thread->hDesktop = hDesktop; + if (!IntSetThreadDesktop(DesktopObject)) + { + RETURN(FALSE); + } RETURN(TRUE); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/hook.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/hook.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/hook.c Wed Apr 5 12:05:55 2006 @@ -69,7 +69,7 @@ return NULL; } - Hook = (PHOOK)UserGetObject(&gHandleTable, hHook, otHook); + Hook = (PHOOK)UserGetObject(gHandleTable, hHook, otHook); if (!Hook) { SetLastWin32Error(ERROR_INVALID_HOOK_HANDLE); @@ -110,7 +110,7 @@ } } - Hook = ObmCreateObject(&gHandleTable, &Handle, otHook, sizeof(HOOK)); + Hook = ObmCreateObject(gHandleTable, &Handle, otHook, sizeof(HOOK)); if (NULL == Hook) { return NULL; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/menu.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/menu.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/menu.c Wed Apr 5 12:05:55 2006 @@ -127,7 +127,7 @@ return NULL; } - Menu = (PMENU_OBJECT)UserGetObject(&gHandleTable, hMenu, otMenu); + Menu = (PMENU_OBJECT)UserGetObject(gHandleTable, hMenu, otMenu); if (!Menu) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); @@ -310,7 +310,7 @@ PMENU_OBJECT Menu; Menu = (PMENU_OBJECT)ObmCreateObject( - &gHandleTable, Handle, + gHandleTable, Handle, otMenu, sizeof(MENU_OBJECT)); if(!Menu) @@ -419,7 +419,7 @@ return NULL; Menu = (PMENU_OBJECT)ObmCreateObject( - &gHandleTable, &hMenu, + gHandleTable, &hMenu, otMenu, sizeof(MENU_OBJECT)); if(!Menu) Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/message.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c Wed Apr 5 12:05:55 2006 @@ -378,28 +378,9 @@ MsgInfo.HandledByKernel = FALSE; Result = 0; - if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) - { - if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000)) - { - /* Both Unicode and Ansi winprocs are real, use whatever - usermode prefers */ - MsgInfo.Proc = (MsgInfo.Ansi ? Window->WndProcA - : Window->WndProcW); - } - else - { - /* Real Unicode winproc */ - MsgInfo.Ansi = FALSE; - MsgInfo.Proc = Window->WndProcW; - } - } - else - { - /* Must have real Ansi winproc */ - MsgInfo.Ansi = TRUE; - MsgInfo.Proc = Window->WndProcA; - } + + MsgInfo.Ansi = !Window->Unicode; + MsgInfo.Proc = Window->WndProc; } } } @@ -615,7 +596,7 @@ { /* generate double click messages, if necessary */ if ((((*HitTest) != HTCLIENT) || - (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) && + (Window->Class->Style & CS_DBLCLKS)) && MsqIsDblClk(Msg, Remove)) { Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN; @@ -1401,16 +1382,9 @@ DPRINT1("Failed to pack message parameters\n"); RETURN( FALSE); } - if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) - { - Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam, - lParamPacked,lParamBufferSize); - } - else - { - Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam, - lParamPacked,lParamBufferSize); - } + + Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProc, !Window->Unicode, hWnd, Msg, wParam, + lParamPacked,lParamBufferSize); if(uResult) { @@ -1580,32 +1554,16 @@ { /* Gather the information usermode needs to call the window proc directly */ Info.HandledByKernel = FALSE; - if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) - { - if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000)) - { - /* Both Unicode and Ansi winprocs are real, see what usermode prefers */ - Status = MmCopyFromCaller(&(Info.Ansi), &(UnsafeInfo->Ansi), - sizeof(BOOL)); - if (! NT_SUCCESS(Status)) - { - Info.Ansi = ! Window->Unicode; - } - Info.Proc = (Info.Ansi ? Window->WndProcA : Window->WndProcW); - } - else - { - /* Real Unicode winproc */ - Info.Ansi = FALSE; - Info.Proc = Window->WndProcW; - } - } - else - { - /* Must have real Ansi winproc */ - Info.Ansi = TRUE; - Info.Proc = Window->WndProcA; - } + + Status = MmCopyFromCaller(&(Info.Ansi), &(UnsafeInfo->Ansi), + sizeof(BOOL)); + if (! NT_SUCCESS(Status)) + { + Info.Ansi = ! Window->Unicode; + } + + Info.Ansi = !Window->Unicode; + Info.Proc = Window->WndProc; } else { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c Wed Apr 5 12:05:55 2006 @@ -886,11 +886,22 @@ DECLARE_RETURN(DWORD); DPRINT("Enter NtUserGetThreadState\n"); - UserEnterShared(); + if (Routine != THREADSTATE_GETTHREADINFO) + { + UserEnterShared(); + } + else + { + UserEnterExclusive(); + } switch (Routine) { - case 0: + case THREADSTATE_GETTHREADINFO: + GetW32ThreadInfo(); + RETURN(0); + + case THREADSTATE_FOCUSWINDOW: RETURN( (DWORD)IntGetThreadFocusWindow()); } RETURN( 0); @@ -1829,4 +1840,106 @@ END_CLEANUP; } +PW32PROCESSINFO +GetW32ProcessInfo(VOID) +{ + PW32PROCESSINFO pi; + PW32PROCESS W32Process = PsGetWin32Process(); + + if (W32Process == NULL) + { + /* FIXME - temporary hack for system threads... */ + return NULL; + } + + if (W32Process->ProcessInfo == NULL) + { + pi = UserHeapAlloc(sizeof(W32PROCESSINFO)); + if (pi != NULL) + { + RtlZeroMemory(pi, + sizeof(W32PROCESSINFO)); + + /* initialize it */ + pi->UserHandleTable = gHandleTable; + + if (InterlockedCompareExchangePointer(&W32Process->ProcessInfo, + pi, + NULL) != NULL) + { + UserHeapFree(pi); + } + } + else + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + } + } + + return W32Process->ProcessInfo; +} + +PW32THREADINFO +GetW32ThreadInfo(VOID) +{ + PTEB Teb; + PW32THREADINFO ti; + PW32THREAD W32Thread = PsGetWin32Thread(); + + if (W32Thread == NULL) + { + /* FIXME - temporary hack for system threads... */ + return NULL; + } + + /* allocate a W32THREAD structure if neccessary */ + if (W32Thread->ThreadInfo == NULL) + { + ti = UserHeapAlloc(sizeof(W32THREADINFO)); + if (ti != NULL) + { + RtlZeroMemory(ti, + sizeof(W32THREADINFO)); + + /* initialize it */ + ti->kpi = GetW32ProcessInfo(); + ti->pi = UserHeapAddressToUser(ti->kpi); + if (W32Thread->Desktop != NULL) + { + ti->Desktop = W32Thread->Desktop->DesktopInfo; + ti->DesktopHeapDelta = DesktopHeapGetUserDelta(); + } + else + { + ti->Desktop = NULL; + ti->DesktopHeapDelta = 0; + } + + W32Thread->ThreadInfo = ti; + /* update the TEB */ + Teb = NtCurrentTeb(); + _SEH_TRY + { + ProbeForWrite(Teb, + sizeof(TEB), + sizeof(ULONG)); + + Teb->Win32ThreadInfo = UserHeapAddressToUser(W32Thread->ThreadInfo); + } + _SEH_HANDLE + { + SetLastNtError(_SEH_GetExceptionCode()); + } + _SEH_END; + } + else + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + } + } + + return W32Thread->ThreadInfo; +} + + /* EOF */ Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c Wed Apr 5 12:05:55 2006 @@ -89,7 +89,7 @@ HANDLE Handle; PMONITOR_OBJECT Monitor; - Monitor = ObmCreateObject(&gHandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT)); + Monitor = ObmCreateObject(gHandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT)); if (Monitor == NULL) { return NULL; @@ -133,7 +133,7 @@ } - Monitor = (PMONITOR_OBJECT)UserGetObject(&gHandleTable, hMonitor, otMonitor); + Monitor = (PMONITOR_OBJECT)UserGetObject(gHandleTable, hMonitor, otMonitor); if (!Monitor) { SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/object.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/object.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/object.c Wed Apr 5 12:05:55 2006 @@ -28,7 +28,7 @@ #include <debug.h> int usedHandles=0; -USER_HANDLE_TABLE gHandleTable; +PUSER_HANDLE_TABLE gHandleTable = NULL; PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle ) @@ -71,19 +71,17 @@ DPRINT1("Out of user handles!\n"); return NULL; #if 0 - - struct user_handle *new_handles; + PUSER_HANDLE_ENTRY new_handles; /* grow array by 50% (but at minimum 32 entries) */ - int growth = max( 32, allocated_handles / 2 ); - int new_size = min( allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 ); - if (new_size <= allocated_handles) + int growth = max( 32, ht->allocated_handles / 2 ); + int new_size = min( ht->allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 ); + if (new_size <= ht->allocated_handles) return NULL; - if (!(new_handles = realloc( handles, new_size * sizeof(*handles) ))) + if (!(new_handles = UserHeapReAlloc( ht->handles, new_size * sizeof(*ht->handles) ))) return NULL; - handles = new_handles; - allocated_handles = new_size; + ht->handles = new_handles; + ht->allocated_handles = new_size; #endif - } entry = &ht->handles[ht->nb_handles++]; @@ -217,7 +215,7 @@ { HANDLE hi; - PUSER_OBJECT_HEADER hdr = ExAllocatePool(PagedPool, size + sizeof(USER_OBJECT_HEADER)); + PUSER_OBJECT_HEADER hdr = UserHeapAlloc(size + sizeof(USER_OBJECT_HEADER));//ExAllocatePool(PagedPool, size + sizeof(USER_OBJECT_HEADER)); if (!hdr) return NULL; @@ -225,7 +223,8 @@ hi = UserAllocHandle(ht, USER_HEADER_TO_BODY(hdr), type ); if (!hi) { - ExFreePool(hdr); + //ExFreePool(hdr); + UserHeapFree(hdr); return NULL; } @@ -242,7 +241,7 @@ ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type ) { PUSER_OBJECT_HEADER hdr; - PVOID body = UserGetObject(&gHandleTable, h, type); + PVOID body = UserGetObject(gHandleTable, h, type); if (!body) return FALSE; @@ -252,11 +251,12 @@ hdr->destroyed = TRUE; if (hdr->RefCount == 0) { - UserFreeHandle(&gHandleTable, h); + UserFreeHandle(gHandleTable, h); memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER)); - ExFreePool(hdr); + UserHeapFree(hdr); + //ExFreePool(hdr); return TRUE; } @@ -274,6 +274,12 @@ hdr->RefCount++; } +HANDLE FASTCALL ObmObjectToHandle(PVOID obj) +{ + PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj); + return hdr->hSelf; +} + BOOL FASTCALL ObmDereferenceObject2(PVOID obj) { @@ -287,11 +293,12 @@ { // DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles); - UserFreeHandle(&gHandleTable, hdr->hSelf); + UserFreeHandle(gHandleTable, hdr->hSelf); memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER)); - ExFreePool(hdr); + UserHeapFree(hdr); + //ExFreePool(hdr); return TRUE; } @@ -307,15 +314,24 @@ PVOID mem; //FIXME: dont alloc all at once! must be mapped into umode also... - mem = ExAllocatePool(PagedPool, sizeof(USER_HANDLE_ENTRY) * 1024*2); + //mem = ExAllocatePool(PagedPool, sizeof(USER_HANDLE_ENTRY) * 1024*2); + mem = UserHeapAlloc(sizeof(USER_HANDLE_ENTRY) * 1024*2); if (!mem) { DPRINT1("Failed creating handle table\n"); return FALSE; } + gHandleTable = UserHeapAlloc(sizeof(USER_HANDLE_TABLE)); + if (gHandleTable == NULL) + { + UserHeapFree(mem); + DPRINT1("Failed creating handle table\n"); + return FALSE; + } + //FIXME: make auto growable - UserInitHandleTable(&gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024*2); + UserInitHandleTable(gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024*2); return TRUE; } Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c Wed Apr 5 12:05:55 2006 @@ -353,7 +353,7 @@ if (!(Flags & DCX_WINDOW)) { - if (Window->Class->style & CS_PARENTDC) + if (Window->Class->Style & CS_PARENTDC) { Flags |= DCX_PARENTCLIP; } @@ -676,7 +676,7 @@ { if (pDCE == Window->Dce) /* owned or Class DCE*/ { - if (Window->Class->style & CS_OWNDC) /* owned DCE*/ + if (Window->Class->Style & CS_OWNDC) /* owned DCE*/ { pDCE = DceFreeDCE(pDCE, FALSE); Window->Dce = NULL; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Wed Apr 5 12:05:55 2006 @@ -33,10 +33,6 @@ #define NDEBUG #include <debug.h> -static WndProcHandle *WndProcHandlesArray = 0; -static WORD WndProcHandlesArraySize = 0; -#define WPH_SIZE 0x40 /* the size to add to the WndProcHandle array each time */ - /* dialog resources appear to pass this in 16 bits, handle them properly */ #define CW_USEDEFAULT16 (0x8000) @@ -53,8 +49,6 @@ NTSTATUS FASTCALL InitWindowImpl(VOID) { - WndProcHandlesArray = ExAllocatePoolWithTag(PagedPool,WPH_SIZE * sizeof(WndProcHandle), TAG_WINPROCLST); - WndProcHandlesArraySize = WPH_SIZE; return STATUS_SUCCESS; } @@ -67,9 +61,6 @@ NTSTATUS FASTCALL CleanupWindowImpl(VOID) { - ExFreePool(WndProcHandlesArray); - WndProcHandlesArray = 0; - WndProcHandlesArraySize = 0; return STATUS_SUCCESS; } @@ -95,15 +86,26 @@ /* temp hack */ PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd) { + PW32THREADINFO ti; PWINDOW_OBJECT Window; - + + if (PsGetCurrentProcess() != PsInitialSystemProcess) + { + ti = GetW32ThreadInfo(); + if (ti == NULL) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return NULL; + } + } + if (!hWnd) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); return NULL; } - Window = (PWINDOW_OBJECT)UserGetObject(&gHandleTable, hWnd, otWindow); + Window = (PWINDOW_OBJECT)UserGetObject(gHandleTable, hWnd, otWindow); if (!Window || 0 != (Window->Status & WINDOWSTATUS_DESTROYED)) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); @@ -432,8 +434,16 @@ IntDestroyScrollBars(Window); + if (!Window->Class->System && Window->CallProc != NULL) + { + DestroyCallProc(Window->ti->Desktop, + Window->CallProc); + } + /* dereference the class */ - ClassDerefObject(Window->Class); + IntDereferenceClass(Window->Class, + Window->ti->Desktop, + Window->ti->kpi); Window->Class = NULL; if(Window->WindowRegion) @@ -473,6 +483,57 @@ *cx = *cy = 0; } } +} + +static WNDPROC +IntGetWindowProc(IN PWINDOW_OBJECT Window, + IN BOOL Ansi) +{ + if (Window->IsSystem) + { + return (Ansi ? Window->WndProcExtra : Window->WndProc); + } + else + { + if (!Ansi == Window->Unicode) + { + return Window->WndProc; + } + else + { + if (Window->CallProc != NULL) + { + return (WNDPROC)ObmObjectToHandle(Window->CallProc); + } + else + { + PCALLPROC NewCallProc, CallProc; + + /* NOTE: use the interlocked functions, as this operation may be done even + when only the shared lock is held! */ + NewCallProc = CreateCallProc(Window->ti->Desktop, + Window->WndProc, + Window->Unicode, + Window->ti->kpi); + if (NewCallProc == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + CallProc = InterlockedCompareExchangePointer(&Window->CallProc, + NewCallProc, + NULL); + if (CallProc != NULL) + { + DestroyCallProc(Window->ti->Desktop, + NewCallProc); + } + + return (WNDPROC)ObmObjectToHandle((CallProc == NULL ? NewCallProc : CallProc)); + } + } + } } BOOL FASTCALL @@ -1333,7 +1394,8 @@ BOOL bUnicodeWindow) { PWINSTATION_OBJECT WinSta; - PWNDCLASS_OBJECT Class = NULL; + PWINDOWCLASS Class = NULL; + RTL_ATOM ClassAtom; PWINDOW_OBJECT Window = NULL; PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow; HWND ParentWindowHandle; @@ -1342,6 +1404,7 @@ HWND hWnd; POINT Pos; SIZE Size; + PW32THREADINFO ti = NULL; #if 0 POINT MaxSize, MaxPos, MinTrack, MaxTrack; @@ -1349,7 +1412,6 @@ POINT MaxPos; #endif - CREATESTRUCTW Cs; CBT_CREATEWNDW CbtCreate; LRESULT Result; @@ -1399,13 +1461,27 @@ /* FIXME: parent must belong to the current process */ + /* Check the window station. */ + ti = GetW32ThreadInfo(); + if (ti == NULL || PsGetWin32Thread()->Desktop == NULL) + { + DPRINT1("Thread is not attached to a desktop! Cannot create window!\n"); + RETURN( (HWND)0); + } + /* Check the class. */ - Class = ClassGetClassByNameOrAtom(ClassName->Buffer, hInstance); - if (!Class) + + ClassAtom = IntGetClassAtom(ClassName, + hInstance, + ti->kpi, + &Class, + NULL); + + if (ClassAtom == (RTL_ATOM)0) { if (IS_ATOM(ClassName->Buffer)) { - DPRINT1("Class 0x%x not found\n", (DWORD_PTR) ClassName->Buffer); + DPRINT1("Class 0x%p not found\n", (DWORD_PTR) ClassName->Buffer); } else { @@ -1416,14 +1492,14 @@ RETURN((HWND)0); } - ClassRefObject(Class); - - /* Check the window station. */ - if (PsGetWin32Thread()->Desktop == NULL) - { - DPRINT("Thread is not attached to a desktop! Cannot create window!\n"); - RETURN( (HWND)0); - } + Class = IntReferenceClass(Class, + ti->Desktop); + if (Class == NULL) + { + DPRINT1("Failed to reference window class!\n"); + RETURN(NULL); + } + WinSta = PsGetWin32Thread()->Desktop->WindowStation; //FIXME: Reference thread/desktop instead @@ -1431,8 +1507,8 @@ /* Create the window object. */ Window = (PWINDOW_OBJECT) - ObmCreateObject(&gHandleTable, (PHANDLE)&hWnd, - otWindow, sizeof(WINDOW_OBJECT) + Class->cbWndExtra + ObmCreateObject(gHandleTable, (PHANDLE)&hWnd, + otWindow, sizeof(WINDOW_OBJECT) + Class->WndExtra ); DPRINT("Created object with handle %X\n", hWnd); @@ -1456,6 +1532,7 @@ /* * Fill out the structure describing it. */ + Window->ti = ti; Window->Class = Class; Window->SystemMenu = (HMENU)0; Window->ContextHelpId = 0; @@ -1474,7 +1551,7 @@ { IntSetMenu(Window, hMenu, &MenuChanged); } - + Window->MessageQueue = PsGetWin32Thread()->MessageQueue; IntReferenceMessageQueue(Window->MessageQueue); Window->Parent = ParentWindow; @@ -1491,27 +1568,38 @@ } Window->UserData = 0; - - if ((((DWORD)Class->lpfnWndProcA & 0xFFFF0000) != 0xFFFF0000) - && (((DWORD)Class->lpfnWndProcW & 0xFFFF0000) != 0xFFFF0000)) - { - Window->Unicode = bUnicodeWindow; + + Window->IsSystem = Class->System; + if (Class->System) + { + Window->Unicode = bUnicodeWindow; + if (bUnicodeWindow) + { + Window->WndProc = Class->WndProc; + Window->WndProcExtra = Class->WndProcExtra; + } + else + { + Window->WndProc = Class->WndProcExtra; + Window->WndProcExtra = Class->WndProc; + } } else { - Window->Unicode = Class->Unicode; - } - Window->WndProcA = Class->lpfnWndProcA; - Window->WndProcW = Class->lpfnWndProcW; + Window->Unicode = Class->Unicode; + Window->WndProc = Class->WndProc; + Window->CallProc = NULL; + } + Window->OwnerThread = PsGetCurrentThread(); Window->FirstChild = NULL; Window->LastChild = NULL; Window->PrevSibling = NULL; Window->NextSibling = NULL; - Window->ExtraDataSize = Class->cbWndExtra; + Window->ExtraDataSize = Class->WndExtra; /* extra window data */ - if (Class->cbWndExtra) + if (Class->WndExtra) Window->ExtraData = (PCHAR)(Window + 1); InitializeListHead(&Window->PropListHead); @@ -1535,7 +1623,6 @@ { RtlInitUnicodeString(&Window->WindowName, NULL); } - /* * This has been tested for WS_CHILD | WS_VISIBLE. It has not been @@ -1931,7 +2018,15 @@ CLEANUP: if (Window) UserDerefObjectCo(Window); if (ParentWindow) UserDerefObjectCo(ParentWindow); - if (!_ret_ && Class) ClassDerefObject(Class); /* only deref if failure (return 0) */ + if (!_ret_ && ti != NULL) + { + if (Class != NULL) + { + IntDereferenceClass(Class, + ti->Desktop, + ti->kpi); + } + } END_CLEANUP; } @@ -1967,7 +2062,7 @@ SetLastNtError(Status); RETURN( NULL); } - if (! IS_ATOM(ClassName.Buffer)) + if (ClassName.Length != 0) { Status = IntSafeCopyUnicodeStringTerminateNULL(&ClassName, UnsafeClassName); if (! NT_SUCCESS(Status)) @@ -1975,6 +2070,11 @@ SetLastNtError(Status); RETURN( NULL); } + } + else if (! IS_INTRESOURCE(ClassName.Buffer)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return NULL; } /* safely copy the window name */ @@ -3254,10 +3354,8 @@ break; case GWL_WNDPROC: - if (Ansi) - Result = (LONG) Window->WndProcA; - else - Result = (LONG) Window->WndProcW; + Result = (LONG)IntGetWindowProc(Window, + Ansi); break; case GWL_HINSTANCE: @@ -3390,22 +3488,28 @@ break; case GWL_WNDPROC: + { /* FIXME: should check if window belongs to current process */ - if (Ansi) + if (Window->IsSystem) { - OldValue = (LONG) Window->WndProcA; - Window->WndProcA = (WNDPROC) NewValue; - Window->WndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)NewValue,FALSE); - Window->Unicode = FALSE; + /* the user changes the window procedure, the window is no longer + directly derived from the system class, because it no longer + uses independent window procedures for ansi and unicode */ + Window->IsSystem = FALSE; + Window->CallProc = NULL; } - else + + /* update the window procedure */ + OldValue = (LONG)Window->WndProc; + Window->WndProc = (WNDPROC)NewValue; + if (Window->CallProc != NULL) { - OldValue = (LONG) Window->WndProcW; - Window->WndProcW = (WNDPROC) NewValue; - Window->WndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)NewValue,TRUE); - Window->Unicode = TRUE; + Window->CallProc->WndProc = (WNDPROC)NewValue; + Window->CallProc->Unicode = !Ansi; } + Window->Unicode = !Ansi; break; + } case GWL_HINSTANCE: OldValue = (LONG) Window->Instance; @@ -4404,99 +4508,6 @@ END_CLEANUP; } -DWORD STDCALL -NtUserDereferenceWndProcHandle(WNDPROC wpHandle, WndProcHandle *Data) -{ - DECLARE_RETURN(DWORD); - WndProcHandle Entry; - - DPRINT("Enter NtUserDereferenceWndProcHandle\n"); - UserEnterShared(); - - if (((DWORD)wpHandle & 0xFFFF0000) == 0xFFFF0000) - { - Entry = WndProcHandlesArray[(DWORD)wpHandle & 0x0000FFFF]; - Data->WindowProc = Entry.WindowProc; - Data->IsUnicode = Entry.IsUnicode; - Data->ProcessID = Entry.ProcessID; - RETURN( TRUE); - } - else - { - RETURN( FALSE); - } - RETURN( FALSE); - -CLEANUP: - DPRINT("Leave NtUserDereferenceWndProcHandle, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - -DWORD -IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode) -{ - WORD i; - WORD FreeSpot = 0; - BOOL found; - WndProcHandle *OldArray; - WORD OldArraySize; - found = FALSE; - for (i = 0;i < WndProcHandlesArraySize;i++) - { - if (WndProcHandlesArray[i].WindowProc == NULL) - { - FreeSpot = i; - found = TRUE; - } - } - if (!found) - { - OldArray = WndProcHandlesArray; - OldArraySize = WndProcHandlesArraySize; - WndProcHandlesArray = ExAllocatePoolWithTag(PagedPool,(OldArraySize + WPH_SIZE) * sizeof(WndProcHandle), TAG_WINPROCLST); - WndProcHandlesArraySize = OldArraySize + WPH_SIZE; - RtlCopyMemory(WndProcHandlesArray,OldArray,OldArraySize * sizeof(WndProcHandle)); - ExFreePool(OldArray); - FreeSpot = OldArraySize + 1; - } - WndProcHandlesArray[FreeSpot].WindowProc = WindowProc; - WndProcHandlesArray[FreeSpot].IsUnicode = IsUnicode; - WndProcHandlesArray[FreeSpot].ProcessID = PsGetCurrentProcessId(); - return FreeSpot + 0xFFFF0000; -} - -DWORD -IntRemoveWndProcHandle(WNDPROC Handle) -{ - WORD position; - position = (DWORD)Handle & 0x0000FFFF; - if (position > WndProcHandlesArraySize) - { - return FALSE; - } - WndProcHandlesArray[position].WindowProc = NULL; - WndProcHandlesArray[position].IsUnicode = FALSE; - WndProcHandlesArray[position].ProcessID = NULL; - return TRUE; -} - -DWORD -IntRemoveProcessWndProcHandles(HANDLE ProcessID) -{ - WORD i; - for (i = 0;i < WndProcHandlesArraySize;i++) - { - if (WndProcHandlesArray[i].ProcessID == ProcessID) - { - WndProcHandlesArray[i].WindowProc = NULL; - WndProcHandlesArray[i].IsUnicode = FALSE; - WndProcHandlesArray[i].ProcessID = NULL; - } - } - return TRUE; -} - #define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040) BOOL Modified: trunk/reactos/subsystems/win32/win32k/w32k.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/w32…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/w32k.h (original) +++ trunk/reactos/subsystems/win32/win32k/w32k.h Wed Apr 5 12:05:55 2006 @@ -1,3 +1,5 @@ +#ifndef __W32K_H +#define __W32K_H /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Graphics Subsystem @@ -68,3 +70,77 @@ #define M_PI_2 1.57079632679489661923 #endif +/* User heap */ +extern HANDLE GlobalUserHeap; + +HANDLE +UserCreateHeap(OUT PSECTION_OBJECT *SectionObject, + IN OUT PVOID *SystemBase, + IN ULONG HeapSize); + +static __inline PVOID +UserHeapAlloc(SIZE_T Bytes) +{ + return RtlAllocateHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + Bytes); +} + +static __inline BOOL +UserHeapFree(PVOID lpMem) +{ + return RtlFreeHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + lpMem); +} + +static __inline PVOID +UserHeapReAlloc(PVOID lpMem, + SIZE_T Bytes) +{ +#if 0 + /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */ + return RtlReAllocateHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + lpMem, + Bytes); +#else + SIZE_T PrevSize; + PVOID pNew; + + PrevSize = RtlSizeHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + lpMem); + + if (PrevSize == Bytes) + return lpMem; + + pNew = RtlAllocateHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + Bytes); + if (pNew != NULL) + { + if (PrevSize < Bytes) + Bytes = PrevSize; + + RtlCopyMemory(pNew, + lpMem, + Bytes); + + RtlFreeHeap(GlobalUserHeap, + HEAP_NO_SERIALIZE, + lpMem); + } + + return pNew; +#endif +} + +static __inline PVOID +UserHeapAddressToUser(PVOID lpMem) +{ + return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) + + (ULONG_PTR)PsGetWin32Process()->HeapMappings.UserMapping); +} + +#endif /* __W32K_H */ Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/win…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/win32k.rbuild (original) +++ trunk/reactos/subsystems/win32/win32k/win32k.rbuild Wed Apr 5 12:05:55 2006 @@ -64,14 +64,15 @@ <file>err.c</file> <file>math.c</file> <file>copy.c</file> + <file>usrheap.c</file> </compilationunit> <directory name="i386"> - <file>cos_asm.s</file> - <file>sin_asm.s</file> - <file>atan2_asm.s</file> - <file>floor_asm.s</file> - <file>ceil_asm.s</file> - </directory> + <file>cos_asm.s</file> + <file>sin_asm.s</file> + <file>atan2_asm.s</file> + <file>floor_asm.s</file> + <file>ceil_asm.s</file> + </directory> </directory> <directory name="ntddraw"> <compilationunit name="ntddraw.c"> Modified: trunk/reactos/tools/nci/w32ksvc.db URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/tools/nci/w32ksvc.db?rev=21…
============================================================================== --- trunk/reactos/tools/nci/w32ksvc.db (original) +++ trunk/reactos/tools/nci/w32ksvc.db Wed Apr 5 12:05:55 2006 @@ -356,7 +356,7 @@ NtUserGetCapture 0 NtUserGetCaretBlinkTime 0 NtUserGetCaretPos 1 -NtUserGetClassInfo 5 +NtUserGetClassInfo 4 NtUserGetClassLong 3 NtUserGetClassName 3 NtUserGetClientOrigin 2 @@ -457,7 +457,7 @@ NtUserReleaseDC 2 NtUserRealChildWindowFromPoint 3 NtUserRedrawWindow 4 -NtUserRegisterClassExWOW 8 +NtUserRegisterClassEx 6 NtUserRegisterHotKey 4 NtUserRegisterTasklist 1 NtUserRegisterWindowMessage 1 @@ -536,7 +536,7 @@ NtUserUnhookWinEvent 1 NtUserUnloadKeyboardLayout 1 NtUserUnlockWindowStation 1 -NtUserUnregisterClass 3 +NtUserUnregisterClass 2 NtUserUnregisterHotKey 2 NtUserUpdateInputContext 3 NtUserUpdateInstance 3
1
0
0
0
[peterw] 21459: [AUDIT] reactos\tools\nci (Unlocked): - No reason for this to be locked (obviously clean).
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: peterw Date: Wed Apr 5 11:45:46 2006 New Revision: 21459 URL:
http://svn.reactos.ru/svn/reactos?rev=21459&view=rev
Log: [AUDIT] reactos\tools\nci (Unlocked): - No reason for this to be locked (obviously clean). Modified: trunk/reactos/tools/nci/nci.mak (props changed) trunk/reactos/tools/nci/ncitool.c (props changed) trunk/reactos/tools/nci/sysfuncs.lst (props changed) trunk/reactos/tools/nci/w32ksvc.db (props changed) Propchange: trunk/reactos/tools/nci/nci.mak ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/tools/nci/ncitool.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/tools/nci/sysfuncs.lst ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -* Propchange: trunk/reactos/tools/nci/w32ksvc.db ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*
1
0
0
0
[tretiakov] 21458: Implement RpcSmDestroyClientContext and RpcSsDestroyClientContext
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: tretiakov Date: Wed Apr 5 11:00:28 2006 New Revision: 21458 URL:
http://svn.reactos.ru/svn/reactos?rev=21458&view=rev
Log: Implement RpcSmDestroyClientContext and RpcSsDestroyClientContext Modified: trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c trunk/reactos/dll/win32/rpcrt4/rpcrt4.spec Modified: trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/rpcrt4/ndr_marsha…
============================================================================== --- trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c (original) +++ trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c Wed Apr 5 11:00:28 2006 @@ -3351,6 +3351,9 @@ return NULL; } +/*********************************************************************** + * NDRCContextBinding + */ RPC_BINDING_HANDLE WINAPI NDRCContextBinding(NDR_CCONTEXT CContext) { if(!CContext) @@ -3358,3 +3361,35 @@ return (RPC_BINDING_HANDLE)((CContextHandle*)CContext)->Binding; } + +/*********************************************************************** + * RpcSmDestroyClientContext + */ +RPC_STATUS WINAPI RpcSmDestroyClientContext(void** ContextHandle) +{ + CContextHandle *ctx = (CContextHandle*)ContextHandle; + + if(!ctx) + return RPC_X_SS_CONTEXT_MISMATCH; + + RPCRT4_DestroyBinding(ctx->Binding); + HeapFree(GetProcessHeap(), 0, ctx); + *ContextHandle = NULL; + + return RPC_S_OK; +} + +/*********************************************************************** + * RpcSsDestroyClientContext + */ +void WINAPI RpcSsDestroyClientContext(void** ContextHandle) +{ + RPC_STATUS status; + + status = RpcSmDestroyClientContext(ContextHandle); + + if(status != RPC_S_OK) + RpcRaiseException(status); +} + + Modified: trunk/reactos/dll/win32/rpcrt4/rpcrt4.spec URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/rpcrt4/rpcrt4.spe…
============================================================================== --- trunk/reactos/dll/win32/rpcrt4/rpcrt4.spec (original) +++ trunk/reactos/dll/win32/rpcrt4/rpcrt4.spec Wed Apr 5 11:00:28 2006 @@ -494,7 +494,7 @@ @ stub RpcServerYield @ stub RpcSmAllocate @ stub RpcSmClientFree -@ stub RpcSmDestroyClientContext +@ stdcall RpcSmDestroyClientContext (ptr) @ stub RpcSmDisableAllocate @ stub RpcSmEnableAllocate @ stub RpcSmFree @@ -505,7 +505,7 @@ @ stub RpcSsAllocate @ stub RpcSsContextLockExclusive # wxp @ stub RpcSsContextLockShared # wxp -@ stub RpcSsDestroyClientContext +@ stdcall RpcSsDestroyClientContext (ptr) @ stub RpcSsDisableAllocate @ stub RpcSsDontSerializeContext @ stub RpcSsEnableAllocate
1
0
0
0
[greatlrd] 21457: Start implement HAL Createsurface The code are from my test apps and base on Steffen Schulze, it need more modifaction before it is complete. for now it create primare and overlay with rgb and most graphic card does not support that thx again Steffen Schulze for the info
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: greatlrd Date: Wed Apr 5 09:43:18 2006 New Revision: 21457 URL:
http://svn.reactos.ru/svn/reactos?rev=21457&view=rev
Log: Start implement HAL Createsurface The code are from my test apps and base on Steffen Schulze, it need more modifaction before it is complete. for now it create primare and overlay with rgb and most graphic card does not support that thx again Steffen Schulze for the info Modified: trunk/reactos/dll/directx/ddraw/hal/surface_hal.c trunk/reactos/dll/directx/ddraw/main/ddraw_main.c trunk/reactos/dll/directx/ddraw/rosdraw.h trunk/reactos/dll/directx/ddraw/soft/surface_hel.c Modified: trunk/reactos/dll/directx/ddraw/hal/surface_hal.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/hal/surfa…
============================================================================== --- trunk/reactos/dll/directx/ddraw/hal/surface_hal.c (original) +++ trunk/reactos/dll/directx/ddraw/hal/surface_hal.c Wed Apr 5 09:43:18 2006 @@ -11,6 +11,259 @@ #include "rosdraw.h" +HRESULT Hal_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter) +{ + UINT i; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + /* create primare surface now */ + + memset(&This->mddsdPrimary, 0, sizeof(DDSURFACEDESC)); + This->mddsdPrimary.dwSize = sizeof(DDSURFACEDESC); + This->mddsdPrimary.dwFlags = DDSD_CAPS; + This->mddsdPrimary.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY | DDSCAPS_VISIBLE; + + DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface; + mDdCanCreateSurface.lpDD = &This->mDDrawGlobal; + mDdCanCreateSurface.CanCreateSurface = This->mCallbacks.HALDD.CanCreateSurface; + mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; //isDifferentPixelFormat; + mDdCanCreateSurface.lpDDSurfaceDesc = &This->mddsdPrimary; // pDDSD; + + + if (This->mHALInfo.lpDDCallbacks->CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED) + { + // derr(L"DirectDrawImpl[%08x]::__createPrimary Cannot create primary [%08x]", this, rv); + return DDERR_NOTINITIALIZED; + } + + if (mDdCanCreateSurface.ddRVal != DD_OK) + { + return DDERR_NOTINITIALIZED; + } + + memset(&This->mPrimaryGlobal, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL)); + This->mPrimaryGlobal.dwGlobalFlags = DDRAWISURFGBL_ISGDISURFACE; + This->mPrimaryGlobal.lpDD = &This->mDDrawGlobal; + This->mPrimaryGlobal.lpDDHandle = &This->mDDrawGlobal; + This->mPrimaryGlobal.wWidth = (WORD)This->mpModeInfos[0].dwWidth; + This->mPrimaryGlobal.wHeight = (WORD)This->mpModeInfos[0].dwHeight; + This->mPrimaryGlobal.lPitch = This->mpModeInfos[0].lPitch; + + memset(&This->mPrimaryMore, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); + This->mPrimaryMore.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); + + memset(&This->mPrimaryLocal, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); + This->mPrimaryLocal.lpGbl = &This->mPrimaryGlobal; + This->mPrimaryLocal.lpSurfMore = &This->mPrimaryMore; + This->mPrimaryLocal.dwProcessId = GetCurrentProcessId(); + This->mPrimaryLocal.dwFlags = DDRAWISURF_PARTOFPRIMARYCHAIN|DDRAWISURF_HASOVERLAYDATA; + This->mPrimaryLocal.ddsCaps.dwCaps = This->mddsdPrimary.ddsCaps.dwCaps; + + This->mpPrimaryLocals[0] = &This->mPrimaryLocal; + + DDHAL_CREATESURFACEDATA mDdCreateSurface; + mDdCreateSurface.lpDD = &This->mDDrawGlobal; + mDdCreateSurface.CreateSurface = This->mCallbacks.HALDD.CreateSurface; + mDdCreateSurface.lpDDSurfaceDesc = &This->mddsdPrimary;//pDDSD; + mDdCreateSurface.lplpSList = This->mpPrimaryLocals; //cSurfaces; + mDdCreateSurface.dwSCnt = 1 ; //ppSurfaces; + + if (This->mHALInfo.lpDDCallbacks->CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED) + { + return DDERR_NOTINITIALIZED; + } + + + if (mDdCreateSurface.ddRVal != DD_OK) + { + return mDdCreateSurface.ddRVal; + } + + // -- Setup Clipper --------------------------------------------------------- + memset(&This->mPrimaryClipperGlobal, 0, sizeof(DDRAWI_DDRAWCLIPPER_GBL)); + This->mPrimaryClipperGlobal.dwFlags = DDRAWICLIP_ISINITIALIZED; + This->mPrimaryClipperGlobal.dwProcessId = GetCurrentProcessId(); + //mPrimaryClipperGlobal.hWnd = (ULONG_PTR)hwnd; + This->mPrimaryClipperGlobal.hWnd = (ULONG_PTR)GetDesktopWindow(); + This->mPrimaryClipperGlobal.lpDD = &This->mDDrawGlobal; + This->mPrimaryClipperGlobal.lpStaticClipList = NULL; + + memset(&This->mPrimaryClipperLocal, 0, sizeof(DDRAWI_DDRAWCLIPPER_LCL)); + This->mPrimaryClipperLocal.lpGbl = &This->mPrimaryClipperGlobal; + + //memset(&mPrimaryClipperInterface, 0, sizeof(DDRAWI_DDRAWCLIPPER_INT)); + //mPrimaryClipperInterface.lpLcl = &mPrimaryClipperLocal; + //mPrimaryClipperInterface.dwIntRefCnt = 1; + //mPrimaryClipperInterface.lpLink = null; + //mPrimaryClipperInterface.lpVtbl = null; + + This->mPrimaryLocal.lpDDClipper = &This->mPrimaryClipperLocal; + //mPrimaryMore.lpDDIClipper = &mPrimaryClipperInterface; + + //mDdBlt.lpDDDestSurface = mpPrimaryLocals[0]; + + + /* create primare surface is down now */ + + + /* + * + * + * + */ + + /* create overlay surface now */ + + memset(&This->mddsdOverlay, 0, sizeof(DDSURFACEDESC)); + This->mddsdOverlay.dwSize = sizeof(DDSURFACEDESC); + This->mddsdOverlay.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_BACKBUFFERCOUNT | DDSD_WIDTH | DDSD_HEIGHT; + + This->mddsdOverlay.ddsCaps.dwCaps = DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_COMPLEX | DDSCAPS_FLIP; + + This->mddsdOverlay.dwWidth = 100; //pels; + This->mddsdOverlay.dwHeight = 100; // lines; + This->mddsdOverlay.dwBackBufferCount = 1; //cBuffers; + + This->mddsdOverlay.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + This->mddsdOverlay.ddpfPixelFormat.dwFlags = DDPF_RGB; + This->mddsdOverlay.ddpfPixelFormat.dwRGBBitCount = 32; + + + //DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface; + mDdCanCreateSurface.lpDD = &This->mDDrawGlobal; + mDdCanCreateSurface.CanCreateSurface = This->mCallbacks.HALDD.CanCreateSurface; + mDdCanCreateSurface.bIsDifferentPixelFormat = TRUE; //isDifferentPixelFormat; + mDdCanCreateSurface.lpDDSurfaceDesc = &This->mddsdOverlay; // pDDSD; + + + if (This->mHALInfo.lpDDCallbacks->CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED) + { + // derr(L"DirectDrawImpl[%08x]::__createPrimary Cannot create primary [%08x]", this, rv); + return DDERR_NOTINITIALIZED; + } + + if (mDdCanCreateSurface.ddRVal != DD_OK) + { + return DDERR_NOTINITIALIZED; + } + + + memset(&This->mOverlayGlobal, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL)); + This->mOverlayGlobal.dwGlobalFlags = 0; + This->mOverlayGlobal.lpDD = &This->mDDrawGlobal; + This->mOverlayGlobal.lpDDHandle = &This->mDDrawGlobal; + This->mOverlayGlobal.wWidth = (WORD)This->mddsdOverlay.dwWidth; + This->mOverlayGlobal.wHeight = (WORD)This->mddsdOverlay.dwHeight; + This->mOverlayGlobal.lPitch = -1; + This->mOverlayGlobal.ddpfSurface = This->mddsdOverlay.ddpfPixelFormat; + + // setup front- and backbuffer surfaces + UINT cSurfaces = This->mddsdOverlay.dwBackBufferCount + 1; + for (i = 0; i < cSurfaces; i++) + { + memset(&This->mOverlayMore[i], 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); + This->mOverlayMore[i].dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); + + memset(&This->mOverlayLocal[i], 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); + This->mOverlayLocal[i].lpGbl = &This->mOverlayGlobal; + This->mOverlayLocal[i].lpSurfMore = &This->mOverlayMore[i]; + This->mOverlayLocal[i].dwProcessId = GetCurrentProcessId(); + This->mOverlayLocal[i].dwFlags = (i == 0) ? + (DDRAWISURF_IMPLICITROOT|DDRAWISURF_FRONTBUFFER): + (DDRAWISURF_IMPLICITCREATE|DDRAWISURF_BACKBUFFER); + + This->mOverlayLocal[i].dwFlags |= + DDRAWISURF_ATTACHED|DDRAWISURF_ATTACHED_FROM| + DDRAWISURF_HASPIXELFORMAT| + DDRAWISURF_HASOVERLAYDATA; + + This->mOverlayLocal[i].ddsCaps.dwCaps = This->mddsdOverlay.ddsCaps.dwCaps; + This->mpOverlayLocals[i] = &This->mOverlayLocal[i]; + } + + for (i = 0; i < cSurfaces; i++) + { + UINT j = (i + 1) % cSurfaces; + + + /*if (!mHALInfo.lpDDSurfaceCallbacks->AddAttachedSurface(mpOverlayLocals[i], mpOverlayLocals[j])) + { + // derr(L"DirectDrawImpl[%08x]::__setupDevice DdAttachSurface(%d, %d) failed", this, i, j); + return DD_FALSE; + }*/ + + if (!DdAttachSurface(This->mpOverlayLocals[i], This->mpOverlayLocals[j])) + { + // derr(L"DirectDrawImpl[%08x]::__setupDevice DdAttachSurface(%d, %d) failed", this, i, j); + return DD_FALSE; + } + + } + + + // DDHAL_CREATESURFACEDATA mDdCreateSurface; + mDdCreateSurface.lpDD = &This->mDDrawGlobal; + mDdCreateSurface.CreateSurface = This->mCallbacks.HALDD.CreateSurface; + mDdCreateSurface.lpDDSurfaceDesc = &This->mddsdOverlay;//pDDSD; + mDdCreateSurface.lplpSList = This->mpOverlayLocals; //cSurfaces; + mDdCreateSurface.dwSCnt = 1 ; //ppSurfaces; + + if (This->mHALInfo.lpDDCallbacks->CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED) + { + return DDERR_NOTINITIALIZED; + } + + + if (mDdCreateSurface.ddRVal != DD_OK) + { + return mDdCreateSurface.ddRVal; + } + + //mSrcRect.w = mddsdOverlay.dwWidth; + //mSrcRect.h = mddsdOverlay.dwHeight; + //__alignBounds(); + + + DDHAL_UPDATEOVERLAYDATA mDdUpdateOverlay; + mDdUpdateOverlay.lpDD = &This->mDDrawGlobal; + mDdUpdateOverlay.UpdateOverlay = This->mCallbacks.HALDDSurface.UpdateOverlay; + mDdUpdateOverlay.lpDDDestSurface = This->mpPrimaryLocals[0]; + mDdUpdateOverlay.lpDDSrcSurface = This->mpOverlayLocals[0];//pDDSurface; + mDdUpdateOverlay.dwFlags = DDOVER_SHOW; + + /* if (flags & DDOVER_DDFX) + mDdUpdateOverlay.overlayFX = *pFx; + copyRect(&mDdUpdateOverlay.rDest, pdst); + copyRect(&mDdUpdateOverlay.rSrc, psrc); +*/ + + mDdUpdateOverlay.rDest.top = 0; + mDdUpdateOverlay.rDest.left = 0; + mDdUpdateOverlay.rDest.right = 50; + mDdUpdateOverlay.rDest.bottom = 50; + + mDdUpdateOverlay.rSrc.top = 0; + mDdUpdateOverlay.rSrc.left = 0; + mDdUpdateOverlay.rSrc.right = 50; + mDdUpdateOverlay.rSrc.bottom = 50; + + + + + if ( mDdUpdateOverlay.UpdateOverlay(&mDdUpdateOverlay) == DDHAL_DRIVER_NOTHANDLED) + { + return DDERR_NOTINITIALIZED; + } + + + if (mDdUpdateOverlay.ddRVal != DD_OK) + { + return mDdUpdateOverlay.ddRVal; + } + + return DD_OK; +} + HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rDest, LPDIRECTDRAWSURFACE7 src, LPRECT rSrc, DWORD dwFlags, LPDDBLTFX lpbltfx) { Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddra…
============================================================================== --- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original) +++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Wed Apr 5 09:43:18 2006 @@ -230,6 +230,8 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter) { + HRESULT ret; + if (pUnkOuter!=NULL) return DDERR_INVALIDPARAMS; @@ -251,6 +253,7 @@ That->lpVtbl = &DirectDrawSurface7_Vtable; That->lpVtbl_v3 = &DDRAW_IDDS3_Thunk_VTable; + *ppSurf = (LPDIRECTDRAWSURFACE7)That; This->mDDrawGlobal.dsList = (LPDDRAWI_DDRAWSURFACE_INT)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDRAWI_DDRAWSURFACE_INT)); @@ -259,90 +262,22 @@ /* we alwasy set to use the DirectDrawSurface7_Vtable as internel */ That->owner->mDDrawGlobal.dsList->lpVtbl = (PVOID) &DirectDrawSurface7_Vtable; - - *ppSurf = (LPDIRECTDRAWSURFACE7)That; - - - //This->mpLocal = (DDRAWI_DDRAWSURFACE_LCL* )DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL) * This->cSurfaces); - //This->mppLocal = (DDRAWI_DDRAWSURFACE_LCL**)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL*) * This->cSurfaces); - /* start alloc memory */ - if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) - { - ///* HAL Code */ - //DDHAL_CANCREATESURFACEDATA CanCreateData; - // memset(&CanCreateData, 0, sizeof(DDHAL_CANCREATESURFACEDATA)); - // CanCreateData.lpDD = &This->mDDrawGlobal; - // CanCreateData.lpDDSurfaceDesc = &mddsdPrimary; - // - // if (mDDrawGlobal.lpDDCBtmp->HALDD.CanCreateSurface(&CanCreateData) == DDHAL_DRIVER_NOTHANDLED) - // { - // return DDERR_INVALIDPARAMS; - // } - - //memset(&mPrimaryGlobal, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL)); - // mPrimaryGlobal.dwGlobalFlags = DDRAWISURFGBL_ISGDISURFACE; - // mPrimaryGlobal.lpDD = &mDDrawGlobal; - // mPrimaryGlobal.lpDDHandle = &mDDrawGlobal; - // mPrimaryGlobal.wWidth = (WORD)mpModeInfos[0].dwWidth; - // mPrimaryGlobal.wHeight = (WORD)mpModeInfos[0].dwHeight; - // mPrimaryGlobal.lPitch = mpModeInfos[0].lPitch; - - //memset(&mPrimaryMore, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); - // mPrimaryMore.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); - - // memset(&mPrimaryLocal, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); - // mPrimaryLocal.lpGbl = &mPrimaryGlobal; - // mPrimaryLocal.lpSurfMore = &mPrimaryMore; - // mPrimaryLocal.dwProcessId = GetCurrentProcessId(); - // // mPrimaryLocal.dwFlags = DDRAWISURF_PARTOFPRIMARYCHAIN|DDRAWISURF_HASOVERLAYDATA; - // - // mPrimaryLocal.ddsCaps.dwCaps = mddsdPrimary.ddsCaps.dwCaps; - - // mpPrimaryLocals[0] = &mPrimaryLocal; - // - // DDHAL_CREATESURFACEDATA CreateData; - // memset(&CreateData, 0, sizeof(DDHAL_CREATESURFACEDATA)); - // CreateData.lpDD = &mDDrawGlobal; - // CreateData.lpDDSurfaceDesc = &mddsdPrimary; - // CreateData.dwSCnt = 1; - // CreateData.lplpSList = mpPrimaryLocals; - // CreateData.ddRVal = DD_FALSE; - // - // if (mDDrawGlobal.lpDDCBtmp->HALDD.CreateSurface(&CreateData)==DDHAL_DRIVER_NOTHANDLED) - // { - // return DD_FALSE; - // } - - // if(CreateData.ddRVal != DD_OK) - // { - // return CreateData.ddRVal; - // } - // return DD_OK; - - } - else - { - // Create system mmeory - //DDSCAPS_SYSTEMMEMORY - return DD_FALSE; - } - - + + + + + if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CREATESURFACE) + { + ret = Hal_DirectDraw_CreateSurface (iface, pDDSD, ppSurf, pUnkOuter); + } + else + { + ret = Hel_DirectDraw_CreateSurface (iface, pDDSD, ppSurf, pUnkOuter); + } // the real surface object creation - //return That->lpVtbl->Initialize (*ppSurf, (LPDIRECTDRAW)iface, pDDSD); - - /* alloc memmory if we need it for diffent surface */ - // DDSCAPS_VIDEOMEMORY graphic card alloc memmory */ - - // DDSCAPS_OFFSCREENPLAIN offcreen surface alloc memmory ?? - - // DDSCAPS_OVERLAY create overlay surface - - // DDSCAPS_TEXTURE - - // return That->lpVtbl->Initialize (*ppSurf, (LPDIRECTDRAW)iface, pDDSD); + return DD_OK; } Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.h…
============================================================================== --- trunk/reactos/dll/directx/ddraw/rosdraw.h (original) +++ trunk/reactos/dll/directx/ddraw/rosdraw.h Wed Apr 5 09:43:18 2006 @@ -45,6 +45,22 @@ UINT mcTextures; DDSURFACEDESC *mpTextures; + + /* Surface */ + DDRAWI_DDRAWSURFACE_GBL mPrimaryGlobal; + DDRAWI_DDRAWSURFACE_MORE mPrimaryMore; + DDRAWI_DDRAWSURFACE_LCL mPrimaryLocal; + DDRAWI_DDRAWSURFACE_LCL *mpPrimaryLocals[1]; + DDRAWI_DDRAWCLIPPER_LCL mPrimaryClipperLocal; + DDRAWI_DDRAWCLIPPER_GBL mPrimaryClipperGlobal; + //DDRAWI_DDRAWCLIPPER_INT mPrimaryClipperInterface; + DDSURFACEDESC mddsdPrimary; + DDSURFACEDESC mddsdOverlay; + + DDRAWI_DDRAWSURFACE_GBL mOverlayGlobal; + DDRAWI_DDRAWSURFACE_LCL mOverlayLocal[6]; + DDRAWI_DDRAWSURFACE_LCL *mpOverlayLocals[6]; + DDRAWI_DDRAWSURFACE_MORE mOverlayMore[6]; /* ExclusiveOwner */ @@ -126,7 +142,7 @@ HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 ); HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7, DWORD, DWORD, DWORD, DWORD, DWORD ); HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX ); - +HRESULT Hal_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter); HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 ); @@ -138,6 +154,7 @@ HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 ); HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 , DWORD , DWORD ,DWORD , DWORD , DWORD ); HRESULT Hel_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX ); +HRESULT Hel_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter); /* Setting for HEL should be move to ros special reg key ? */ Modified: trunk/reactos/dll/directx/ddraw/soft/surface_hel.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/soft/surf…
============================================================================== --- trunk/reactos/dll/directx/ddraw/soft/surface_hel.c (original) +++ trunk/reactos/dll/directx/ddraw/soft/surface_hel.c Wed Apr 5 09:43:18 2006 @@ -11,6 +11,10 @@ #include "rosdraw.h" +HRESULT Hel_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter) +{ + DX_STUB; +} HRESULT Hel_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
1
0
0
0
[jimtabor] 21456: svn propset svn:eol-style native
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: jimtabor Date: Wed Apr 5 06:40:09 2006 New Revision: 21456 URL:
http://svn.reactos.ru/svn/reactos?rev=21456&view=rev
Log: svn propset svn:eol-style native Modified: trunk/reactos/regtests/winetests/user32/monitor.c (props changed) trunk/reactos/regtests/winetests/user32/resource.rc (props changed) Propchange: trunk/reactos/regtests/winetests/user32/monitor.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/regtests/winetests/user32/resource.rc ------------------------------------------------------------------------------ svn:eol-style = native
1
0
0
0
[jimtabor] 21455: Update Wine User32 test to Apr 4 2006 cvs.
by alekseyï¼ studiocerebral.com
05 Apr '06
05 Apr '06
Author: jimtabor Date: Wed Apr 5 06:34:10 2006 New Revision: 21455 URL:
http://svn.reactos.ru/svn/reactos?rev=21455&view=rev
Log: Update Wine User32 test to Apr 4 2006 cvs. Added: trunk/reactos/regtests/winetests/user32/monitor.c (with props) Modified: trunk/reactos/regtests/winetests/user32/class.c trunk/reactos/regtests/winetests/user32/clipboard.c (contents, props changed) trunk/reactos/regtests/winetests/user32/dce.c (contents, props changed) trunk/reactos/regtests/winetests/user32/dde.c (contents, props changed) trunk/reactos/regtests/winetests/user32/dialog.c (props changed) trunk/reactos/regtests/winetests/user32/edit.c (contents, props changed) trunk/reactos/regtests/winetests/user32/input.c (props changed) trunk/reactos/regtests/winetests/user32/listbox.c (contents, props changed) trunk/reactos/regtests/winetests/user32/menu.c (contents, props changed) trunk/reactos/regtests/winetests/user32/msg.c (contents, props changed) trunk/reactos/regtests/winetests/user32/resource.c (contents, props changed) trunk/reactos/regtests/winetests/user32/resource.rc (props changed) trunk/reactos/regtests/winetests/user32/sysparams.c (contents, props changed) trunk/reactos/regtests/winetests/user32/testlist.c (contents, props changed) trunk/reactos/regtests/winetests/user32/text.c (contents, props changed) trunk/reactos/regtests/winetests/user32/user32.rbuild (contents, props changed) trunk/reactos/regtests/winetests/user32/win.c (contents, props changed) trunk/reactos/regtests/winetests/user32/winstation.c (contents, props changed) trunk/reactos/regtests/winetests/user32/wsprintf.c (props changed) Modified: trunk/reactos/regtests/winetests/user32/class.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/c…
============================================================================== --- trunk/reactos/regtests/winetests/user32/class.c (original) +++ trunk/reactos/regtests/winetests/user32/class.c Wed Apr 5 06:34:10 2006 @@ -248,12 +248,12 @@ wc.hInstance, info_inst, name ); hwnd = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, inst, 0 ); ok( hwnd != NULL, "Couldn't create window for class %s inst %p\n", name, inst ); - ok( (HINSTANCE)GetClassLongA( hwnd, GCL_HMODULE ) == gcl_inst, + ok( (HINSTANCE)GetClassLongPtrA( hwnd, GCLP_HMODULE ) == gcl_inst, "Wrong GCL instance %p/%p for class %s\n", - (HINSTANCE)GetClassLongA( hwnd, GCL_HMODULE ), gcl_inst, name ); - ok( (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ) == inst, + (HINSTANCE)GetClassLongPtrA( hwnd, GCLP_HMODULE ), gcl_inst, name ); + ok( (HINSTANCE)GetWindowLongPtrA( hwnd, GWLP_HINSTANCE ) == inst, "Wrong GWL instance %p/%p for window %s\n", - (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ), inst, name ); + (HINSTANCE)GetWindowLongPtrA( hwnd, GWLP_HINSTANCE ), inst, name ); ok(!UnregisterClassA(name, inst), "UnregisterClassA should fail while exists a class window\n"); ok(GetLastError() == ERROR_CLASS_HAS_WINDOWS, "GetLastError() should be set to ERROR_CLASS_HAS_WINDOWS not %ld\n", GetLastError()); DestroyWindow(hwnd); @@ -363,7 +363,7 @@ ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" ); /* changing the instance doesn't make it global */ - SetClassLongA( hwnd, GCL_HMODULE, 0 ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, 0 ); ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" ); check_class( kernel32, name, "kernel32" ); check_instance( name, kernel32, kernel32, kernel32 ); @@ -372,7 +372,7 @@ ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" ); /* GetClassInfo with instance 0 finds user32 instance */ - SetClassLongA( hwnd, GCL_HMODULE, (LONG)user32 ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, (LONG_PTR)user32 ); ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" ); check_class( kernel32, name, "kernel32" ); check_class( user32, name, "main_module" ); @@ -385,7 +385,7 @@ check_thread_instance( name, 0, 0, kernel32 ); ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" ); - SetClassLongA( hwnd, GCL_HMODULE, 0x12345678 ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, 0x12345678 ); ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" ); check_class( kernel32, name, "kernel32" ); check_class( (HINSTANCE)0x12345678, name, "main_module" ); @@ -401,24 +401,24 @@ cls.style = 3; ok( RegisterClassA( &cls ), "Failed to register local class for deadbeef\n" ); hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 ); - ok( (HINSTANCE)GetClassLong( hwnd2, GCL_HMODULE ) == (HINSTANCE)0xdeadbeef, + ok( (HINSTANCE)GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == (HINSTANCE)0xdeadbeef, "Didn't get deadbeef class for null instance\n" ); DestroyWindow( hwnd2 ); ok( UnregisterClassA( name, (HINSTANCE)0xdeadbeef ), "Unregister failed for deadbeef\n" ); hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 ); - ok( (HINSTANCE)GetClassLong( hwnd2, GCL_HMODULE ) == kernel32, + ok( (HINSTANCE)GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == kernel32, "Didn't get kernel32 class for null instance\n" ); DestroyWindow( hwnd2 ); ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" ); hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 ); - ok( GetClassLong( hwnd2, GCL_HMODULE ) == 0x12345678, + ok( GetClassLongPtrA( hwnd2, GCLP_HMODULE ) == 0x12345678, "Didn't get 12345678 class for null instance\n" ); DestroyWindow( hwnd2 ); - SetClassLongA( hwnd, GCL_HMODULE, (LONG)main_module ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, (LONG_PTR)main_module ); DestroyWindow( hwnd ); /* null handle means the same thing as main module */ @@ -476,7 +476,7 @@ check_thread_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, main_module ); /* changing the instance for global class doesn't make much difference */ - SetClassLongA( hwnd, GCL_HMODULE, 0xdeadbeef ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, 0xdeadbeef ); check_instance( name, main_module, main_module, (HINSTANCE)0xdeadbeef ); check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef ); check_thread_instance( name, main_module, main_module, (HINSTANCE)0xdeadbeef ); @@ -542,7 +542,7 @@ check_instance( "EDIT", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 ); check_thread_instance( "EDIT", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 ); hwnd = CreateWindowExA( 0, "EDIT", "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 ); - SetClassLongA( hwnd, GCL_HMODULE, 0xdeadbeef ); + SetClassLongPtrA( hwnd, GCLP_HMODULE, 0xdeadbeef ); check_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef ); check_thread_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef ); } Modified: trunk/reactos/regtests/winetests/user32/clipboard.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/c…
============================================================================== --- trunk/reactos/regtests/winetests/user32/clipboard.c (original) +++ trunk/reactos/regtests/winetests/user32/clipboard.c Wed Apr 5 06:34:10 2006 @@ -30,8 +30,8 @@ { \ if (!is_win9x) \ ok(GetLastError() == expected_error, \ - "Last error should be set to %ld, not %ld\n", \ - (DWORD) expected_error, (DWORD) GetLastError()); \ + "Last error should be set to %d, not %ld\n", \ + expected_error, GetLastError()); \ } while (0) static void test_ClipboardOwner(void) Propchange: trunk/reactos/regtests/winetests/user32/clipboard.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/dce.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/d…
============================================================================== --- trunk/reactos/regtests/winetests/user32/dce.c (original) +++ trunk/reactos/regtests/winetests/user32/dce.c Wed Apr 5 06:34:10 2006 @@ -33,7 +33,9 @@ #include "wine/test.h" -#define DCX_USESTYLE 0x00010000 +#ifndef DCX_USESTYLE +#define DCX_USESTYLE 0x00010000 +#endif static HWND hwnd_cache, hwnd_owndc, hwnd_classdc, hwnd_classdc2; Propchange: trunk/reactos/regtests/winetests/user32/dce.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/dde.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/d…
============================================================================== --- trunk/reactos/regtests/winetests/user32/dde.c (original) +++ trunk/reactos/regtests/winetests/user32/dde.c Wed Apr 5 06:34:10 2006 @@ -289,13 +289,11 @@ ok(DdeFreeStringHandle(dde_inst, hsz_server), "DdeFreeStringHandle error %x\n", DdeGetLastError(dde_inst)); - /* This call hangs on win2k SP4. + /* This call hangs on win2k SP4 and XP SP1. DdeUninitialize(dde_inst);*/ DestroyWindow(hwnd_client); DestroyWindow(hwnd_server); - - DdeUninitialize(dde_inst); } static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage) Propchange: trunk/reactos/regtests/winetests/user32/dde.c ------------------------------------------------------------------------------ native = class.c Propchange: trunk/reactos/regtests/winetests/user32/dialog.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/edit.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/e…
============================================================================== --- trunk/reactos/regtests/winetests/user32/edit.c (original) +++ trunk/reactos/regtests/winetests/user32/edit.c Wed Apr 5 06:34:10 2006 @@ -20,7 +20,6 @@ #include <assert.h> #include <windows.h> -#include <windowsx.h> #include <commctrl.h> #include "wine/test.h" @@ -38,9 +37,11 @@ static struct edit_notify notifications; -static char szEditTest2Name[] = "Edit Test 2 window class"; static HINSTANCE hinst; static HWND hwndET2; +static const char szEditTest2Class[] = "EditTest2Class"; +static const char szEditTest3Class[] = "EditTest3Class"; +static const char szEditTextPositionClass[] = "EditTextPositionWindowClass"; static HWND create_editcontrol (DWORD style, DWORD exstyle) { @@ -48,14 +49,57 @@ handle = CreateWindowEx(exstyle, "EDIT", - NULL, - ES_AUTOHSCROLL | ES_AUTOVSCROLL | style, + "Test Text", + style, 10, 10, 300, 300, - NULL, NULL, NULL, NULL); + NULL, NULL, hinst, NULL); assert (handle); if (winetest_interactive) ShowWindow (handle, SW_SHOW); return handle; +} + +static HWND create_child_editcontrol (DWORD style, DWORD exstyle) +{ + HWND parentWnd; + HWND editWnd; + RECT rect; + + rect.left = 0; + rect.top = 0; + rect.right = 300; + rect.bottom = 300; + assert(AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE)); + + parentWnd = CreateWindowEx(0, + szEditTextPositionClass, + "Edit Test", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + rect.right - rect.left, rect.bottom - rect.top, + NULL, NULL, hinst, NULL); + assert(parentWnd); + + editWnd = CreateWindowEx(exstyle, + "EDIT", + "Test Text", + WS_CHILD | style, + 0, 0, 300, 300, + parentWnd, NULL, hinst, NULL); + assert(editWnd); + if (winetest_interactive) + ShowWindow (parentWnd, SW_SHOW); + return editWnd; +} + +static void destroy_child_editcontrol (HWND hwndEdit) +{ + if (GetParent(hwndEdit)) + DestroyWindow(GetParent(hwndEdit)); + else { + trace("Edit control has no parent!\n"); + DestroyWindow(hwndEdit); + } } static LONG get_edit_style (HWND hwnd) @@ -87,30 +131,29 @@ GetWindowRect(Wnd, &WindowRect); GetClientRect(Wnd, &ClientRect); - SetWindowPos(Wnd, NULL, WindowRect.left, WindowRect.top, + SetWindowPos(Wnd, NULL, 0, 0, WindowRect.right - WindowRect.left, - Height + (WindowRect.bottom - WindowRect.top) - (ClientRect.bottom - ClientRect.top), - SWP_NOMOVE | SWP_NOZORDER); -} - -#define edit_pos_ok(exp, got, txt) \ - ok(exp == got, "wrong " #txt " expected %d got %ld\n", exp, got); - -#define edit_todo_pos_ok(exp, got, txt, todo) \ - if (todo) todo_wine { edit_pos_ok(exp, got, txt); } \ - else edit_pos_ok(exp, got, txt) - -#define check_pos(hwEdit, set_height, test_top, test_height, test_left, todo_top, todo_height, todo_left) \ -do { \ - RECT format_rect; \ - int left_margin; \ - set_client_height(hwEdit, set_height); \ - SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &format_rect); \ - left_margin = LOWORD(SendMessage(hwEdit, EM_GETMARGINS, 0, 0)); \ - edit_todo_pos_ok(test_top, format_rect.top, vertical position, todo_top); \ - edit_todo_pos_ok((int)test_height, format_rect.bottom - format_rect.top, height, todo_height); \ - edit_todo_pos_ok(test_left, format_rect.left - left_margin, left, todo_left); \ -} while(0) + Height + (WindowRect.bottom - WindowRect.top) - + (ClientRect.bottom - ClientRect.top), + SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + + /* Workaround for a bug in Windows' edit control + (multi-line mode) */ + GetWindowRect(Wnd, &WindowRect); + SetWindowPos(Wnd, NULL, 0, 0, + WindowRect.right - WindowRect.left + 1, + WindowRect.bottom - WindowRect.top + 1, + SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + SetWindowPos(Wnd, NULL, 0, 0, + WindowRect.right - WindowRect.left, + WindowRect.bottom - WindowRect.top, + SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + + GetClientRect(Wnd, &ClientRect); + ok(ClientRect.bottom - ClientRect.top == Height, + "The client height should be %ld, but is %ld\n", + (long)Height, (long)(ClientRect.bottom - ClientRect.top)); +} static void test_edit_control_1(void) { @@ -118,14 +161,11 @@ MSG msMessage; int i; LONG r; - HFONT Font, OldFont; - HDC Dc; - TEXTMETRIC Metrics; msMessage.message = WM_KEYDOWN; trace("EDIT: Single line\n"); - hwEdit = create_editcontrol(0, 0); + hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); r = get_edit_style(hwEdit); ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL), "Wrong style expected 0xc0 got: 0x%lx\n", r); for (i=0;i<65535;i++) @@ -138,7 +178,7 @@ DestroyWindow (hwEdit); trace("EDIT: Single line want returns\n"); - hwEdit = create_editcontrol(ES_WANTRETURN, 0); + hwEdit = create_editcontrol(ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); r = get_edit_style(hwEdit); ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN), "Wrong style expected 0x10c0 got: 0x%lx\n", r); for (i=0;i<65535;i++) @@ -151,7 +191,7 @@ DestroyWindow (hwEdit); trace("EDIT: Multiline line\n"); - hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0); + hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); r = get_edit_style(hwEdit); ok(r == (ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0xc4 got: 0x%lx\n", r); for (i=0;i<65535;i++) @@ -164,7 +204,7 @@ DestroyWindow (hwEdit); trace("EDIT: Multi line want returns\n"); - hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN, 0); + hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); r = get_edit_style(hwEdit); ok(r == (ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0x10c4 got: 0x%lx\n", r); for (i=0;i<65535;i++) @@ -175,260 +215,6 @@ "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %lx\n", r); } DestroyWindow (hwEdit); - - /* Get a stock font for which we can determine the metrics */ - Font = GetStockObject(SYSTEM_FONT); - assert(NULL != Font); - Dc = GetDC(NULL); - assert(NULL != Dc); - OldFont = SelectObject(Dc, Font); - assert(NULL != OldFont); - if (! GetTextMetrics(Dc, &Metrics)) - { - assert(FALSE); - } - SelectObject(Dc, OldFont); - ReleaseDC(NULL, Dc); - - trace("EDIT: Text position\n"); - hwEdit = create_editcontrol(0, 0); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, 0); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP, 0); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 0, Metrics.tmHeight , 0, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, 0); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 3, 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 2, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 2, Metrics.tmHeight , 2, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP, WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP, WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 0, Metrics.tmHeight , 0, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 0, Metrics.tmHeight , 0, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 3, 0, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 2, Metrics.tmHeight , 2, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 2, Metrics.tmHeight , 2, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, ES_MULTILINE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_CLIENTEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 1, 1, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 1, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(0, ES_MULTILINE | WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); - - hwEdit = create_editcontrol(WS_BORDER, ES_MULTILINE | WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); - SendMessage(hwEdit, WM_SETFONT, (WPARAM) Font, (LPARAM) FALSE); - check_pos(hwEdit, Metrics.tmHeight - 1, 0, Metrics.tmHeight - 1, 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight , 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 1, 0, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 2, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 4, 1, Metrics.tmHeight , 1, 0, 0, 0); - check_pos(hwEdit, Metrics.tmHeight + 10, 1, Metrics.tmHeight , 1, 0, 0, 0); - DestroyWindow(hwEdit); } /* WM_SETTEXT is implemented by selecting all text, and then replacing the @@ -443,7 +229,7 @@ char szLocalString[MAXLEN]; /* Create main and edit windows. */ - hwndMain = CreateWindow(szEditTest2Name, "ET2", WS_OVERLAPPEDWINDOW, + hwndMain = CreateWindow(szEditTest2Class, "ET2", WS_OVERLAPPEDWINDOW, 0, 0, 200, 200, NULL, NULL, hinst, NULL); assert(hwndMain); if (winetest_interactive) @@ -491,27 +277,11 @@ static LRESULT CALLBACK ET2_WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch (iMsg) { - HANDLE_MSG(hwnd, WM_COMMAND, ET2_OnCommand); + case WM_COMMAND: + ET2_OnCommand(hwnd, LOWORD(wParam), (HWND)lParam, HIWORD(wParam)); + break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); -} - -static BOOL RegisterWindowClasses (void) -{ - WNDCLASSA cls; - cls.style = 0; - cls.lpfnWndProc = ET2_WndProc; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = hinst; - cls.hIcon = NULL; - cls.hCursor = LoadCursorA (NULL, IDC_ARROW); - cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - cls.lpszMenuName = NULL; - cls.lpszClassName = szEditTest2Name; - if (!RegisterClassA (&cls)) return FALSE; - - return TRUE; } static void zero_notify(void) @@ -555,7 +325,6 @@ */ static void test_edit_control_3(void) { - WNDCLASSA cls; HWND hWnd; HWND hParent; int len; @@ -564,21 +333,8 @@ trace("EDIT: Test notifications\n"); - cls.style = 0; - cls.lpfnWndProc = edit3_wnd_procA; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandleA(0); - cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); - cls.hbrBackground = GetStockObject(WHITE_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = "ParentWindowClass"; - - assert(RegisterClassA(&cls)); - hParent = CreateWindowExA(0, - "ParentWindowClass", + szEditTest3Class, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, @@ -807,7 +563,7 @@ int i; trace("EDIT: Test EM_CHARFROMPOS and EM_POSFROMCHAR\n"); - hwEdit = create_editcontrol(0, 0); + hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -825,7 +581,7 @@ ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); - hwEdit = create_editcontrol(ES_RIGHT, 0); + hwEdit = create_editcontrol(ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -843,7 +599,7 @@ ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); - hwEdit = create_editcontrol(ES_CENTER, 0); + hwEdit = create_editcontrol(ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -861,7 +617,7 @@ ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); - hwEdit = create_editcontrol(ES_MULTILINE, 0); + hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -879,7 +635,7 @@ ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); - hwEdit = create_editcontrol(ES_MULTILINE | ES_RIGHT, 0); + hwEdit = create_editcontrol(ES_MULTILINE | ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -897,7 +653,7 @@ ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); - hwEdit = create_editcontrol(ES_MULTILINE | ES_CENTER, 0); + hwEdit = create_editcontrol(ES_MULTILINE | ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa"); lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0)); hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0)); @@ -916,6 +672,40 @@ DestroyWindow(hwEdit); } +/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL + * truncates text that doesn't fit. + */ +static void test_edit_control_5(void) +{ + static const char *str = "test\r\ntest"; + HWND hWnd; + int len; + + hWnd = CreateWindowEx(0, + "EDIT", + str, + 0, + 10, 10, 1, 1, + NULL, NULL, NULL, NULL); + assert(hWnd); + + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str) == len, "text shouldn't have been truncated\n"); + DestroyWindow(hWnd); + + hWnd = CreateWindowEx(0, + "EDIT", + str, + ES_MULTILINE, + 10, 10, 1, 1, + NULL, NULL, NULL, NULL); + assert(hWnd); + + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str) == len, "text shouldn't have been truncated\n"); + DestroyWindow(hWnd); +} + static void test_margins(void) { HWND hwEdit; @@ -923,7 +713,7 @@ INT old_left_margin, old_right_margin; DWORD old_margins, new_margins; - hwEdit = create_editcontrol(WS_BORDER, 0); + hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); old_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); old_left_margin = LOWORD(old_margins); @@ -970,19 +760,314 @@ ok(new_rect.right == old_rect.right, "The right border of the rectangle has changed\n"); ok(new_rect.top == old_rect.top, "The top border of the rectangle has changed\n"); ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle has changed\n"); - + DestroyWindow (hwEdit); } +static INT CALLBACK find_font_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam) +{ + return 0; +} + +static void test_margins_font_change(void) +{ + HWND hwEdit; + DWORD margins, font_margins; + LOGFONT lf; + HFONT hfont, hfont2; + HDC hdc = GetDC(0); + + if(EnumFontFamiliesA(hdc, "Arial", find_font_proc, 0)) + { + trace("Arial not found - skipping font change margin tests\n"); + ReleaseDC(0, hdc); + return; + } + ReleaseDC(0, hdc); + + hwEdit = create_child_editcontrol(0, 0); + + SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE); + + memset(&lf, 0, sizeof(lf)); + strcpy(lf.lfFaceName, "Arial"); + lf.lfHeight = 16; + lf.lfCharSet = DEFAULT_CHARSET; + hfont = CreateFontIndirectA(&lf); + lf.lfHeight = 30; + hfont2 = CreateFontIndirectA(&lf); + + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + font_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(font_margins) != 0, "got %d\n", LOWORD(font_margins)); + ok(HIWORD(font_margins) != 0, "got %d\n", HIWORD(font_margins)); + + /* With 'small' edit controls, test that the margin doesn't get set */ + SetWindowPos(hwEdit, NULL, 10, 10, 16, 100, SWP_NOZORDER | SWP_NOACTIVATE); + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0,0)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == 0, "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == 0, "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == 0, "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO)); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins)); + + /* Above a certain size threshold then the margin is updated */ + SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE); + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO)); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0); + margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); + ok(LOWORD(margins) != LOWORD(font_margins), "got %d\n", LOWORD(margins)); + ok(HIWORD(margins) != HIWORD(font_margins), "got %d\n", HIWORD(margins)); + + SendMessageA(hwEdit, WM_SETFONT, 0, 0); + + DeleteObject(hfont2); + DeleteObject(hfont); + destroy_child_editcontrol(hwEdit); + +} + +#define edit_pos_ok(exp, got, txt) \ + ok(exp == got, "wrong " #txt " expected %d got %ld\n", exp, got); + +#define check_pos(hwEdit, set_height, test_top, test_height, test_left) \ +do { \ + RECT format_rect; \ + int left_margin; \ + set_client_height(hwEdit, set_height); \ + SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &format_rect); \ + left_margin = LOWORD(SendMessage(hwEdit, EM_GETMARGINS, 0, 0)); \ + edit_pos_ok(test_top, format_rect.top, vertical position); \ + edit_pos_ok((int)test_height, format_rect.bottom - format_rect.top, height); \ + edit_pos_ok(test_left, format_rect.left - left_margin, left); \ +} while(0) + +void test_text_position_style(DWORD style) +{ + HWND hwEdit; + HFONT font, oldFont; + HDC dc; + TEXTMETRIC metrics; + INT b, bm, b2, b3; + BOOL single_line = !(style & ES_MULTILINE); + + b = GetSystemMetrics(SM_CYBORDER) + 1; + b2 = 2 * b; + b3 = 3 * b; + bm = b2 - 1; + + /* Get a stock font for which we can determine the metrics */ + assert(font = GetStockObject(SYSTEM_FONT)); + assert(dc = GetDC(NULL)); + oldFont = SelectObject(dc, font); + assert(GetTextMetrics(dc, &metrics)); + SelectObject(dc, oldFont); + ReleaseDC(NULL, dc); + + /* Windows' edit control has some bugs in multi-line mode: + * - Sometimes the format rectangle doesn't get updated + * (see workaround in set_client_height()) + * - If the height of the control is smaller than the height of a text + * line, the format rectangle is still as high as a text line + * (higher than the client rectangle) and the caret is not shown + */ + + /* Edit controls that are in a parent window */ + + hwEdit = create_child_editcontrol(style | WS_VISIBLE, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0); + destroy_child_editcontrol(hwEdit); + + hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b); + destroy_child_editcontrol(hwEdit); + + hwEdit = create_child_editcontrol(style | WS_VISIBLE, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1); + destroy_child_editcontrol(hwEdit); + + hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1); + destroy_child_editcontrol(hwEdit); + + + /* Edit controls that are popup windows */ + + hwEdit = create_editcontrol(style | WS_POPUP, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0); + check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, 0); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b); + check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(style | WS_POPUP, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1); + DestroyWindow(hwEdit); + + hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE); + SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE); + if (single_line) + check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1); + check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1); + check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1); + DestroyWindow(hwEdit); +} + +void test_text_position(void) +{ + trace("EDIT: Text position (Single line)\n"); + test_text_position_style(ES_AUTOHSCROLL | ES_AUTOVSCROLL); + trace("EDIT: Text position (Multi line)\n"); + test_text_position_style(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL); +} + +static BOOL RegisterWindowClasses (void) +{ + WNDCLASSA test2; + WNDCLASSA test3; + WNDCLASSA text_position; + + test2.style = 0; + test2.lpfnWndProc = ET2_WndProc; + test2.cbClsExtra = 0; + test2.cbWndExtra = 0; + test2.hInstance = hinst; + test2.hIcon = NULL; + test2.hCursor = LoadCursorA (NULL, IDC_ARROW); + test2.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + test2.lpszMenuName = NULL; + test2.lpszClassName = szEditTest2Class; + if (!RegisterClassA(&test2)) return FALSE; + + test3.style = 0; + test3.lpfnWndProc = edit3_wnd_procA; + test3.cbClsExtra = 0; + test3.cbWndExtra = 0; + test3.hInstance = hinst; + test3.hIcon = 0; + test3.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + test3.hbrBackground = GetStockObject(WHITE_BRUSH); + test3.lpszMenuName = NULL; + test3.lpszClassName = szEditTest3Class; + if (!RegisterClassA(&test3)) return FALSE; + + text_position.style = CS_HREDRAW | CS_VREDRAW; + text_position.cbClsExtra = 0; + text_position.cbWndExtra = 0; + text_position.hInstance = hinst; + text_position.hIcon = NULL; + text_position.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_ARROW)); + text_position.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + text_position.lpszMenuName = NULL; + text_position.lpszClassName = szEditTextPositionClass; + text_position.lpfnWndProc = DefWindowProc; + if (!RegisterClassA(&text_position)) return FALSE; + + return TRUE; +} + +static void UnregisterWindowClasses (void) +{ + UnregisterClassA(szEditTest2Class, hinst); + UnregisterClassA(szEditTest3Class, hinst); + UnregisterClassA(szEditTextPositionClass, hinst); +} + START_TEST(edit) { - hinst = GetModuleHandleA (NULL); - if (!RegisterWindowClasses()) - assert(0); + hinst = GetModuleHandleA(NULL); + assert(RegisterWindowClasses()); test_edit_control_1(); test_edit_control_2(); test_edit_control_3(); test_edit_control_4(); + test_edit_control_5(); test_margins(); -} + test_margins_font_change(); + test_text_position(); + + UnregisterWindowClasses(); +} Propchange: trunk/reactos/regtests/winetests/user32/edit.c ------------------------------------------------------------------------------ native = class.c Propchange: trunk/reactos/regtests/winetests/user32/input.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/listbox.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/l…
============================================================================== --- trunk/reactos/regtests/winetests/user32/listbox.c (original) +++ trunk/reactos/regtests/winetests/user32/listbox.c Wed Apr 5 06:34:10 2006 @@ -47,10 +47,14 @@ static HWND create_listbox (DWORD add_style, HWND parent) { - HWND handle=CreateWindow ("LISTBOX", "TestList", + HWND handle; + int ctl_id=0; + if (parent) + ctl_id=1; + handle=CreateWindow ("LISTBOX", "TestList", (LBS_STANDARD & ~LBS_SORT) | add_style, 0, 0, 100, 100, - parent, (HMENU)1, NULL, 0); + parent, (HMENU)ctl_id, NULL, 0); assert (handle); SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) strings[0]); @@ -135,6 +139,7 @@ HWND hLB=create_listbox (test.prop.add_style, 0); RECT second_item; int i; + int res; listbox_query (hLB, &answer); listbox_ok (test, init, answer); @@ -175,6 +180,16 @@ HeapFree (GetProcessHeap(), 0, txt); } + /* Confirm the count of items, and that an invalid delete does not remove anything */ + res = SendMessage (hLB, LB_GETCOUNT, 0, 0); + ok((res==4), "Expected 4 items, got %d\n", res); + res = SendMessage (hLB, LB_DELETESTRING, -1, 0); + ok((res==LB_ERR), "Expected LB_ERR items, got %d\n", res); + res = SendMessage (hLB, LB_DELETESTRING, 4, 0); + ok((res==LB_ERR), "Expected LB_ERR items, got %d\n", res); + res = SendMessage (hLB, LB_GETCOUNT, 0, 0); + ok((res==4), "Expected 4 items, got %d\n", res); + WAIT; DestroyWindow (hLB); } @@ -212,7 +227,8 @@ trace("%p WM_DRAWITEM %08x %08lx\n", hwnd, wparam, lparam); - ok(wparam == 0, "wrong wparam %04x\n", wparam); + ok(wparam == dis->CtlID, "got wParam=%08x instead of %08x\n", + wparam, dis->CtlID); ok(dis->CtlType == ODT_LISTBOX, "wrong CtlType %04x\n", dis->CtlType); GetClientRect(dis->hwndItem, &rc_client); @@ -286,6 +302,131 @@ DestroyWindow(hLB); DestroyWindow(parent); +} + +#define listbox_test_query(exp, got) \ + ok(exp.selected == got.selected, "expected selected %d, got %d\n", exp.selected, got.selected); \ + ok(exp.anchor == got.anchor, "expected anchor %d, got %d\n", exp.anchor, got.anchor); \ + ok(exp.caret == got.caret, "expected caret %d, got %d\n", exp.caret, got.caret); \ + ok(exp.selcount == got.selcount, "expected selcount %d, got %d\n", exp.selcount, got.selcount); + +static void test_selection(void) +{ + static const struct listbox_stat test_nosel = { 0, LB_ERR, 0, 0 }; + static const struct listbox_stat test_1 = { 0, LB_ERR, 0, 2 }; + static const struct listbox_stat test_2 = { 0, LB_ERR, 0, 3 }; + static const struct listbox_stat test_3 = { 0, LB_ERR, 0, 4 }; + HWND hLB; + struct listbox_stat answer; + INT ret; + + trace("testing LB_SELITEMRANGE\n"); + + hLB = create_listbox(LBS_EXTENDEDSEL, 0); + assert(hLB); + + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, 2)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_1, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(0, 4)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_3, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(-5, 5)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(2, 10)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_1, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(4, 10)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(10, 1)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_2, answer); + + SendMessage(hLB, LB_SETSEL, FALSE, (LPARAM)-1); + listbox_query(hLB, &answer); + listbox_test_query(test_nosel, answer); + + ret = SendMessage(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, -1)); + ok(ret == LB_OKAY, "LB_SELITEMRANGE returned %d instead of LB_OKAY\n", ret); + listbox_query(hLB, &answer); + listbox_test_query(test_2, answer); + + DestroyWindow(hLB); +} + +static void test_listbox_height(void) +{ + HWND hList; + int r, id; + + hList = CreateWindow( "ListBox", "list test", 0, + 1, 1, 600, 100, NULL, NULL, NULL, NULL ); + ok( hList != NULL, "failed to create listbox\n"); + + id = SendMessage( hList, LB_ADDSTRING, 0, (LPARAM) "hi"); + ok( id == 0, "item id wrong\n"); + + r = SendMessage( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 20, 0 )); + ok( r == 0, "send message failed\n"); + + r = SendMessage(hList, LB_GETITEMHEIGHT, 0, 0 ); + ok( r == 20, "height wrong\n"); + + r = SendMessage( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 0, 30 )); + ok( r == -1, "send message failed\n"); + + r = SendMessage(hList, LB_GETITEMHEIGHT, 0, 0 ); + ok( r == 20, "height wrong\n"); + + r = SendMessage( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 0x100, 0 )); + ok( r == -1, "send message failed\n"); + + r = SendMessage(hList, LB_GETITEMHEIGHT, 0, 0 ); + ok( r == 20, "height wrong\n"); + + r = SendMessage( hList, LB_SETITEMHEIGHT, 0, MAKELPARAM( 0xff, 0 )); + ok( r == 0, "send message failed\n"); + + r = SendMessage(hList, LB_GETITEMHEIGHT, 0, 0 ); + ok( r == 0xff, "height wrong\n"); + + DestroyWindow( hList ); } START_TEST(listbox) @@ -360,4 +501,6 @@ check_item_height(); test_ownerdraw(); -} + test_selection(); + test_listbox_height(); +} Propchange: trunk/reactos/regtests/winetests/user32/listbox.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/menu.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/m…
============================================================================== --- trunk/reactos/regtests/winetests/user32/menu.c (original) +++ trunk/reactos/regtests/winetests/user32/menu.c Wed Apr 5 06:34:10 2006 @@ -23,8 +23,10 @@ #include <stdlib.h> #include <stdarg.h> +#include <stdio.h> #include <assert.h> - +#define _WIN32_WINNT 0x0500 +#define WINVER 0x0500 #include "windef.h" #include "winbase.h" #include "wingdi.h" @@ -33,6 +35,9 @@ #include "wine/test.h" static ATOM atomMenuCheckClass; + +static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO); +static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO); static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { @@ -49,11 +54,30 @@ } /* globals to communicate between test and wndproc */ + +#define MOD_SIZE 10 +#define MOD_NRMENUS 8 + + /* menu texts with their sizes */ +static struct { + char *text; + SIZE size; /* size of text up to any \t */ + SIZE sc_size; /* size of the short-cut */ +} MOD_txtsizes[] = { + { "Pinot &Noir" }, + { "&Merlot\bF4" }, + { "Shira&z\tAlt+S" }, + { "" }, + { NULL } +}; + unsigned int MOD_maxid; -RECT MOD_rc[4]; +RECT MOD_rc[MOD_NRMENUS]; int MOD_avec, MOD_hic; int MOD_odheight; -#define MOD_SIZE 10 +SIZE MODsizes[MOD_NRMENUS]= { {MOD_SIZE, MOD_SIZE},{MOD_SIZE, MOD_SIZE}, + {MOD_SIZE, MOD_SIZE},{MOD_SIZE, MOD_SIZE}}; +int MOD_GotDrawItemMsg = FALSE; /* wndproc used by test_menu_ownerdraw() */ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -64,11 +88,11 @@ { MEASUREITEMSTRUCT* pmis = (MEASUREITEMSTRUCT*)lparam; if( winetest_debug) - trace("WM_MEASUREITEM received %d,%d\n", - pmis->itemWidth, pmis->itemHeight); + trace("WM_MEASUREITEM received data %lx size %dx%d\n", + pmis->itemData, pmis->itemWidth, pmis->itemHeight); MOD_odheight = pmis->itemHeight; - pmis->itemWidth = MOD_SIZE; - pmis->itemHeight = MOD_SIZE; + pmis->itemWidth = MODsizes[pmis->itemData].cx; + pmis->itemHeight = MODsizes[pmis->itemData].cy; return TRUE; } case WM_DRAWITEM: @@ -78,18 +102,41 @@ HPEN oldpen; char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; SIZE sz; + int i; pdis = (DRAWITEMSTRUCT *) lparam; if( winetest_debug) { - trace("WM_DRAWITEM received itemdata %ld item %d rc %ld,%ld-%ld,%ld \n", - pdis->itemData, + RECT rc; + GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc); + trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %ld,%ld-%ld,%ld itemrc: %ld,%ld-%ld,%ld\n", + hwnd, (HMENU)pdis->hwndItem, pdis->itemData, pdis->itemID, pdis->rcItem.left, pdis->rcItem.top, - pdis->rcItem.right,pdis->rcItem.bottom ); + pdis->rcItem.right,pdis->rcItem.bottom, + rc.left,rc.top,rc.right,rc.bottom); oldpen=SelectObject( pdis->hDC, GetStockObject( pdis->itemState & ODS_SELECTED ? WHITE_PEN :BLACK_PEN)); Rectangle( pdis->hDC, pdis->rcItem.left,pdis->rcItem.top, pdis->rcItem.right,pdis->rcItem.bottom ); SelectObject( pdis->hDC, oldpen); } + /* calculate widths of some menu texts */ + if( ! MOD_txtsizes[0].size.cx) + for(i = 0; MOD_txtsizes[i].text; i++) { + char buf[100], *p; + RECT rc={0,0,0,0}; + strcpy( buf, MOD_txtsizes[i].text); + if( ( p = strchr( buf, '\t'))) { + *p = '\0'; + DrawText( pdis->hDC, p + 1, -1, &rc, + DT_SINGLELINE|DT_CALCRECT); + MOD_txtsizes[i].sc_size.cx= rc.right - rc.left; + MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top; + } + DrawText( pdis->hDC, buf, -1, &rc, + DT_SINGLELINE|DT_CALCRECT); + MOD_txtsizes[i].size.cx= rc.right - rc.left; + MOD_txtsizes[i].size.cy= rc.bottom - rc.top; + } + if( pdis->itemData > MOD_maxid) return TRUE; /* store the rectangl */ MOD_rc[pdis->itemData] = pdis->rcItem; @@ -98,7 +145,12 @@ MOD_avec = (sz.cx + 26)/52; GetTextMetrics( pdis->hDC, &tm); MOD_hic = tm.tmHeight; - if( pdis->itemData == MOD_maxid) PostMessage(hwnd, WM_CANCELMODE, 0, 0); + MOD_GotDrawItemMsg = TRUE; + return TRUE; + } + case WM_ENTERIDLE: + { + PostMessage(hwnd, WM_CANCELMODE, 0, 0); return TRUE; } @@ -125,7 +177,7 @@ atomMenuCheckClass = RegisterClass(&wc); } -/* demonstrates that windows lock the menu object so that it is still valid +/* demonstrates that windows locks the menu object so that it is still valid * even after a client calls DestroyMenu on it */ static void test_menu_locked_by_window(void) { @@ -172,7 +224,7 @@ NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError()); if( !hwnd) return; - SetWindowLong( hwnd, GWL_WNDPROC, (LONG)menu_ownerdraw_wnd_proc); + SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG)menu_ownerdraw_wnd_proc); hmenu = CreatePopupMenu(); ok(hmenu != NULL, "CreateMenu failed with error %ld\n", GetLastError()); if( !hmenu) { DestroyWindow(hwnd);return;} @@ -225,7 +277,7 @@ "Height is incorrect. Got %ld expected %d\n", MOD_rc[0].bottom - MOD_rc[0].top, MOD_SIZE); - /* test width/height of a OD menu bar as well */ + /* test width/height of an ownerdraw menu bar as well */ ret = DestroyMenu(hmenu); ok(ret, "DestroyMenu failed with error %ld\n", GetLastError()); hmenu = CreateMenu(); @@ -236,7 +288,7 @@ ret = AppendMenu( hmenu, MF_OWNERDRAW , i, 0); ok( ret, "AppendMenu failed for %d\n", i); } - SetMenu( hwnd, hmenu); + ret = SetMenu( hwnd, hmenu); UpdateWindow( hwnd); /* hack for wine to draw the window + menu */ ok(ret, "SetMenu failed with error %ld\n", GetLastError()); /* test width */ @@ -247,14 +299,1133 @@ ok( MOD_rc[0].bottom - MOD_rc[0].top == GetSystemMetrics( SM_CYMENU) - 1, "Height of owner drawn menu item is wrong. Got %ld expected %d\n", MOD_rc[0].bottom - MOD_rc[0].top, GetSystemMetrics( SM_CYMENU) - 1); + + /* clean up */ + ret = DestroyMenu(hmenu); + ok(ret, "DestroyMenu failed with error %ld\n", GetLastError()); + DestroyWindow(hwnd); +} + +/* helper for test_menu_bmp_and_string() */ +static void test_mbs_help( int ispop, int hassub, int mnuopt, + HWND hwnd, int arrowwidth, int count, HBITMAP hbmp, + SIZE bmpsize, char *text, SIZE size, SIZE sc_size) +{ + BOOL ret; + HMENU hmenu, submenu; + MENUITEMINFO mii={ sizeof( MENUITEMINFO )}; + MENUINFO mi; + RECT rc; + int hastab, expect; + int failed = 0; + + MOD_GotDrawItemMsg = FALSE; + mii.fMask = MIIM_FTYPE | MIIM_DATA | MIIM_STATE; + mii.fType = 0; + mii.fState = MF_CHECKED; + mii.dwItemData =0; + MODsizes[0] = bmpsize; + hastab = 0; + if( text ) { + char *p; + mii.fMask |= MIIM_STRING; + mii.dwTypeData = text; + if( ( p = strchr( text, '\t'))) { + hastab = *(p + 1) ? 2 : 1; + } + } + /* tabs don't make sense in menubars */ + if(hastab && !ispop) return; + if( hbmp) { + mii.fMask |= MIIM_BITMAP; + mii.hbmpItem = hbmp; + } + submenu = CreateMenu(); + ok( submenu != 0, "CreateMenu failed with error %ld\n", GetLastError()); + if( ispop) + hmenu = CreatePopupMenu(); + else + hmenu = CreateMenu(); + ok( hmenu != 0, "Create{Popup}Menu failed with error %ld\n", GetLastError()); + if( hassub) { + mii.fMask |= MIIM_SUBMENU; + mii.hSubMenu = submenu; + } + if( mnuopt) { + mi.cbSize = sizeof(mi); + mi.fMask = MIM_STYLE; + pGetMenuInfo( hmenu, &mi); + mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP; + ret = pSetMenuInfo( hmenu, &mi); + ok( ret, "SetMenuInfo failed with error %ld\n", GetLastError()); + } + ret = InsertMenuItem( hmenu, 0, FALSE, &mii); + ok( ret, "InsertMenuItem failed with error %ld\n", GetLastError()); + failed = !ret; + if( winetest_debug) { + HDC hdc=GetDC(hwnd); + RECT rc = {100, 50, 400, 70}; + char buf[100]; + + sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt); + FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW); + TextOut( hdc, 100, 50, buf, strlen( buf)); + ReleaseDC( hwnd, hdc); + } + if(ispop) + ret = TrackPopupMenu( hmenu, 0x100, 100,100, 0, hwnd, NULL); + else { + ret = SetMenu( hwnd, hmenu); + ok(ret, "SetMenu failed with error %ld\n", GetLastError()); + DrawMenuBar( hwnd); + } + ret = GetMenuItemRect( hwnd, hmenu, 0, &rc); + /* check menu width */ + if( ispop) + expect = ( text || hbmp ? + 4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0) + : 0) + + arrowwidth + MOD_avec + (hbmp ? bmpsize.cx + 2 : 0) + + (text && hastab ? /* TAB space */ + MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) + + (text ? 2 + (text[0] ? size.cx :0): 0) ; + else + expect = !(text || hbmp) ? 0 : + ( hbmp ? (text ? 2:0) + bmpsize.cx : 0 ) + + (text ? 2 * MOD_avec + (text[0] ? size.cx :0): 0) ; + ok( rc.right - rc.left == expect, + "menu width wrong, got %ld expected %d\n", rc.right - rc.left, expect); + failed = failed || !(rc.right - rc.left == expect); + /* check menu height */ + if( ispop) + expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0), + max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0), + (hbmp ? bmpsize.cy + 2 : 0))); + else + expect = ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : + max( GetSystemMetrics( SM_CYMENU) - 1, (hbmp ? bmpsize.cy : 0))); + ok( rc.bottom - rc.top == expect, + "menu height wrong, got %ld expected %d (%d)\n", + rc.bottom - rc.top, expect, GetSystemMetrics( SM_CYMENU)); + failed = failed || !(rc.bottom - rc.top == expect); + if( hbmp == HBMMENU_CALLBACK && MOD_GotDrawItemMsg) { + /* check the position of the bitmap */ + /* horizontal */ + expect = ispop ? (4 + ( mnuopt ? 0 : GetSystemMetrics(SM_CXMENUCHECK))) + : 3; + ok( expect == MOD_rc[0].left, + "bitmap left is %ld expected %d\n", MOD_rc[0].left, expect); + failed = failed || !(expect == MOD_rc[0].left); + /* vertical */ + expect = (rc.bottom - rc.top - MOD_rc[0].bottom + MOD_rc[0].top) / 2; + ok( expect == MOD_rc[0].top, + "bitmap top is %ld expected %d\n", MOD_rc[0].top, expect); + failed = failed || !(expect == MOD_rc[0].top); + } + /* if there was a failure, report details */ + if( failed) { + trace("*** count %d text \"%s\" bitmap %p bmsize %ld,%ld textsize %ld+%ld,%ld mnuopt %d hastab %d\n", + count, text ? text: "(nil)", hbmp, bmpsize.cx, bmpsize.cy, + size.cx, size.cy, sc_size.cx, mnuopt, hastab); + trace(" check %d,%d arrow %d avechar %d\n", + GetSystemMetrics(SM_CXMENUCHECK ), + GetSystemMetrics(SM_CYMENUCHECK ),arrowwidth, MOD_avec); + if( hbmp == HBMMENU_CALLBACK) + trace( " rc %ld,%ld-%ld,%ld bmp.rc %ld,%ld-%ld,%ld\n", + rc.left, rc.top, rc.top, rc.bottom, MOD_rc[0].left, + MOD_rc[0].top,MOD_rc[0].right, MOD_rc[0].bottom); + } + /* clean up */ + ret = DestroyMenu(submenu); + ok(ret, "DestroyMenu failed with error %ld\n", GetLastError()); + ret = DestroyMenu(hmenu); + ok(ret, "DestroyMenu failed with error %ld\n", GetLastError()); +} + + +static void test_menu_bmp_and_string(void) +{ + BYTE bmfill[300]; + HBITMAP hbm_arrow; + BITMAP bm; + INT arrowwidth; + HWND hwnd; + int count, szidx, txtidx, bmpidx, hassub, mnuopt, ispop; + + if( !pGetMenuInfo) return; + + memset( bmfill, 0x55, sizeof( bmfill)); + hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, NULL, NULL); + hbm_arrow=LoadBitmap( 0, (CHAR*)OBM_MNARROW); + GetObject( hbm_arrow, sizeof(bm), &bm); + arrowwidth = bm.bmWidth; + + ok(hwnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError()); + if( !hwnd) return; + SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG)menu_ownerdraw_wnd_proc); + + if( winetest_debug) + trace(" check %d,%d arrow %d avechar %d\n", + GetSystemMetrics(SM_CXMENUCHECK ), + GetSystemMetrics(SM_CYMENUCHECK ),arrowwidth, MOD_avec); + count = 0; + MOD_maxid = 0; + for( ispop=1; ispop >= 0; ispop--){ + static SIZE bmsizes[]= { + {10,10},{38,38},{1,30},{55,5}}; + for( szidx=0; szidx < sizeof( bmsizes) / sizeof( SIZE); szidx++) { + HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill); + HBITMAP bitmaps[] = { HBMMENU_CALLBACK, hbm, NULL }; + ok( (int)hbm, "CreateBitmap failed err %ld\n", GetLastError()); + for( txtidx = 0; txtidx < sizeof(MOD_txtsizes)/sizeof(MOD_txtsizes[0]); txtidx++) { + for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */ + for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */ + for( bmpidx = 0; bmpidx <sizeof(bitmaps)/sizeof(HBITMAP); bmpidx++) { + /* no need to test NULL bitmaps of several sizes */ + if( !bitmaps[bmpidx] && szidx > 0) continue; + if( !ispop && hassub) continue; + test_mbs_help( ispop, hassub, mnuopt, + hwnd, arrowwidth, ++count, + bitmaps[bmpidx], + bmsizes[szidx], + MOD_txtsizes[txtidx].text, + MOD_txtsizes[txtidx].size, + MOD_txtsizes[txtidx].sc_size); + } + } + } + } + DeleteObject( hbm); + } + } /* clean up */ DestroyWindow(hwnd); } +static void test_menu_add_string( void ) +{ + HMENU hmenu; + MENUITEMINFO info; + BOOL rc; + + char string[0x80]; + char string2[0x80]; + + char strback[0x80]; + WCHAR strbackW[0x80]; + static const WCHAR expectedString[] = {'D', 'u', 'm', 'm', 'y', ' ', + 's', 't', 'r', 'i', 'n', 'g', 0}; + + hmenu = CreateMenu(); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_ID; + info.dwTypeData = "blah"; + info.cch = 6; + info.dwItemData = 0; + info.wID = 1; + info.fState = 0; + InsertMenuItem(hmenu, 0, TRUE, &info ); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_ID; + info.dwTypeData = string; + info.cch = sizeof string; + string[0] = 0; + GetMenuItemInfo( hmenu, 0, TRUE, &info ); + + ok( !strcmp( string, "blah" ), "menu item name differed\n"); + + /* Test combination of ownerdraw and strings with GetMenuItemString(A/W) */ + strcpy(string, "Dummy string"); + memset(&info, 0x00, sizeof(info)); + info.cbSize= sizeof(MENUITEMINFO); + info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */ + info.fType= MFT_OWNERDRAW; + info.dwTypeData= string; + rc = InsertMenuItem( hmenu, 0, TRUE, &info ); + ok (rc, "InsertMenuItem failed\n"); + + strcpy(string,"Garbage"); + ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); + + ok (GetMenuStringW( hmenu, 0, (WCHAR *)strbackW, 99, MF_BYPOSITION), "GetMenuStringW on ownerdraw entry failed\n"); + ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n"); + + /* Just change ftype to string and see what text is stored */ + memset(&info, 0x00, sizeof(info)); + info.cbSize= sizeof(MENUITEMINFO); + info.fMask= MIIM_FTYPE; /* Set string type */ + info.fType= MFT_STRING; + info.dwTypeData= (char *)0xdeadbeef; + rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + ok (rc, "SetMenuItemInfo failed\n"); + + /* Did we keep the old dwTypeData? */ + ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); + + /* Ensure change to bitmap type fails */ + memset(&info, 0x00, sizeof(info)); + info.cbSize= sizeof(MENUITEMINFO); + info.fMask= MIIM_FTYPE; /* Set as bitmap type */ + info.fType= MFT_BITMAP; + info.dwTypeData= (char *)0xdeadbee2; + rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + ok (!rc, "SetMenuItemInfo unexpectedly worked\n"); + + /* Just change ftype back and ensure data hasn't been freed */ + info.fType= MFT_OWNERDRAW; /* Set as ownerdraw type */ + info.dwTypeData= (char *)0xdeadbee3; + rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + ok (rc, "SetMenuItemInfo failed\n"); + + /* Did we keep the old dwTypeData? */ + ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); + + /* Just change string value (not type) */ + memset(&info, 0x00, sizeof(info)); + info.cbSize= sizeof(MENUITEMINFO); + info.fMask= MIIM_STRING; /* Set typeData */ + strcpy(string2, "string2"); + info.dwTypeData= string2; + rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + ok (rc, "SetMenuItemInfo failed\n"); + + ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (!strcmp( strback, "string2" ), "Menu text from Ansi version incorrect\n"); + + /* crashes with wine 0.9.5 */ + memset(&info, 0x00, sizeof(info)); + info.cbSize= sizeof(MENUITEMINFO); + info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */ + info.fType= MFT_OWNERDRAW; + rc = InsertMenuItem( hmenu, 0, TRUE, &info ); + ok (rc, "InsertMenuItem failed\n"); + ok (!GetMenuString( hmenu, 0, NULL, 0, MF_BYPOSITION), + "GetMenuString on ownerdraw entry succeeded.\n"); + ok (!GetMenuStringW( hmenu, 0, NULL, 0, MF_BYPOSITION), + "GetMenuStringW on ownerdraw entry succeeded.\n"); + + + DestroyMenu( hmenu ); +} + +/* define building blocks for the menu item info tests */ +static int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) +{ + if (n <= 0) return 0; + while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; } + return *str1 - *str2; +} + +static WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) +{ + WCHAR *p = dst; + while ((*p++ = *src++)); + return dst; +} + + +#define DMIINFF( i, e, field)\ + ok((int)((i)->field)==(int)((e)->field) || (int)((i)->field)==(0xffff & (int)((e)->field)), \ + "%s got 0x%x expected 0x%x\n", #field, (int)((i)->field), (int)((e)->field)); + +#define DUMPMIINF(s,i,e)\ +{\ + DMIINFF( i, e, fMask)\ + DMIINFF( i, e, fType)\ + DMIINFF( i, e, fState)\ + DMIINFF( i, e, wID)\ + DMIINFF( i, e, hSubMenu)\ + DMIINFF( i, e, hbmpChecked)\ + DMIINFF( i, e, hbmpUnchecked)\ + DMIINFF( i, e, dwItemData)\ + DMIINFF( i, e, dwTypeData)\ + DMIINFF( i, e, cch)\ + if( s==sizeof(MENUITEMINFOA)) DMIINFF( i, e, hbmpItem)\ +} + +/* insert menu item */ +#define TMII_INSMI( a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,\ + eret1)\ +{\ + MENUITEMINFOA info1=a1 b1,c1,d1,e1,f1,(void*)g1,(void*)h1,(void*)i1,j1,(void*)k1,l1,(void*)m1 n1;\ + HMENU hmenu = CreateMenu();\ + BOOL ret, stop = FALSE;\ + SetLastError( 0xdeadbeef);\ + if(ansi)strcpy( string, init);\ + else strcpyW( (WCHAR*)string, (WCHAR*)init);\ + if( ansi) ret = InsertMenuItemA(hmenu, 0, TRUE, &info1 );\ + else ret = InsertMenuItemW(hmenu, 0, TRUE, (MENUITEMINFOW*)&info1 );\ + if( !(eret1)) { ok( (eret1)==ret,"InsertMenuItem should have failed.\n");\ + stop = TRUE;\ + } else ok( (eret1)==ret,"InsertMenuItem failed, err %ld\n",GetLastError());\ + + +/* GetMenuItemInfo + GetMenuString */ +#define TMII_GMII( a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,\ + a3,b3,c3,d3,e3,f3,g3,h3,i3,j3,k3,l3,m3,n3,\ + expname, eret2, eret3)\ +{\ + MENUITEMINFOA info2A=a2 b2,c2,d2,e2,f2,(void*)g2,(void*)h2,(void*)i2,j2,(void*)k2,l2,(void*)m2 n2;\ + MENUITEMINFOA einfoA=a3 b3,c3,d3,e3,f3,(void*)g3,(void*)h3,(void*)i3,j3,(void*)k3,l3,(void*)m3 n3;\ + MENUITEMINFOA *info2 = &info2A;\ + MENUITEMINFOA *einfo = &einfoA;\ + MENUITEMINFOW *info2W = (MENUITEMINFOW *)&info2A;\ + if( !stop) {\ + ret = ansi ? GetMenuItemInfoA( hmenu, 0, TRUE, info2 ) :\ + GetMenuItemInfoW( hmenu, 0, TRUE, info2W );\ + if( !(eret2)) ok( (eret2)==ret,"GetMenuItemInfo should have failed.\n");\ + else { \ + ok( (eret2)==ret,"GetMenuItemInfo failed, err %ld\n",GetLastError());\ + ret = memcmp( info2, einfo, sizeof einfoA);\ + /* ok( ret==0, "Got wrong menu item info data\n");*/\ + if( ret) DUMPMIINF(info2A.cbSize, &info2A, &einfoA)\ + if( einfo->dwTypeData == string) {\ + if(ansi) ok( !strncmp( expname, info2->dwTypeData, einfo->cch ), "menu item name differed \"%s\"\n",\ + einfo->dwTypeData ? einfo->dwTypeData: "");\ + else ok( !strncmpW( (WCHAR*)expname, (WCHAR*)info2->dwTypeData, einfo->cch ), "menu item name differed \"%s\"\n",\ + einfo->dwTypeData ? einfo->dwTypeData: "");\ + ret = ansi ? GetMenuStringA( hmenu, 0, string, 80, MF_BYPOSITION) :\ + GetMenuStringW( hmenu, 0, string, 80, MF_BYPOSITION);\ + if( (eret3)){\ + ok( ret, "GetMenuString failed, err %ld\n",GetLastError());\ + }else\ + ok( !ret, "GetMenuString should have failed\n");\ + }\ + }\ + }\ +} + +#define TMII_DONE \ + RemoveMenu(hmenu, 0, TRUE );\ + DestroyMenu( hmenu );\ + DestroyMenu( submenu );\ +submenu = CreateMenu();\ +} +/* modify menu */ +#define TMII_MODM( flags, id, data, eret )\ +if( !stop) {\ + if(ansi)ret = ModifyMenuA( hmenu, 0, flags, (UINT_PTR)id, (char*)data);\ + else ret = ModifyMenuW( hmenu, 0, flags, (UINT_PTR)id, (WCHAR*)data);\ + if( !(eret)) ok( (eret)==ret,"ModifyMenuA should have failed.\n");\ + else ok( (eret)==ret,"ModifyMenuA failed, err %ld\n",GetLastError());\ +} + +/* SetMenuItemInfo */ +#define TMII_SMII( a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,\ + eret1)\ +if( !stop) {\ + MENUITEMINFOA info1=a1 b1,c1,d1,e1,f1,(void*)g1,(void*)h1,(void*)i1,j1,(void*)k1,l1,(void*)m1 n1;\ + SetLastError( 0xdeadbeef);\ + if(ansi)strcpy( string, init);\ + else strcpyW( (WCHAR*)string, (WCHAR*)init);\ + if( ansi) ret = SetMenuItemInfoA(hmenu, 0, TRUE, &info1 );\ + else ret = SetMenuItemInfoW(hmenu, 0, TRUE, (MENUITEMINFOW*)&info1 );\ + if( !(eret1)) { ok( (eret1)==ret,"InsertMenuItem should have failed.\n");\ + stop = TRUE;\ + } else ok( (eret1)==ret,"InsertMenuItem failed, err %ld\n",GetLastError());\ +} + + + +#define OK 1 +#define ER 0 + + +static void test_menu_iteminfo( void ) +{ + int S=sizeof( MENUITEMINFOA); + int ansi = TRUE; + char txtA[]="wine"; + char initA[]="XYZ"; + char emptyA[]=""; + WCHAR txtW[]={'W','i','n','e',0}; + WCHAR initW[]={'X','Y','Z',0}; + WCHAR emptyW[]={0}; + void *txt, *init, *empty, *string; + HBITMAP hbm = CreateBitmap(1,1,1,1,NULL); + char stringA[0x80]; + HMENU submenu=CreateMenu(); + + do { + if( ansi) {txt=txtA;init=initA;empty=emptyA;string=stringA;} + else {txt=txtW;init=initW;empty=emptyW;string=stringA;} + trace( "%s string %p hbm %p txt %p\n", ansi ? "ANSI tests: " : "Unicode tests:", string, hbm, txt); + /* test all combinations of MFT_STRING, MFT_OWNERDRAW and MFT_BITMAP */ + /* (since MFT_STRING is zero, there are four of them) */ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, 0, 0, 0, 0, 0, 0, txt, 0, 0, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, 0, 0, 0, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_BITMAP, -1, -1, -1, -1, -1, -1, hbm, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP, -9, -9, 0, -9, -9, -9, hbm, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_BITMAP|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, hbm, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, hbm, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + /* not enough space for name*/ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, NULL, 0, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, NULL, 4, 0, }, + empty, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 5, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 4, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 3, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING, MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, NULL, 0, -9, }, + {, S, MIIM_TYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 0, 0, }, + empty, OK, ER ) + TMII_DONE + /* cannot combine MIIM_TYPE with some other flags */ + TMII_INSMI( {, S, MIIM_TYPE|MIIM_STRING, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_STRING, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, ER, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE|MIIM_FTYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, ER, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE|MIIM_BITMAP, MFT_BITMAP, -1, -1, -1, -1, -1, -1, hbm, 6, hbm, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, OK, OK ) + TMII_DONE + /* but succeeds with some others */ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_SUBMENU, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_SUBMENU, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_STATE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_STATE, MFT_STRING, 0, -9, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE|MIIM_ID, MFT_STRING, -1, 888, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_ID, MFT_STRING, -9, 888, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING, -1, -1, -1, -1, -1, 999, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_DATA, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING, -9, -9, 0, -9, -9, 999, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + /* to be continued */ + /* set text with MIIM_TYPE and retrieve with MIIM_STRING */ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, -9, }, + txt, OK, OK ) + TMII_DONE + /* set text with MIIM_TYPE and retrieve with MIIM_STRING; MFT_OWNERDRAW causes an empty string */ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 0, -9, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 0, -9, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 80, -9, }, + init, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, 0, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, 0, -9, -9, -9, 0, -9, -9, -9, string, 80, -9, }, + init, OK, OK ) + TMII_DONE + /* contrary to MIIM_TYPE,you can set the text for an owner draw menu */ + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 4, -9, }, + txt, OK, OK ) + TMII_DONE + /* same but retrieve with MIIM_TYPE */ + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 0, -9, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 0, -9, }, + empty, OK, ER ) + TMII_DONE + + /* How is that with bitmaps? */ + TMII_INSMI( {, S, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP, -9, -9, 0, -9, -9, -9, hbm, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_BITMAP|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_BITMAP|MIIM_FTYPE, 0, -9, -9, 0, -9, -9, -9, string, 80, hbm, }, + init, OK, ER ) + TMII_DONE + /* MIIM_BITMAP does not like MFT_BITMAP */ + TMII_INSMI( {, S, MIIM_BITMAP|MIIM_FTYPE, MFT_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + init, OK, OK ) + TMII_DONE + /* no problem with OWNERDRAWN */ + TMII_INSMI( {, S, MIIM_BITMAP|MIIM_FTYPE, MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_BITMAP|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_BITMAP|MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 80, hbm, }, + init, OK, ER ) + TMII_DONE + /* setting MFT_BITMAP with MFT_FTYPE fails anyway */ + TMII_INSMI( {, S, MIIM_FTYPE, MFT_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + empty, OK, OK ) + TMII_DONE + + /* menu with submenu */ + TMII_INSMI( {, S, MIIM_SUBMENU|MIIM_FTYPE, MFT_STRING, -1, -1, submenu, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_SUBMENU, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_SUBMENU, -9, -9, -9, submenu, -9, -9, -9, string, 80, -9, }, + init, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_SUBMENU|MIIM_FTYPE, MFT_STRING, -1, -1, submenu, -1, -1, -1, empty, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_SUBMENU, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_SUBMENU, -9, -9, -9, submenu, -9, -9, -9, string, 80, -9, }, + init, OK, ER ) + TMII_DONE + /* menu with submenu, without MIIM_SUBMENU the submenufield is cleared */ + TMII_INSMI( {, S, MIIM_SUBMENU|MIIM_FTYPE, MFT_STRING, -1, -1, submenu, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING|MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 0, -9, }, + empty, OK, ER ) + TMII_GMII ( {, S, MIIM_SUBMENU|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_SUBMENU|MIIM_FTYPE, MFT_SEPARATOR, -9, -9, submenu, -9, -9, -9, string, 80, -9, }, + empty, OK, ER ) + TMII_DONE + /* menu with invalid submenu */ + TMII_INSMI( {, S, MIIM_SUBMENU|MIIM_FTYPE, MFT_STRING, -1, -1, 999, -1, -1, -1, txt, 0, -1, }, ER) + TMII_GMII ( {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + {, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, + init, OK, ER ) + TMII_DONE + + TMII_INSMI( {, S, MIIM_TYPE, MFT_SEPARATOR, 0, 0, 0, 0, 0, 0, txt, 0, 0, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, 0, 0, 0, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_BITMAP|MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, hbm, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP|MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, hbm, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + /* SEPARATOR and STRING go well together */ + /* BITMAP and STRING go well together */ + TMII_INSMI( {, S, MIIM_STRING|MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + /* BITMAP, SEPARATOR and STRING go well together */ + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + /* last two tests, but use MIIM_TYPE to retrieve info */ + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING, MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_STRING|MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP, -9, -9, 0, -9, -9, -9, hbm, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR|MFT_BITMAP, -9, -9, 0, -9, -9, -9, hbm, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + /* same three with MFT_OWNERDRAW */ + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING, MFT_SEPARATOR|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_BITMAP|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, hbm, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR|MFT_BITMAP|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, hbm, 4, hbm, }, + txt, OK, OK ) + TMII_DONE + + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE|MIIM_ID, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + /* test with modifymenu: string is preserved after seting OWNERDRAW */ + TMII_INSMI( {, S, MIIM_STRING, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_MODM( MFT_OWNERDRAW, -1, 787, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_DATA, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_DATA, MFT_OWNERDRAW, -9, -9, 0, -9, -9, 787, string, 4, -9, }, + txt, OK, OK ) + TMII_DONE + /* same with bitmap: now the text is cleared */ + TMII_INSMI( {, S, MIIM_STRING, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_MODM( MFT_BITMAP, 545, hbm, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, MFT_BITMAP, -9, 545, 0, -9, -9, -9, string, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + /* start with bitmap: now setting text clears it (though he flag is raised) */ + TMII_INSMI( {, S, MIIM_BITMAP, MFT_STRING, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, MFT_STRING, -9, 0, 0, -9, -9, -9, string, 0, hbm, }, + empty, OK, ER ) + TMII_MODM( MFT_STRING, 545, txt, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, MFT_STRING, -9, 545, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + /*repeat with text NULL */ + TMII_INSMI( {, S, MIIM_BITMAP, MFT_STRING, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_MODM( MFT_STRING, 545, NULL, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, MFT_SEPARATOR, -9, 545, 0, -9, -9, -9, string, 0, 0, }, + empty, OK, ER ) + TMII_DONE + /* repeat with text "" */ + TMII_INSMI( {, S, MIIM_BITMAP, -1 , -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_MODM( MFT_STRING, 545, empty, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_ID, MFT_STRING, -9, 545, 0, -9, -9, -9, string, 0, 0, }, + empty, OK, ER ) + TMII_DONE + /* start with bitmap: set ownerdraw */ + TMII_INSMI( {, S, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_MODM( MFT_OWNERDRAW, -1, 232, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_DATA, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP|MIIM_DATA, MFT_OWNERDRAW, -9, -9, 0, -9, -9, 232, string, 0, hbm, }, + empty, OK, ER ) + TMII_DONE + /* ask nothing */ + TMII_INSMI( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, 0, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, 0, -9, -9, -9, 0, -9, -9, -9, string, 80, -9, }, + init, OK, OK ) + TMII_DONE + /* some tests with small cbSize: the hbmpItem is to be ignored */ + TMII_INSMI( {, S - 4, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, NULL, 0, NULL, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S - 4, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_BITMAP|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_BITMAP|MIIM_FTYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 80, NULL, }, + init, OK, ER ) + TMII_DONE + TMII_INSMI( {, S - 4, MIIM_STRING|MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S - 4, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S - 4, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + TMII_INSMI( {, S - 4, MIIM_FTYPE|MIIM_STRING|MIIM_BITMAP, MFT_SEPARATOR|MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, txt, 6, hbm, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_SEPARATOR|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, NULL, 4, NULL, }, + txt, OK, OK ) + TMII_DONE + /* MIIM_TYPE by itself does not get/set the dwItemData for OwnerDrawn menus */ + TMII_INSMI( {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, 343, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_DATA, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING|MFT_OWNERDRAW, -9, -9, 0, -9, -9, 343, 0, 0, 0, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, 343, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, 0, 0, 0, }, + empty, OK, ER ) + TMII_DONE + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING|MFT_OWNERDRAW, -1, -1, -1, -1, -1, 343, txt, 0, -1, }, OK) + TMII_GMII ( {, S, MIIM_TYPE|MIIM_DATA, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE|MIIM_DATA, MFT_STRING|MFT_OWNERDRAW, -9, -9, 0, -9, -9, 0, 0, 0, 0, }, + empty, OK, ER ) + TMII_DONE + /* set a string menu to ownerdraw with MIIM_TYPE */ + TMII_INSMI( {, S, MIIM_TYPE, MFT_STRING, -2, -2, -2, -2, -2, -2, txt, -2, -2, }, OK) + TMII_SMII( {, S, MIIM_TYPE, MFT_OWNERDRAW, -1, -1, -1, -1, -1, -1, -1, -1, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_OWNERDRAW, -9, -9, 0, -9, -9, -9, string, 4, -9, }, + txt, OK, OK ) + TMII_DONE + /* test with modifymenu add submenu */ + TMII_INSMI( {, S, MIIM_STRING, MFT_STRING, -1, -1, -1, -1, -1, -1, txt, 0, -1, }, OK) + TMII_MODM( MF_POPUP, submenu, txt, OK) + TMII_GMII ( {, S, MIIM_FTYPE|MIIM_STRING|MIIM_SUBMENU, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_FTYPE|MIIM_STRING|MIIM_SUBMENU, MFT_STRING, -9, -9, submenu, -9, -9, -9, string, 4, -9, }, + txt, OK, OK ) + TMII_GMII ( {, S, MIIM_TYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_TYPE, MFT_STRING, -9, -9, 0, -9, -9, -9, string, 4, 0, }, + txt, OK, OK ) + TMII_DONE + /* MFT_SEPARATOR bit is kept when the text is added */ + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_SMII( {, S, MIIM_STRING, -1, -1, -1, -1, -1, -1, -1, txt, -1, -1, }, OK) + TMII_GMII ( {, S, MIIM_STRING|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_STRING|MIIM_FTYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 4, -9, }, + txt, OK, OK ) + TMII_DONE + /* MFT_SEPARATOR bit is kept when bitmap is added */ + TMII_INSMI( {, S, MIIM_STRING|MIIM_FTYPE, MFT_STRING, -1, -1, -1, -1, -1, -1, NULL, 0, -1, }, OK) + TMII_SMII( {, S, MIIM_BITMAP, -1, -1, -1, -1, -1, -1, -1, -1, -1, hbm, }, OK) + TMII_GMII ( {, S, MIIM_BITMAP|MIIM_FTYPE, -9, -9, -9, -9, -9, -9, -9, string, 80, -9, }, + {, S, MIIM_BITMAP|MIIM_FTYPE, MFT_SEPARATOR, -9, -9, 0, -9, -9, -9, string, 80, hbm, }, + init, OK, ER ) + TMII_DONE + + } while( !(ansi = !ansi) ); + DeleteObject( hbm); +} + +/* + The following tests try to confirm the algorithm used to return the menu items + when there is a collision between a menu item and a popup menu + */ +void test_menu_search_bycommand( void ) +{ + HMENU hmenu, hmenuSub, hmenuSub2; + MENUITEMINFO info; + BOOL rc; + UINT id; + char strback[0x80]; + char strIn[0x80]; + + /* Case 1: Menu containing a menu item */ + hmenu = CreateMenu(); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + strcpy(strIn, "Case 1 MenuItem"); + info.dwTypeData = strIn; + info.wID = (UINT) 0x1234; + + rc = InsertMenuItem(hmenu, 0, TRUE, &info ); + ok (rc, "Inserting the menuitem failed\n"); + + id = GetMenuItemID(hmenu, 0); + ok (id == 0x1234, "Getting the menuitem id failed(gave %x)\n", id); + + /* Confirm the menuitem was given the id supplied (getting by position) */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + + rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); /* Get by position */ + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == 0x1234, "IDs differ for the menuitem\n"); + ok (!strcmp(info.dwTypeData, "Case 1 MenuItem"), "Returned item has wrong label\n"); + + /* Search by id - Should return the item */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + rc = GetMenuItemInfo(hmenu, 0x1234, FALSE, &info); /* Get by ID */ + + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == 0x1234, "IDs differ for the menuitem\n"); + ok (!strcmp(info.dwTypeData, "Case 1 MenuItem"), "Returned item has wrong label\n"); + + DestroyMenu( hmenu ); + + /* Case 2: Menu containing a popup menu */ + hmenu = CreateMenu(); + hmenuSub = CreateMenu(); + + strcpy(strIn, "Case 2 SubMenu"); + rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, strIn); + ok (rc, "Inserting the popup menu into the main menu failed\n"); + + id = GetMenuItemID(hmenu, 0); + ok (id == -1, "Getting the menuitem id unexpectedly worked (gave %x)\n", id); + + /* Confirm the menuitem itself was given an id the same as the HMENU, (getting by position) */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + info.wID = 0xdeadbeef; + + rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); /* Get by position */ + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the menuitem\n"); + ok (!strcmp(info.dwTypeData, "Case 2 SubMenu"), "Returned item has wrong label\n"); + + /* Search by id - returns the popup menu itself */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); + ok (!strcmp(info.dwTypeData, "Case 2 SubMenu"), "Returned item has wrong label\n"); + + /* + Now add an item after it with the same id + */ + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + strcpy(strIn, "Case 2 MenuItem 1"); + info.dwTypeData = strIn; + info.wID = (UINT_PTR) hmenuSub; + rc = InsertMenuItem(hmenu, -1, TRUE, &info ); + ok (rc, "Inserting the menuitem failed\n"); + + /* Search by id - returns the item which follows the popup menu */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); + ok (!strcmp(info.dwTypeData, "Case 2 MenuItem 1"), "Returned item has wrong label (%s)\n", info.dwTypeData); + + /* + Now add an item before the popup (with the same id) + */ + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + strcpy(strIn, "Case 2 MenuItem 2"); + info.dwTypeData = strIn; + info.wID = (UINT_PTR) hmenuSub; + rc = InsertMenuItem(hmenu, 0, TRUE, &info ); + ok (rc, "Inserting the menuitem failed\n"); + + /* Search by id - returns the item which precedes the popup menu */ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; + info.dwTypeData = strback; + info.cch = sizeof(strback); + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + + ok (rc, "Getting the menu items info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); + ok (!strcmp(info.dwTypeData, "Case 2 MenuItem 2"), "Returned item has wrong label (%s)\n", info.dwTypeData); + + DestroyMenu( hmenu ); + DestroyMenu( hmenuSub ); + + /* + Case 3: Menu containing a popup menu which in turn + contains 2 items with the same id as the popup itself + */ + + hmenu = CreateMenu(); + hmenuSub = CreateMenu(); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + info.dwTypeData = "MenuItem"; + info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ + + rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); + ok (rc, "Inserting the popup menu into the main menu failed\n"); + + rc = InsertMenuItem(hmenuSub, 0, TRUE, &info ); + ok (rc, "Inserting the sub menu menuitem failed\n"); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + info.dwTypeData = "MenuItem 2"; + info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ + + rc = InsertMenuItem(hmenuSub, 1, TRUE, &info ); + ok (rc, "Inserting the sub menu menuitem 2 failed\n"); + + /* Prove that you can't query the id of a popup directly (By position) */ + id = GetMenuItemID(hmenu, 0); + ok (id == -1, "Getting the sub menu id should have failed because its a popup (gave %x)\n", id); + + /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_STRING | MIIM_ID; + info.dwTypeData = strback; + info.cch = sizeof(strback); + + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); + ok (rc, "Getting the menus info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for popup menu\n"); + ok (!strcmp(info.dwTypeData, "MenuItem"), "Returned item has wrong label (%s)\n", info.dwTypeData); + DestroyMenu( hmenu ); + DestroyMenu( hmenuSub ); + + /* + Case 4: Menu containing 2 popup menus, the second + contains 2 items with the same id as the first popup menu + */ + hmenu = CreateMenu(); + hmenuSub = CreateMenu(); + hmenuSub2 = CreateMenu(); + + rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); + ok (rc, "Inserting the popup menu into the main menu failed\n"); + + rc = InsertMenu(hmenu, 1, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub2, "Submenu2"); + ok (rc, "Inserting the popup menu into the main menu failed\n"); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + info.dwTypeData = "MenuItem"; + info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ + + rc = InsertMenuItem(hmenuSub2, 0, TRUE, &info ); + ok (rc, "Inserting the sub menu menuitem failed\n"); + + memset( &info, 0, sizeof info ); + info.cbSize = sizeof info; + info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; + info.fType = MFT_STRING; + info.dwTypeData = "MenuItem 2"; + info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ + + rc = InsertMenuItem(hmenuSub2, 1, TRUE, &info ); + ok (rc, "Inserting the sub menu menuitem 2 failed\n"); + + /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/ + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_STRING | MIIM_ID; + info.dwTypeData = strback; + info.cch = sizeof(strback); + + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); + ok (rc, "Getting the menus info failed\n"); + ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for popup menu\n"); + ok (!strcmp(info.dwTypeData, "MenuItem"), "Returned item has wrong label (%s)\n", info.dwTypeData); + + memset( &info, 0, sizeof info ); + strback[0] = 0x00; + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_STRING | MIIM_ID; + info.dwTypeData = strback; + info.cch = sizeof(strback); + + rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub2, FALSE, &info); + ok (rc, "Getting the menus info failed\n"); + ok (info.wID == (UINT)hmenuSub2, "IDs differ for popup menu\n"); + ok (!strcmp(info.dwTypeData, "Submenu2"), "Returned item has wrong label (%s)\n", info.dwTypeData); +} + START_TEST(menu) { + pSetMenuInfo = + (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "SetMenuInfo" ); + pGetMenuInfo = + (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetMenuInfo" ); + register_menu_check_class(); test_menu_locked_by_window(); test_menu_ownerdraw(); -} + test_menu_add_string(); + test_menu_iteminfo(); + test_menu_search_bycommand(); + test_menu_bmp_and_string(); +} Propchange: trunk/reactos/regtests/winetests/user32/menu.c ------------------------------------------------------------------------------ native = class.c Added: trunk/reactos/regtests/winetests/user32/monitor.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/m…
============================================================================== --- trunk/reactos/regtests/winetests/user32/monitor.c (added) +++ trunk/reactos/regtests/winetests/user32/monitor.c Wed Apr 5 06:34:10 2006 @@ -1,0 +1,106 @@ +/* + * Unit tests for monitor APIs + * + * Copyright 2005 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#define _WIN32_WINNT 0x0500 + +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" + +static HMODULE hdll; +static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD); +static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM); +static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); + +static void init_function_pointers(void) +{ + hdll = GetModuleHandleA("user32.dll"); + + if(hdll) + { + pEnumDisplayDevicesA = (void*)GetProcAddress(hdll, "EnumDisplayDevicesA"); + pEnumDisplayMonitors = (void*)GetProcAddress(hdll, "EnumDisplayMonitors"); + pGetMonitorInfoA = (void*)GetProcAddress(hdll, "GetMonitorInfoA"); + } +} + +static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc, + LPARAM lparam) +{ + MONITORINFOEXA mi; + char *primary = (char *)lparam; + + mi.cbSize = sizeof(mi); + + ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n"); + if(mi.dwFlags == MONITORINFOF_PRIMARY) + strcpy(primary, mi.szDevice); + + return TRUE; +} + +static void test_enumdisplaydevices(void) +{ + DISPLAY_DEVICEA dd; + char primary_device_name[32]; + char primary_monitor_device_name[32]; + DWORD primary_num = -1, num = 0; + + dd.cb = sizeof(dd); + if(pEnumDisplayDevicesA == NULL) return; + while(1) + { + BOOL ret; + HDC dc; + ret = pEnumDisplayDevicesA(NULL, num, &dd, 0); + ok(ret || num != 0, "EnumDisplayDevices fails with num == 0\n"); + if(!ret) break; + if(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) + { + strcpy(primary_device_name, dd.DeviceName); + primary_num = num; + } + if(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) + { + /* test creating DC */ + dc = CreateDCA(dd.DeviceName, NULL, NULL, NULL); + ok(dc != NULL, "Failed to CreateDC(\"%s\") err=%ld\n", dd.DeviceName, GetLastError()); + DeleteDC(dc); + } + num++; + } + ok(primary_num != -1, "Didn't get the primary device\n"); + + if(pEnumDisplayMonitors && pGetMonitorInfoA) { + ok(pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name), + "EnumDisplayMonitors failed\n"); + + ok(!strcmp(primary_monitor_device_name, primary_device_name), + "monitor device name %s, device name %s\n", primary_monitor_device_name, + primary_device_name); + } +} + + +START_TEST(monitor) +{ + init_function_pointers(); + test_enumdisplaydevices(); +} Propchange: trunk/reactos/regtests/winetests/user32/monitor.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/msg.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/m…
============================================================================== --- trunk/reactos/regtests/winetests/user32/msg.c (original) +++ trunk/reactos/regtests/winetests/user32/msg.c Wed Apr 5 06:34:10 2006 @@ -25,18 +25,20 @@ #include <stdio.h> #define WINVER 0x0500 -#define _WIN32_WINNT 0x0500 /* For WM_CHANGEUISTATE */ +#define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */ #include "windef.h" #include "winbase.h" #include "wingdi.h" #include "winuser.h" +#include "winnls.h" #include "wine/test.h" +#define OBJID_QUERYCLASSNAMEIDX -12 +#define OBJID_NATIVEOM -16 + #define MDI_FIRST_CHILD_ID 2004 -#define OBJID_QUERYCLASSNAMEIDX -12 // Fixme w32api -#define OBJID_NATIVEOM -16 // ditto /* undocumented SWP flags - from SDK 3.1 */ #define SWP_NOCLIENTSIZE 0x0800 @@ -127,6 +129,7 @@ { WM_NCCALCSIZE, sent|wparam|optional, 1 }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_ERASEBKGND, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { 0 } }; /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE) @@ -156,6 +159,7 @@ { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */ { 0 } }; @@ -189,6 +193,59 @@ { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE }, { WM_MOVE, sent|defwinproc|wparam, 0 }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + +/* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE| + SWP_NOZORDER|SWP_FRAMECHANGED) + * for a visible overlapped window with WS_CLIPCHILDREN style set. + */ +static const struct message WmSWP_FrameChanged_clip[] = { + { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED }, + { WM_NCCALCSIZE, sent|wparam|parent, 1 }, + { WM_NCPAINT, sent|parent }, /* wparam != 1 */ + { WM_GETTEXT, sent|parent|defwinproc|optional }, + { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */ + { WM_NCPAINT, sent }, /* wparam != 1 */ + { WM_ERASEBKGND, sent }, + { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { WM_PAINT, sent }, + { 0 } +}; +/* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE| + SWP_NOZORDER|SWP_FRAMECHANGED) + * for a visible overlapped window. + */ +static const struct message WmSWP_FrameChangedDeferErase[] = { + { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED }, + { WM_NCCALCSIZE, sent|wparam|parent, 1 }, + { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { WM_PAINT, sent|parent }, + { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */ + { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional }, + { WM_PAINT, sent }, + { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */ + { WM_ERASEBKGND, sent|beginpaint }, + { 0 } +}; + +/* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE| + SWP_NOZORDER|SWP_FRAMECHANGED) + * for a visible overlapped window without WS_CLIPCHILDREN style set. + */ +static const struct message WmSWP_FrameChanged_noclip[] = { + { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED }, + { WM_NCCALCSIZE, sent|wparam|parent, 1 }, + { WM_NCPAINT, sent|parent }, /* wparam != 1 */ + { WM_GETTEXT, sent|parent|defwinproc|optional }, + { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */ + { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { WM_PAINT, sent }, + { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */ + { WM_ERASEBKGND, sent|beginpaint }, { 0 } }; @@ -231,14 +288,49 @@ #endif { 0 } }; +/* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */ +static const struct message WmShowMaxOverlappedSeq[] = { + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 }, + { WM_GETMINMAXINFO, sent|defwinproc }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, + { HCBT_ACTIVATE, hook }, + { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, + { WM_IME_NOTIFY, sent|defwinproc|optional }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ERASEBKGND, sent|optional }, + /* Win9x adds SWP_NOZORDER below */ + { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, + { WM_MOVE, sent|defwinproc }, + { WM_SIZE, sent|defwinproc }, + { WM_NCCALCSIZE, sent|optional }, + { WM_NCPAINT, sent|optional }, + { WM_ERASEBKGND, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; /* ShowWindow(SW_HIDE) for a visible overlapped window */ static const struct message WmHideOverlappedSeq[] = { { WM_SHOWWINDOW, sent|wparam, 0 }, { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE }, { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, - { WM_SIZE, sent }, - { WM_MOVE, sent }, + { WM_SIZE, sent|optional }, /* XP doesn't send it */ + { WM_MOVE, sent|optional }, /* XP doesn't send it */ { WM_NCACTIVATE, sent|wparam, 0 }, { WM_ACTIVATE, sent|wparam, 0 }, { WM_ACTIVATEAPP, sent|wparam, 0 }, @@ -262,6 +354,137 @@ { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, { WM_DESTROY, sent }, { WM_NCDESTROY, sent }, + { 0 } +}; +/* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */ +static const struct message WmCreateMaxPopupSeq[] = { + { HCBT_CREATEWND, hook }, + { WM_NCCREATE, sent }, + { WM_NCCALCSIZE, sent|wparam, 0 }, + { WM_CREATE, sent }, + { WM_SIZE, sent }, + { WM_MOVE, sent }, + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ }, + { WM_MOVE, sent|defwinproc }, + { WM_SIZE, sent|defwinproc }, + { WM_SHOWWINDOW, sent|wparam, 1 }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE }, + { HCBT_ACTIVATE, hook }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SYNCPAINT, sent|wparam|optional, 4 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE }, + { 0 } +}; +/* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */ +static const struct message WmCreateInvisibleMaxPopupSeq[] = { + { HCBT_CREATEWND, hook }, + { WM_NCCREATE, sent }, + { WM_NCCALCSIZE, sent|wparam, 0 }, + { WM_CREATE, sent }, + { WM_SIZE, sent }, + { WM_MOVE, sent }, + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ }, + { WM_MOVE, sent|defwinproc }, + { WM_SIZE, sent|defwinproc }, + { 0 } +}; +/* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */ +static const struct message WmShowMaxPopupResizedSeq[] = { + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { HCBT_ACTIVATE, hook }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOZORDER }, + /* WinNT4.0 sends WM_MOVE */ + { WM_MOVE, sent|defwinproc|optional }, + { WM_SIZE, sent|defwinproc }, + { 0 } +}; +/* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */ +static const struct message WmShowMaxPopupSeq[] = { + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { HCBT_ACTIVATE, hook }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SYNCPAINT, sent|wparam|optional, 4 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER }, + { 0 } +}; +/* CreateWindow(WS_VISIBLE) for popup window */ +static const struct message WmCreatePopupSeq[] = { + { HCBT_CREATEWND, hook }, + { WM_NCCREATE, sent }, + { WM_NCCALCSIZE, sent|wparam, 0 }, + { WM_CREATE, sent }, + { WM_SIZE, sent }, + { WM_MOVE, sent }, + { WM_SHOWWINDOW, sent|wparam, 1 }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE }, + { HCBT_ACTIVATE, hook }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SYNCPAINT, sent|wparam|optional, 4 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE }, + { 0 } +}; +/* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */ +static const struct message WmShowVisMaxPopupSeq[] = { + { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE }, + { WM_GETMINMAXINFO, sent }, + { WM_GETTEXT, sent|optional }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 }, + { WM_NCCALCSIZE, sent|wparam, TRUE }, + { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, + { WM_NCPAINT, sent|wparam|optional, 1 }, + { WM_ERASEBKGND, sent|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOZORDER|0x8000 }, + { WM_MOVE, sent|defwinproc }, + { WM_SIZE, sent|defwinproc }, { 0 } }; /* CreateWindow (for a child popup window, not initially visible) */ @@ -367,6 +590,7 @@ { WM_ERASEBKGND, sent|parent|optional }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { 0 } }; /* ShowWindow(SW_SHOW) for a not visible child window */ @@ -460,6 +684,16 @@ { WM_NCDESTROY, sent }, { 0 } }; +/* DestroyWindow for a visible child window with invisible parent */ +static const struct message WmDestroyInvisibleChildSeq[] = { + { HCBT_DESTROYWND, hook }, + { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY }, + { WM_SHOWWINDOW, sent|wparam, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, + { WM_DESTROY, sent }, + { WM_NCDESTROY, sent }, + { 0 } +}; /* Moving the mouse in nonclient area */ static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */ { WM_NCHITTEST, sent }, @@ -584,11 +818,8 @@ { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, @@ -610,13 +841,11 @@ { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, + { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_ERASEBKGND, sent }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, { WM_CTLCOLORDLG, sent|defwinproc }, @@ -625,11 +854,8 @@ { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, @@ -639,16 +865,16 @@ { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, - { WM_GETICON, sent|optional|defwinproc }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, + { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_ERASEBKGND, sent|optional }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 }, { WM_CTLCOLORDLG, sent|optional|defwinproc }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, { WM_SIZE, sent }, { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, { WM_MOVE, sent }, @@ -660,15 +886,9 @@ { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, { WM_GETTEXT, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { HCBT_ACTIVATE, hook }, { WM_NCACTIVATE, sent|wparam, 0 }, { WM_GETTEXT, sent|optional|defwinproc }, - { WM_GETICON, sent|optional|defwinproc }, - { WM_GETICON, sent|optional|defwinproc }, - { WM_GETICON, sent|optional|defwinproc }, { WM_GETTEXT, sent|optional|defwinproc }, { WM_ACTIVATE, sent|wparam, 0 }, { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, @@ -748,33 +968,22 @@ { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, { WM_NCACTIVATE, sent|wparam, 1 }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { WM_ACTIVATE, sent|wparam, 1 }, { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE }, { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, { WM_NCPAINT, sent }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { WM_ERASEBKGND, sent }, { WM_CTLCOLORDLG, sent }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { WM_NCCALCSIZE, sent|optional }, { WM_NCPAINT, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { WM_ERASEBKGND, sent|optional }, { WM_CTLCOLORDLG, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { WM_PAINT, sent|optional }, { WM_CTLCOLORBTN, sent }, { WM_ENTERIDLE, sent|parent|optional }, @@ -797,24 +1006,15 @@ { WM_ENTERIDLE, sent|parent|optional }, { WM_ENTERIDLE, sent|parent|optional }, { WM_ENTERIDLE, sent|parent|optional }, - { WM_GETICON, sent|parent|optional }, - { WM_GETICON, sent|parent|optional }, - { WM_GETICON, sent|parent|optional }, { WM_TIMER, sent }, { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 }, { WM_ENABLE, sent|parent|wparam, 1 }, { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE }, { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { HCBT_ACTIVATE, hook }, { WM_NCACTIVATE, sent|wparam, 0 }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { WM_ACTIVATE, sent|wparam, 0 }, { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, @@ -867,10 +1067,9 @@ { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|defwinproc }, + { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */ { WM_GETTEXT, sent|optional }, { WM_NCCALCSIZE, sent|wparam|optional, 1 }, { 0 } @@ -888,24 +1087,25 @@ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER }, { WM_NCCALCSIZE, sent|wparam, 1 }, { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 }, - { WM_NCPAINT, sent|wparam, 1 }, + { WM_NCPAINT, sent }, /* wparam != 1 */ { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, { WM_ACTIVATE, sent|optional }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|defwinproc }, + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, + { WM_NCPAINT, sent|optional }, /* wparam != 1 */ + { WM_ERASEBKGND, sent|optional }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, - { WM_NCCALCSIZE, sent|wparam|optional, 1 }, - { WM_NCPAINT, sent|wparam|optional, 1 }, - { WM_ERASEBKGND, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */ { 0 } }; /* SetMenu for Visible windows with no size change */ static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = { { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER }, { WM_NCCALCSIZE, sent|wparam, 1 }, - { WM_NCPAINT, sent|wparam, 1 }, + { WM_NCPAINT, sent }, /* wparam != 1 */ { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, { WM_ACTIVATE, sent|optional }, @@ -918,7 +1118,7 @@ { { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER }, { WM_NCCALCSIZE, sent|wparam, 1 }, - { WM_NCPAINT, sent|wparam, 1 }, + { WM_NCPAINT, sent }, /* wparam != 1 */ { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, @@ -990,6 +1190,7 @@ { WM_ERASEBKGND, sent|optional }, { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 }, { 0 } }; /* SetScrollRange for a window with a non-client area */ @@ -1000,27 +1201,16 @@ { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 }, { WM_NCPAINT, sent|optional }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_GETICON, sent|optional|defwinproc }, - { WM_GETICON, sent|optional|defwinproc }, - { WM_GETICON, sent|optional|defwinproc }, { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */ { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|0x1000*/ }, { WM_SIZE, sent|defwinproc }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 }, { WM_GETTEXT, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|optional }, { 0 } }; @@ -1057,15 +1247,13 @@ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, { WM_NCPAINT, sent|wparam, 1 }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, - { WM_GETICON, sent|optional }, { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, - { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, { WM_NCCALCSIZE, sent|wparam|optional, 1 }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_ERASEBKGND, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { WM_SIZE, sent }, { WM_MOVE, sent }, { 0 } @@ -1096,6 +1284,21 @@ sequence[sequence_cnt].lParam = msg->lParam; sequence_cnt++; +} + +/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + diff = time - GetTickCount(); + } } static void flush_sequence(void) @@ -1240,8 +1443,6 @@ { WM_ACTIVATEAPP, sent|wparam, 1 }, { WM_NCACTIVATE, sent|wparam, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_GETICON, sent|defwinproc|optional }, - { WM_GETICON, sent|defwinproc|optional }, { WM_ACTIVATE, sent|wparam, 1 }, { HCBT_SETFOCUS, hook }, { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, @@ -1249,6 +1450,8 @@ { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, /* Win9x adds SWP_NOZORDER below */ { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { WM_SIZE, sent }, { WM_MOVE, sent }, { 0 } @@ -1659,7 +1862,9 @@ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */ + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */ { 0 } }; @@ -1826,10 +2031,14 @@ { WM_SIZE, sent|defwinproc }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */ + + { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */ /* in MDI frame */ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER }, @@ -1869,8 +2078,10 @@ { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE }, { WM_SIZE, sent }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */ + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */ { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */ + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */ { HCBT_SETFOCUS, hook }, { WM_KILLFOCUS, sent }, @@ -1997,6 +2208,7 @@ message != WM_NCHITTEST && message != WM_GETTEXT && message != WM_MDIGETACTIVE && + message != WM_GETICON && message != WM_DEVICECHANGE) { trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); @@ -2043,6 +2255,7 @@ message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && + message != WM_GETICON && message != WM_DEVICECHANGE) { trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); @@ -2107,6 +2320,7 @@ message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && + message != WM_GETICON && message != WM_DEVICECHANGE) { trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); @@ -2582,6 +2796,9 @@ trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; + switch (message) { case WM_WINDOWPOSCHANGING: @@ -2798,6 +3015,7 @@ static void test_showwindow(void) { HWND hwnd, hchild; + RECT rc; hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL); @@ -2825,14 +3043,14 @@ /* ShowWindow(SW_SHOWNA) with child and parent invisible */ trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n"); ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" ); - ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", TRUE); + ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE); trace("done\n"); /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */ ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" ); flush_sequence(); trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n"); ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" ); - ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", TRUE); + ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE); trace("done\n"); /* ShowWindow(SW_SHOWNA) with child visible and parent visible */ ShowWindow( hwnd, SW_SHOW); @@ -2855,6 +3073,89 @@ DestroyWindow(hchild); ok(!GetCapture(), "wrong capture window %p\n", GetCapture()); + DestroyWindow(hwnd); + flush_sequence(); + + /* Popup windows */ + /* Test 1: + * 1. Create invisible maximized popup window. + * 2. Move and resize it. + * 3. Show it maximized. + */ + trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n"); + hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (hwnd != 0, "Failed to create popup window\n"); + ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE); + trace("done\n"); + + GetWindowRect(hwnd, &rc); + ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) && + rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN), + "Invalid maximized size before ShowWindow (%ld,%ld)-(%ld,%ld)\n", + rc.left, rc.top, rc.right, rc.bottom); + /* Reset window's size & position */ + SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE); + flush_sequence(); + + trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n"); + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE); + trace("done\n"); + + GetWindowRect(hwnd, &rc); + ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) && + rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN), + "Invalid maximized size after ShowWindow (%ld,%ld)-(%ld,%ld)\n", + rc.left, rc.top, rc.right, rc.bottom); + DestroyWindow(hwnd); + flush_sequence(); + + /* Test 2: + * 1. Create invisible maximized popup window. + * 2. Show it maximized. + */ + trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n"); + hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (hwnd != 0, "Failed to create popup window\n"); + ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE); + trace("done\n"); + + trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n"); + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE); + trace("done\n"); + DestroyWindow(hwnd); + flush_sequence(); + + /* Test 3: + * 1. Create visible maximized popup window. + */ + trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n"); + hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (hwnd != 0, "Failed to create popup window\n"); + ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE); + trace("done\n"); + DestroyWindow(hwnd); + flush_sequence(); + + /* Test 4: + * 1. Create visible popup window. + * 2. Maximize it. + */ + trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n"); + hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (hwnd != 0, "Failed to create popup window\n"); + ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE); + trace("done\n"); + + trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n"); + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", TRUE); + trace("done\n"); DestroyWindow(hwnd); flush_sequence(); } @@ -2931,9 +3232,19 @@ ok(GetFocus() == hwnd, "window should have input focus\n"); ShowWindow(hwnd, SW_HIDE); ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE); - + ShowWindow(hwnd, SW_SHOW); ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE); + + ShowWindow(hwnd, SW_HIDE); + ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE); + + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE); + + ShowWindow(hwnd, SW_RESTORE); + /* FIXME: add ok_sequence() here */ + flush_sequence(); ShowWindow(hwnd, SW_SHOW); ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE); @@ -3136,12 +3447,12 @@ ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE); ShowWindow( hchild, SW_SHOW ); - ok_sequence(WmShowChildInvisibleParentSeq, "ShowWindow:show child with invisible parent", TRUE); + ok_sequence(WmShowChildInvisibleParentSeq, "ShowWindow:show child with invisible parent", FALSE); ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n"); ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n"); ShowWindow( hchild, SW_HIDE ); - ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", TRUE); + ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE); ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n"); ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n"); @@ -3155,7 +3466,11 @@ ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n"); ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n"); + SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); + flush_sequence(); DestroyWindow(hchild); + ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE); + DestroyWindow(hparent); flush_sequence(); @@ -3174,14 +3489,20 @@ ok (SetMenu(hwnd, 0), "SetMenu\n"); ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE); ShowWindow(hwnd, SW_SHOW); + UpdateWindow( hwnd ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); flush_sequence(); ok (SetMenu(hwnd, 0), "SetMenu\n"); - ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", TRUE); + ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE); ok (SetMenu(hwnd, hmenu), "SetMenu\n"); - ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", TRUE); - + ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE); + + UpdateWindow( hwnd ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); ok(DrawMenuBar(hwnd), "DrawMenuBar\n"); - ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", TRUE); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE); DestroyWindow(hwnd); flush_sequence(); @@ -3312,6 +3633,9 @@ struct message msg; trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; msg.message = message; msg.flags = sent|wparam|lparam; @@ -3620,6 +3944,7 @@ static void test_paint_messages(void) { + BOOL ret; RECT rect; POINT pt; MSG msg; @@ -3632,22 +3957,82 @@ ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); - - /* try to flush pending X expose events */ - MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ); - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_events(); check_update_rgn( hwnd, 0 ); SetRectRgn( hrgn, 10, 10, 20, 20 ); - RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE ); + ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE ); + ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret); check_update_rgn( hwnd, hrgn ); SetRectRgn( hrgn2, 20, 20, 30, 30 ); - RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE ); + ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE ); + ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret); CombineRgn( hrgn, hrgn, hrgn2, RGN_OR ); check_update_rgn( hwnd, hrgn ); /* validate everything */ + ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); + ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret); + check_update_rgn( hwnd, 0 ); + + /* test empty region */ + SetRectRgn( hrgn, 10, 10, 10, 15 ); + ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE ); + ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret); + check_update_rgn( hwnd, 0 ); + /* test empty rect */ + SetRect( &rect, 10, 10, 10, 15 ); + ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE ); + ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret); + check_update_rgn( hwnd, 0 ); + + /* flush pending messages */ + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + + GetClientRect( hwnd, &rect ); + SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top ); + /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws + * all windows and sends WM_ERASEBKGND and WM_NCPAINT. + */ + trace("testing InvalidateRect(0, NULL, FALSE)\n"); + SetRectEmpty( &rect ); + ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n"); + check_update_rgn( hwnd, hrgn ); + ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence( WmPaint, "Paint", FALSE ); RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); check_update_rgn( hwnd, 0 ); + + /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws + * all windows and sends WM_ERASEBKGND and WM_NCPAINT. + */ + trace("testing ValidateRect(0, NULL)\n"); + SetRectEmpty( &rect ); + ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n"); + check_update_rgn( hwnd, hrgn ); + ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence( WmPaint, "Paint", FALSE ); + RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE ); + check_update_rgn( hwnd, 0 ); + + trace("testing InvalidateRgn(0, NULL, FALSE)\n"); + SetLastError(0xdeadbeef); + ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n"); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError()); + check_update_rgn( hwnd, 0 ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); + + trace("testing ValidateRgn(0, NULL)\n"); + SetLastError(0xdeadbeef); + ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n"); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError()); + check_update_rgn( hwnd, 0 ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); + /* now with frame */ SetRectRgn( hrgn, -5, -5, 20, 20 ); @@ -3773,10 +4158,7 @@ ShowWindow( hparent, SW_SHOW ); UpdateWindow( hparent ); UpdateWindow( hchild ); - /* try to flush pending X expose events */ - MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ); - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); - + flush_events(); flush_sequence(); log_all_parent_messages++; @@ -3956,11 +4338,53 @@ while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE ); + assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN ); + UpdateWindow( hparent ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n"); + RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME ); + SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE ); + + UpdateWindow( hparent ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n"); + RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME ); + SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE ); + SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN ); ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE ); RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT ); while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); ok_sequence( WmParentPaint, "WmParentPaint", FALSE ); + + assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) ); + UpdateWindow( hparent ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n"); + RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME ); + SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE ); + + UpdateWindow( hparent ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n"); + RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME ); + SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE ); log_all_parent_messages--; DestroyWindow( hparent ); @@ -4124,6 +4548,8 @@ { HCBT_SYSCOMMAND, hook }, { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 }, { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, + { 0x00AE, sent|defwinproc|optional }, /* XP */ + { WM_GETTEXT, sent|defwinproc|optional }, /* XP */ { WM_INITMENU, sent|defwinproc }, { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 }, { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) }, @@ -4237,6 +4663,16 @@ { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 }, { 0 } }; +static const struct message WmF1Seq[] = { + { WM_KEYDOWN, wparam|lparam, VK_F1, 1 }, + { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 }, + { 0x4d, wparam|lparam, 0, 0 }, + { 0x4d, sent|wparam|lparam, 0, 0 }, + { WM_HELP, sent|defwinproc }, + { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 }, + { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 }, + { 0 } +}; static void pump_msg_loop(HWND hwnd, HACCEL hAccel) { @@ -4250,6 +4686,7 @@ /* ignore some unwanted messages */ if (msg.message == WM_MOUSEMOVE || + msg.message == WM_GETICON || msg.message == WM_DEVICECHANGE) continue; @@ -4278,6 +4715,7 @@ assert(hwnd != 0); UpdateWindow(hwnd); + flush_events(); SetFocus(hwnd); ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus()); @@ -4442,12 +4880,18 @@ pump_msg_loop(hwnd, 0); ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE); + keybd_event(VK_F1, 0, 0, 0); + keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0); + pump_msg_loop(hwnd, 0); + ok_sequence(WmF1Seq, "F1 press/release", TRUE); + DestroyWindow(hwnd); } /************* window procedures ********************/ -static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) { static long defwndproc_counter = 0; static long beginpaint_counter = 0; @@ -4455,6 +4899,9 @@ struct message msg; trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; switch (message) { @@ -4471,7 +4918,7 @@ { DWORD style = GetWindowLongA(hwnd, GWL_STYLE); if (style & WS_CHILD) - lParam = GetWindowLongA(hwnd, GWL_ID); + lParam = GetWindowLongPtrA(hwnd, GWLP_ID); else if (style & WS_POPUP) lParam = WND_POPUP_ID; else @@ -4500,7 +4947,7 @@ { DWORD style = GetWindowLongA(hwnd, GWL_STYLE); if (style & WS_CHILD) - lParam = GetWindowLongA(hwnd, GWL_ID); + lParam = GetWindowLongPtrA(hwnd, GWLP_ID); else if (style & WS_POPUP) lParam = WND_POPUP_ID; else @@ -4581,10 +5028,21 @@ } defwndproc_counter++; - ret = DefWindowProcA(hwnd, message, wParam, lParam); + ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam) + : DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; +} + +static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + return MsgCheckProc (FALSE, hwnd, message, wParam, lParam); +} + +static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + return MsgCheckProc (TRUE, hwnd, message, wParam, lParam); } static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -4594,6 +5052,9 @@ struct message msg; trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; msg.message = message; msg.flags = sent|wparam|lparam; @@ -4624,12 +5085,45 @@ trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; + if (log_all_parent_messages || message == WM_PARENTNOTIFY || message == WM_CANCELMODE || message == WM_SETFOCUS || message == WM_KILLFOCUS || message == WM_ENABLE || message == WM_ENTERIDLE || message == WM_IME_SETCONTEXT) { + switch (message) + { + case WM_ERASEBKGND: + { + RECT rc; + INT ret = GetClipBox((HDC)wParam, &rc); + + trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n", + ret, rc.left, rc.top, rc.right, rc.bottom); + break; + } + + case WM_WINDOWPOSCHANGING: + case WM_WINDOWPOSCHANGED: + { + WINDOWPOS *winpos = (WINDOWPOS *)lParam; + + trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED"); + trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n", + winpos->hwnd, winpos->hwndInsertAfter, + winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags); + + /* Log only documented flags, win2k uses 0x1000 and 0x2000 + * in the high word for internal purposes + */ + wParam = winpos->flags & 0xffff; + break; + } + } + msg.message = message; msg.flags = sent|parent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -4663,6 +5157,9 @@ struct message msg; trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; DefDlgProcA(hwnd, DM_SETDEFID, 1, 0); ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0); @@ -4791,7 +5288,7 @@ { DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE); if (style & WS_CHILD) - lParam = GetWindowLongA((HWND)wParam, GWL_ID); + lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID); else if (style & WS_POPUP) lParam = WND_POPUP_ID; else @@ -4813,6 +5310,7 @@ !lstrcmpiA(buf, "MDI_client_class") || !lstrcmpiA(buf, "MDI_child_class") || !lstrcmpiA(buf, "my_button_class") || + !lstrcmpiA(buf, "my_edit_class") || !lstrcmpiA(buf, "static") || !lstrcmpiA(buf, "#32770")) { @@ -4858,6 +5356,7 @@ !lstrcmpiA(buf, "MDI_client_class") || !lstrcmpiA(buf, "MDI_child_class") || !lstrcmpiA(buf, "my_button_class") || + !lstrcmpiA(buf, "my_edit_class") || !lstrcmpiA(buf, "static") || !lstrcmpiA(buf, "#32770")) { @@ -4890,6 +5389,32 @@ return DefWindowProcW(hwnd, uMsg, wParam, lParam); } +static const struct message WmGetTextLengthAfromW[] = { + { WM_GETTEXTLENGTH, sent }, + { WM_GETTEXT, sent }, + { 0 } +}; + +static const WCHAR testWindowClassW[] = +{ 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 }; + +static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0}; + +/* dummy window proc for WM_GETTEXTLENGTH test */ +static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) +{ + switch(msg) + { + case WM_GETTEXTLENGTH: + return lstrlenW(dummy_window_text) + 37; /* some random length */ + case WM_GETTEXT: + lstrcpynW( (LPWSTR)lp, dummy_window_text, wp ); + return lstrlenW( (LPWSTR)lp ); + default: + return DefWindowProcW( hwnd, msg, wp, lp ); + } +} + static void test_message_conversion(void) { static const WCHAR wszMsgConversionClass[] = @@ -4897,7 +5422,8 @@ WNDCLASSW cls; LRESULT lRes; HWND hwnd; - WNDPROC wndproc; + WNDPROC wndproc, newproc; + BOOL ret; cls.style = 0; cls.lpfnWndProc = MsgConversionProcW; @@ -4911,6 +5437,18 @@ cls.lpszClassName = wszMsgConversionClass; /* this call will fail on Win9x, but that doesn't matter as this test is * meaningless on those platforms */ + if(!RegisterClassW(&cls)) return; + + cls.style = 0; + cls.lpfnWndProc = MsgCheckProcW; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleW(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = testWindowClassW; if(!RegisterClassW(&cls)) return; hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED, @@ -4974,14 +5512,49 @@ lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0); ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER), "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError()); -} - -typedef struct _thread_info + + /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */ + + hwnd = CreateWindowW (testWindowClassW, wszUnicode, + WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + assert(hwnd); + flush_sequence(); + lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0); + ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE); + ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ), + "got bad length %ld\n", lRes ); + + flush_sequence(); + lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), + hwnd, WM_GETTEXTLENGTH, 0, 0); + ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE); + ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ), + "got bad length %ld\n", lRes ); + + wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc ); + newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ); + lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 ); + ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text), + NULL, 0, NULL, NULL ), + "got bad length %ld\n", lRes ); + + SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */ + lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 ); + ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text), + NULL, 0, NULL, NULL ), + "got bad length %ld\n", lRes ); + + ret = DestroyWindow(hwnd); + ok( ret, "DestroyWindow() error %ld\n", GetLastError()); +} + +struct timer_info { HWND hWnd; HANDLE handles[2]; DWORD id; -} thread_info; +}; static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime) { @@ -4991,7 +5564,7 @@ static DWORD WINAPI timer_thread_proc(LPVOID x) { - thread_info *info = x; + struct timer_info *info = x; DWORD r; r = KillTimer(info->hWnd, 0x19); @@ -5006,7 +5579,7 @@ static void test_timers(void) { - thread_info info; + struct timer_info info; DWORD id; info.hWnd = CreateWindow ("TestWindowClass", NULL, @@ -5100,6 +5673,13 @@ { 0 } }; +static const struct message WmMouseLLHookSeq[] = { + { WM_MOUSEMOVE, hook }, + { WM_LBUTTONDOWN, hook }, + { WM_LBUTTONUP, hook }, + { 0 } +}; + static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent, DWORD event, HWND hwnd, @@ -5149,6 +5729,21 @@ msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2; add_message(&msg); + return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam); + } + /* WH_MOUSE_LL hook */ + if (nCode == HC_ACTION) + { + struct message msg; + MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam; + + /* we can't test for real mouse events */ + if (mhll->flags & LLMHF_INJECTED) + { + msg.message = wParam; + msg.flags = hook; + add_message(&msg); + } return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam); } @@ -5235,6 +5830,33 @@ { TranslateMessage(&msg); DispatchMessage(&msg); + } + return 0; +} + +static DWORD WINAPI mouse_ll_global_thread_proc(void *param) +{ + HWND hwnd; + MSG msg; + HANDLE hevent = *(HANDLE *)param; + + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL); + assert(hwnd); + trace("created thread window %p\n", hwnd); + + *(HWND *)param = hwnd; + + flush_sequence(); + + mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0); + mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); + mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); + + SetEvent(hevent); + while (GetMessage(&msg, 0, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); } return 0; } @@ -5401,6 +6023,39 @@ ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n"); /****** end of out of context event test *************/ + /****** start of MOUSE_LL hook test *************/ + hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0); + assert(hCBT_global_hook); + + hevent = CreateEventA(NULL, 0, 0, NULL); + assert(hevent); + hwnd2 = (HWND)hevent; + + hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid); + ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError()); + + while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT) + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + + ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE); + flush_sequence(); + + mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); + mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); + mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); + + ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE); + + ret = UnhookWindowsHookEx(hCBT_global_hook); + ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError()); + + PostThreadMessageA(tid, WM_QUIT, 0, 0); + ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + CloseHandle(hthread); + CloseHandle(hevent); + ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n"); + /****** end of MOUSE_LL hook test *************/ + ok(DestroyWindow(hwnd), "failed to destroy window\n"); } @@ -5530,7 +6185,7 @@ 10, 10, 150, 150, hwnd, 0, 0, NULL); ok (hchild != 0, "Failed to create child\n"); UpdateWindow(hwnd); - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_events(); flush_sequence(); /* scroll without the child window */ @@ -5727,11 +6382,7 @@ static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - if (message == WM_PAINT) - { - trace( "Got WM_PAINT, ignoring\n" ); - return 0; - } + if (message == WM_PAINT) return 0; return MsgCheckProcA( hwnd, message, wParam, lParam ); } @@ -5746,7 +6397,7 @@ UpdateWindow( hwnd ); while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); flush_sequence(); - SetWindowLongPtrA( hwnd, GWL_WNDPROC, (LONG_PTR)DispatchMessageCheckProc ); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc ); SetRect( &rect, -5, -5, 5, 5 ); RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME ); @@ -5787,8 +6438,673 @@ if (++count > 10) break; } } -} - + DestroyWindow(hwnd); +} + + +static const struct message WmUser[] = { + { WM_USER, sent }, + { 0 } +}; + +struct sendmsg_info +{ + HWND hwnd; + DWORD timeout; + DWORD ret; +}; + +static DWORD CALLBACK send_msg_thread( LPVOID arg ) +{ + struct sendmsg_info *info = arg; + info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL ); + if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError()); + return 0; +} + +static void wait_for_thread( HANDLE thread ) +{ + while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0) + { + MSG msg; + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg); + } +} + +static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_USER) Sleep(200); + return MsgCheckProcA( hwnd, message, wParam, lParam ); +} + +static void test_SendMessageTimeout(void) +{ + MSG msg; + HANDLE thread; + struct sendmsg_info info; + DWORD tid; + + info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + flush_sequence(); + + info.timeout = 1000; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + wait_for_thread( thread ); + CloseHandle( thread ); + ok( info.ret == 1, "SendMessageTimeout failed\n" ); + ok_sequence( WmUser, "WmUser", FALSE ); + + info.timeout = 1; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + Sleep(100); /* SendMessageTimeout should timeout here */ + wait_for_thread( thread ); + CloseHandle( thread ); + ok( info.ret == 0, "SendMessageTimeout succeeded\n" ); + ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); + + /* 0 means infinite timeout */ + info.timeout = 0; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + Sleep(100); + wait_for_thread( thread ); + CloseHandle( thread ); + ok( info.ret == 1, "SendMessageTimeout failed\n" ); + ok_sequence( WmUser, "WmUser", FALSE ); + + /* timeout is treated as signed despite the prototype */ + info.timeout = 0x7fffffff; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + Sleep(100); + wait_for_thread( thread ); + CloseHandle( thread ); + ok( info.ret == 1, "SendMessageTimeout failed\n" ); + ok_sequence( WmUser, "WmUser", FALSE ); + + info.timeout = 0x80000000; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + Sleep(100); + wait_for_thread( thread ); + CloseHandle( thread ); + ok( info.ret == 0, "SendMessageTimeout succeeded\n" ); + ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE ); + + /* now check for timeout during message processing */ + SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc ); + info.timeout = 100; + info.ret = 0xdeadbeef; + thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid ); + wait_for_thread( thread ); + CloseHandle( thread ); + /* we should timeout but still get the message */ + ok( info.ret == 0, "SendMessageTimeout failed\n" ); + ok_sequence( WmUser, "WmUser", FALSE ); + + DestroyWindow( info.hwnd ); +} + + +/****************** edit message test *************************/ +#define ID_EDIT 0x1234 +static const struct message sl_edit_setfocus[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_SETFOCUS, sent|wparam, 0 }, + { WM_CTLCOLOREDIT, sent|parent }, + { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, + { 0 } +}; +static const struct message ml_edit_setfocus[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_SETFOCUS, sent|wparam, 0 }, + { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, + { 0 } +}; +static const struct message sl_edit_killfocus[] = +{ + { HCBT_SETFOCUS, hook }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_KILLFOCUS, sent|wparam, 0 }, + { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { 0 } +}; +static const struct message sl_edit_lbutton_dblclk[] = +{ + { WM_LBUTTONDBLCLK, sent }, + { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; +static const struct message sl_edit_lbutton_down[] = +{ + { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 }, + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_CTLCOLOREDIT, sent|parent }, + { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, + { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { 0 } +}; +static const struct message ml_edit_lbutton_down[] = +{ + { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 }, + { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, + { 0 } +}; +static const struct message sl_edit_lbutton_up[] = +{ + { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 }, + { WM_CAPTURECHANGED, sent|defwinproc }, + { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, + { 0 } +}; +static const struct message ml_edit_lbutton_up[] = +{ + { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 }, + { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 }, + { WM_CAPTURECHANGED, sent|defwinproc }, + { 0 } +}; + +static WNDPROC old_edit_proc; + +static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static long defwndproc_counter = 0; + LRESULT ret; + struct message msg; + + trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam); + + /* explicitly ignore WM_GETICON message */ + if (message == WM_GETICON) return 0; + + msg.message = message; + msg.flags = sent|wparam|lparam; + if (defwndproc_counter) msg.flags |= defwinproc; + msg.wParam = wParam; + msg.lParam = lParam; + add_message(&msg); + + defwndproc_counter++; + ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam); + defwndproc_counter--; + + return ret; +} + +static void subclass_edit(void) +{ + WNDCLASSA cls; + + if (!GetClassInfoA(0, "edit", &cls)) assert(0); + + old_edit_proc = cls.lpfnWndProc; + + cls.hInstance = GetModuleHandle(0); + cls.lpfnWndProc = edit_hook_proc; + cls.lpszClassName = "my_edit_class"; + if (!RegisterClassA(&cls)) assert(0); +} + +static void test_edit_messages(void) +{ + HWND hwnd, parent; + DWORD dlg_code; + + subclass_edit(); + log_all_parent_messages++; + + parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (parent != 0, "Failed to create parent window\n"); + + /* test single line edit */ + hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD, + 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL); + ok(hwnd != 0, "Failed to create edit window\n"); + + dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0); + ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08lx\n", dlg_code); + + ShowWindow(hwnd, SW_SHOW); + UpdateWindow(hwnd); + SetFocus(0); + flush_sequence(); + + SetFocus(hwnd); + ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE); + + SetFocus(0); + ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE); + + SetFocus(0); + ReleaseCapture(); + flush_sequence(); + + SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0); + ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE); + + SetFocus(0); + ReleaseCapture(); + flush_sequence(); + + SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0); + ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE); + + SendMessageA(hwnd, WM_LBUTTONUP, 0, 0); + ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE); + + DestroyWindow(hwnd); + + /* test multiline edit */ + hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE, + 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL); + ok(hwnd != 0, "Failed to create edit window\n"); + + dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0); + ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS), + "wrong dlg_code %08lx\n", dlg_code); + + ShowWindow(hwnd, SW_SHOW); + UpdateWindow(hwnd); + SetFocus(0); + flush_sequence(); + + SetFocus(hwnd); + ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE); + + SetFocus(0); + ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE); + + SetFocus(0); + ReleaseCapture(); + flush_sequence(); + + SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0); + ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE); + + SetFocus(0); + ReleaseCapture(); + flush_sequence(); + + SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0); + ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE); + + SendMessageA(hwnd, WM_LBUTTONUP, 0, 0); + ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE); + + DestroyWindow(hwnd); + DestroyWindow(parent); + + log_all_parent_messages--; +} + +/**************************** End of Edit test ******************************/ + +static const struct message WmChar[] = { + { WM_CHAR, sent|wparam, 'z' }, + { 0 } +}; + +static const struct message WmKeyDownUp[] = { + { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x00000001 }, + { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 }, + { 0 } +}; + +static const struct message WmUserChar[] = { + { WM_USER, sent }, + { WM_CHAR, sent|wparam, 'z' }, + { 0 } +}; + +#define EV_START_STOP 0 +#define EV_SENDMSG 1 +#define EV_ACK 2 + +struct peekmsg_info +{ + HWND hwnd; + HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */ +}; + +static DWORD CALLBACK send_msg_thread_2(void *param) +{ + DWORD ret; + struct peekmsg_info *info = param; + + trace("thread: waiting for start\n"); + WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE); + trace("thread: looping\n"); + + while (1) + { + ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE); + + switch (ret) + { + case WAIT_OBJECT_0 + EV_START_STOP: + trace("thread: exiting\n"); + return 0; + + case WAIT_OBJECT_0 + EV_SENDMSG: + trace("thread: sending message\n"); + SendNotifyMessageA(info->hwnd, WM_USER, 0, 0); + SetEvent(info->hevent[EV_ACK]); + break; + + default: + trace("unexpected return: %04lx\n", ret); + assert(0); + break; + } + } + return 0; +} + +static void test_PeekMessage(void) +{ + MSG msg; + HANDLE hthread; + DWORD tid, qstatus; + UINT qs_all_input = QS_ALLINPUT; + UINT qs_input = QS_INPUT; + struct peekmsg_info info; + + info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + ShowWindow(info.hwnd, SW_SHOW); + UpdateWindow(info.hwnd); + + info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL); + info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL); + info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL); + + hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid); + + trace("signalling to start looping\n"); + SetEvent(info.hevent[EV_START_STOP]); + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + flush_sequence(); + + SetLastError(0xdeadbeef); + qstatus = GetQueueStatus(qs_all_input); + if (GetLastError() == ERROR_INVALID_FLAGS) + { + trace("QS_RAWINPUT not supported on this platform\n"); + qs_all_input &= ~QS_RAWINPUT; + qs_input &= ~QS_RAWINPUT; + } + ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus); + + trace("signalling to send message\n"); + SetEvent(info.hevent[EV_SENDMSG]); + WaitForSingleObject(info.hevent[EV_ACK], INFINITE); + + /* pass invalid QS_xxxx flags */ + SetLastError(0xdeadbeef); + qstatus = GetQueueStatus(0xffffffff); + ok(qstatus == 0, "GetQueueStatus should fail: %08lx\n", qstatus); + ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %ld\n", GetLastError()); + + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE), + "wrong qstatus %08lx\n", qstatus); + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + ok_sequence(WmUser, "WmUser", FALSE); + + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus); + + keybd_event('N', 0, 0, 0); + keybd_event('N', 0, KEYEVENTF_KEYUP, 0); + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == MAKELONG(QS_KEY, QS_KEY), + "wrong qstatus %08lx\n", qstatus); + + PostMessageA(info.hwnd, WM_CHAR, 'z', 0); + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); + + InvalidateRect(info.hwnd, NULL, FALSE); + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); + + trace("signalling to send message\n"); + SetEvent(info.hevent[EV_SENDMSG]); + WaitForSingleObject(info.hevent[EV_ACK], INFINITE); + + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16))) DispatchMessageA(&msg); + ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + trace("signalling to send message\n"); + SetEvent(info.hevent[EV_SENDMSG]); + WaitForSingleObject(info.hevent[EV_ACK], INFINITE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg); + ok_sequence(WmUser, "WmUser", FALSE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg); + ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT)) DispatchMessageA(&msg); + ok_sequence(WmPaint, "WmPaint", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + trace("signalling to send message\n"); + SetEvent(info.hevent[EV_SENDMSG]); + WaitForSingleObject(info.hevent[EV_ACK], INFINITE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + PostMessageA(info.hwnd, WM_CHAR, 'z', 0); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE)) DispatchMessage(&msg); + ok_sequence(WmUserChar, "WmUserChar", FALSE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + PostMessageA(info.hwnd, WM_CHAR, 'z', 0); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + trace("signalling to send message\n"); + SetEvent(info.hevent[EV_SENDMSG]); + WaitForSingleObject(info.hevent[EV_ACK], INFINITE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16))) DispatchMessage(&msg); + ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16))) DispatchMessage(&msg); + ok_sequence(WmKeyDownUp, "WmKeyDownUp", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE)) DispatchMessage(&msg); + ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE); + + qstatus = GetQueueStatus(qs_all_input); +todo_wine { + ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), + "wrong qstatus %08lx\n", qstatus); +} + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */ + + qstatus = GetQueueStatus(qs_all_input); + ok(qstatus == 0, + "wrong qstatus %08lx\n", qstatus); + + trace("signalling to exit\n"); + SetEvent(info.hevent[EV_START_STOP]); + + WaitForSingleObject(hthread, INFINITE); + + CloseHandle(hthread); + CloseHandle(info.hevent[0]); + CloseHandle(info.hevent[1]); + CloseHandle(info.hevent[2]); + + DestroyWindow(info.hwnd); +} + + +static void test_quit_message(void) +{ + MSG msg; + BOOL ret; + + /* test using PostQuitMessage */ + PostQuitMessage(0xbeef); + + ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); + ok(ret, "PeekMessage failed with error %ld\n", GetLastError()); + ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message); + ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam); + + ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0); + ok(ret, "PostMessage failed with error %ld\n", GetLastError()); + + ret = GetMessage(&msg, NULL, 0, 0); + ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError()); + ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message); + + /* note: WM_QUIT message received after WM_USER message */ + ret = GetMessage(&msg, NULL, 0, 0); + ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError()); + ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message); + ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam); + + ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" ); + + /* now test with PostThreadMessage - different behaviour! */ + PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0); + + ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); + ok(ret, "PeekMessage failed with error %ld\n", GetLastError()); + ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message); + ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam); + + ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0); + ok(ret, "PostMessage failed with error %ld\n", GetLastError()); + + /* note: we receive the WM_QUIT message first this time */ + ret = GetMessage(&msg, NULL, 0, 0); + ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError()); + ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message); + ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam); + + ret = GetMessage(&msg, NULL, 0, 0); + ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError()); + ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message); +} START_TEST(msg) { @@ -5825,12 +7141,15 @@ test_winevents(); - /* Fix message sequences before removing 3 lines below */ + /* Fix message sequences before removing 4 lines below */ +#if 1 ret = pUnhookWinEvent(hEvent_hook); ok( ret, "UnhookWinEvent error %ld\n", GetLastError()); pUnhookWinEvent = 0; hEvent_hook = 0; - +#endif + + test_PeekMessage(); test_scrollwindowex(); test_messages(); test_mdi_messages(); @@ -5843,6 +7162,9 @@ test_set_hook(); test_DestroyWindow(); test_DispatchMessage(); + test_SendMessageTimeout(); + test_edit_messages(); + test_quit_message(); UnhookWindowsHookEx(hCBT_hook); if (pUnhookWinEvent) Propchange: trunk/reactos/regtests/winetests/user32/msg.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/resource.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/r…
============================================================================== --- trunk/reactos/regtests/winetests/user32/resource.c (original) +++ trunk/reactos/regtests/winetests/user32/resource.c Wed Apr 5 06:34:10 2006 @@ -23,6 +23,16 @@ #include "wine/test.h" +static UINT (WINAPI *pPrivateExtractIconsA)(LPCTSTR, int, int, int, HICON *, UINT *, UINT, UINT) = NULL; + +static void init_function_pointers(void) +{ + HMODULE hmod = GetModuleHandleA("user32.dll"); + if (hmod) { + pPrivateExtractIconsA = (void*)GetProcAddress(hmod, "PrivateExtractIconsA"); + } +} + static void test_LoadStringA (void) { HINSTANCE hInst = GetModuleHandle (NULL); @@ -247,9 +257,50 @@ ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); } +static void test_PrivateExtractIcons(void) { + CONST CHAR szShell32Dll[] = "shell32.dll"; + HICON ahIcon[256]; + UINT aIconId[256]; + UINT cIcons, cIcons2; + + if (!pPrivateExtractIconsA) return; + + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, NULL, NULL, 0, 0); + cIcons2 = pPrivateExtractIconsA(szShell32Dll, 4, MAKELONG(32,16), MAKELONG(32,16), + NULL, NULL, 256, 0); + ok((cIcons == cIcons2) && (cIcons > 0), + "Icon count should be independent of requested icon sizes and base icon index! " + "(cIcons=%d, cIcons2=%d)\n", cIcons, cIcons2); + + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, ahIcon, aIconId, 0, 0); + ok(cIcons == 0, "Zero icons requested, got cIcons=%d\n", cIcons); + + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, ahIcon, aIconId, 3, 0); + ok(cIcons == 3, "Three icons requested got cIcons=%d\n", cIcons); + + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(32,16), MAKELONG(32,16), + ahIcon, aIconId, 3, 0); + ok(cIcons == 4, "Three icons requested, four expected, got cIcons=%d\n", cIcons); +} + +static void test_LoadImage(void) { + HBITMAP bmp; + + bmp = LoadBitmapA(NULL, MAKEINTRESOURCE(OBM_CHECK)); + ok(bmp != NULL, "Could not load the OBM_CHECK bitmap\n"); + if (bmp) DeleteObject(bmp); + + bmp = LoadBitmapA(NULL, "#32760"); /* Value of OBM_CHECK */ + ok(bmp != NULL, "Could not load the OBM_CHECK bitmap\n"); + if (bmp) DeleteObject(bmp); +} + START_TEST(resource) { + init_function_pointers(); test_LoadStringA (); test_accel1(); test_accel2(); -} + test_PrivateExtractIcons(); + test_LoadImage(); +} Propchange: trunk/reactos/regtests/winetests/user32/resource.c ------------------------------------------------------------------------------ native = class.c Propchange: trunk/reactos/regtests/winetests/user32/resource.rc ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/sysparams.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/s…
============================================================================== --- trunk/reactos/regtests/winetests/user32/sysparams.c (original) +++ trunk/reactos/regtests/winetests/user32/sysparams.c Wed Apr 5 06:34:10 2006 @@ -22,6 +22,7 @@ #include <stdarg.h> #include <stdio.h> +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 /* For SPI_GETMOUSEHOVERWIDTH and more */ #include "wine/test.h" @@ -30,12 +31,16 @@ #include "wingdi.h" #include "winreg.h" #include "winuser.h" +#include "winnls.h" #ifndef SPI_GETDESKWALLPAPER # define SPI_GETDESKWALLPAPER 0x0073 #endif static int strict; +static int dpi; +static int iswin9x; +static HDC hdc; #define eq(received, expected, label, type) \ ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected)) @@ -48,9 +53,36 @@ #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2" #define SPI_SETMOUSE_VALNAME3 "MouseSpeed" #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics" +#define SPI_SETBORDER_REGKEY2 "Control Panel\\Desktop" #define SPI_SETBORDER_VALNAME "BorderWidth" +#define SPI_METRIC_REGKEY "Control Panel\\Desktop\\WindowMetrics" +#define SPI_SCROLLWIDTH_VALNAME "ScrollWidth" +#define SPI_SCROLLHEIGHT_VALNAME "ScrollHeight" +#define SPI_CAPTIONWIDTH_VALNAME "CaptionWidth" +#define SPI_CAPTIONHEIGHT_VALNAME "CaptionHeight" +#define SPI_CAPTIONFONT_VALNAME "CaptionFont" +#define SPI_SMCAPTIONWIDTH_VALNAME "SmCaptionWidth" +#define SPI_SMCAPTIONHEIGHT_VALNAME "SmCaptionHeight" +#define SPI_SMCAPTIONFONT_VALNAME "SmCaptionFont" +#define SPI_MENUWIDTH_VALNAME "MenuWidth" +#define SPI_MENUHEIGHT_VALNAME "MenuHeight" +#define SPI_MENUFONT_VALNAME "MenuFont" +#define SPI_STATUSFONT_VALNAME "StatusFont" +#define SPI_MESSAGEFONT_VALNAME "MessageFont" + #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard" #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed" +#define SPI_ICONHORIZONTALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics" +#define SPI_ICONHORIZONTALSPACING_REGKEY2 "Control Panel\\Desktop" +#define SPI_ICONHORIZONTALSPACING_VALNAME "IconSpacing" +#define SPI_ICONVERTICALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics" +#define SPI_ICONVERTICALSPACING_REGKEY2 "Control Panel\\Desktop" +#define SPI_ICONVERTICALSPACING_VALNAME "IconVerticalSpacing" +#define SPI_MINIMIZEDMETRICS_REGKEY "Control Panel\\Desktop\\WindowMetrics" +#define SPI_MINWIDTH_VALNAME "MinWidth" +#define SPI_MINHORZGAP_VALNAME "MinHorzGap" +#define SPI_MINVERTGAP_VALNAME "MinVertGap" +#define SPI_MINARRANGE_VALNAME "MinArrange" #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop" #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut" #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop" @@ -87,6 +119,8 @@ #define SPI_SETSCREENREADER_VALNAME "On" #define SPI_SETSCREENREADER_REGKEY_LEGACY "Control Panel\\Accessibility" #define SPI_SETSCREENREADER_VALNAME_LEGACY "Blind Access" +#define SPI_SETFONTSMOOTHING_REGKEY "Control Panel\\Desktop" +#define SPI_SETFONTSMOOTHING_VALNAME "FontSmoothing" #define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop" #define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive" #define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop" @@ -123,7 +157,13 @@ switch (msg) { case WM_SETTINGCHANGE: - if (change_counter>0) { + if (change_counter>0) { + /* ignore these messages caused by resizing of toolbars */ + if( wParam == SPI_SETWORKAREA) break; + if( change_last_param == SPI_SETWORKAREA) { + change_last_param = wParam; + break; + } ok(0,"too many changes counter=%d last change=%d\n", change_counter,change_last_param); } @@ -294,6 +334,98 @@ #define test_reg_key_ex2( subKey1, subKey2, valName1, valName2, testValue ) \ _test_reg_key( subKey1, subKey2, valName1, valName2, testValue ) +/* get a metric from the registry. If the value is negative + * it is assumed to be in twips and converted to pixels */ +static UINT metricfromreg( char *keyname, char *valname, int dpi) +{ + HKEY hkey; + char buf[64]; + DWORD ret; + DWORD size, type; + int value; + + RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey ); + size = sizeof(buf); + ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)buf, &size ); + RegCloseKey( hkey ); + if( ret != ERROR_SUCCESS) return -1; + value = atoi( buf); + if( value < 0) + value = ( -value * dpi + 720) / 1440; + return value; +} + +typedef struct +{ + INT16 lfHeight; + INT16 lfWidth; + INT16 lfEscapement; + INT16 lfOrientation; + INT16 lfWeight; + BYTE lfItalic; + BYTE lfUnderline; + BYTE lfStrikeOut; + BYTE lfCharSet; + BYTE lfOutPrecision; + BYTE lfClipPrecision; + BYTE lfQuality; + BYTE lfPitchAndFamily; + CHAR lfFaceName[LF_FACESIZE]; +} LOGFONT16, *LPLOGFONT16; + +/* get logfont from the registry */ +static int lffromreg( char *keyname, char *valname, LOGFONTA *plf) +{ + HKEY hkey; + LOGFONTW lfw; + DWORD ret, size, type; + + RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey ); + size = sizeof( lfw); + ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)&lfw, &size ); + RegCloseKey( hkey ); + ok( ret == ERROR_SUCCESS, "Key \"%s\" value \"%s\" not found\n", keyname, valname); + if( ret != ERROR_SUCCESS) + return FALSE; + if( size <= sizeof( LOGFONT16)) { + LOGFONT16 *plf16 = (LOGFONT16*) &lfw; + plf->lfHeight = plf16->lfHeight; + plf->lfWidth = plf16->lfWidth; + plf->lfEscapement = plf16->lfEscapement; + plf->lfOrientation = plf16->lfOrientation; + plf->lfWeight = plf16->lfWeight; + plf->lfItalic = plf16->lfItalic; + plf->lfUnderline = plf16->lfUnderline; + plf->lfStrikeOut = plf16->lfStrikeOut; + plf->lfCharSet = plf16->lfCharSet; + plf->lfOutPrecision = plf16->lfOutPrecision; + plf->lfClipPrecision = plf16->lfClipPrecision; + plf->lfQuality = plf16->lfQuality; + plf->lfPitchAndFamily = plf16->lfPitchAndFamily; + memcpy( plf->lfFaceName, plf16->lfFaceName, LF_FACESIZE ); + } else if( size <= sizeof( LOGFONTA)) { + plf = (LOGFONTA*) &lfw; + } else { + plf->lfHeight = lfw.lfHeight; + plf->lfWidth = lfw.lfWidth; + plf->lfEscapement = lfw.lfEscapement; + plf->lfOrientation = lfw.lfOrientation; + plf->lfWeight = lfw.lfWeight; + plf->lfItalic = lfw.lfItalic; + plf->lfUnderline = lfw.lfUnderline; + plf->lfStrikeOut = lfw.lfStrikeOut; + plf->lfCharSet = lfw.lfCharSet; + plf->lfOutPrecision = lfw.lfOutPrecision; + plf->lfClipPrecision = lfw.lfClipPrecision; + plf->lfQuality = lfw.lfQuality; + plf->lfPitchAndFamily = lfw.lfPitchAndFamily; + WideCharToMultiByte( CP_ACP, 0, lfw.lfFaceName, -1, plf->lfFaceName, + LF_FACESIZE, NULL, NULL); + + } + return TRUE; +} + static void test_SPI_SETBEEP( void ) /* 2 */ { BOOL rc; @@ -497,26 +629,44 @@ ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } -#if 0 -static void test_setborder(UINT curr_val) -{ - BOOL rc; - UINT border; +static void test_setborder(UINT curr_val, int usesetborder, int dpi) +{ + BOOL rc; + UINT border, regval; INT frame; - char buf[10]; - - rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - test_change_message( SPI_SETBORDER, 1 ); - sprintf( buf, "%d", curr_val ); - test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf ); - - if (curr_val == 0) - curr_val = 1; + NONCLIENTMETRICSA ncm; + + ncm.cbSize = sizeof( ncm); + rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + if( usesetborder) { + rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_SETBORDER, 1 ); + } else { /* set non client metrics */ + ncm.iBorderWidth = curr_val; + rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncm, SPIF_UPDATEINIFILE| + SPIF_SENDCHANGE); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); + } + if( curr_val) { /* skip if 0, some windows versions return 0 others 1 */ + regval = metricfromreg( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_VALNAME, dpi); + if( regval != curr_val) + regval = metricfromreg( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, dpi); + ok( regval==curr_val, "wrong value in registry %d, expected %d\n", regval, curr_val); + } + /* minimum border width is 1 */ + if (curr_val == 0) curr_val = 1; + /* should be the same as the non client metrics */ + rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( (UINT)ncm.iBorderWidth, curr_val, "NonClientMetric.iBorderWidth", "%d"); + /* and from SPI_GETBORDER */ rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 ); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d"); - + /* test some SystemMetrics */ frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME ); eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" ); @@ -528,6 +678,18 @@ { BOOL rc; UINT old_border; + NONCLIENTMETRICSA ncmsave; + INT CaptionWidth; + + ncmsave.cbSize = sizeof( ncmsave); + rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncmsave, 0); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + /* CaptionWidth from the registry may have different value of iCaptionWidth + * from the non client metrics (observed on WinXP). + * Fix this so we can safely restore settings with the nonclientmetrics */ + CaptionWidth = metricfromreg( + "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi); + ncmsave.iCaptionWidth = CaptionWidth; /* These tests hang when XFree86 4.0 for Windows is running (tested on * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is @@ -537,24 +699,33 @@ return; trace("testing SPI_{GET,SET}BORDER\n"); + SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}BORDER")) return; - - test_setborder(1); - test_setborder(0); - test_setborder(7); - test_setborder(20); - /* This will restore sane values if the test hang previous run. */ if ( old_border == 7 || old_border == 20 ) - old_border = -15; - - rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); - ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); -} -#endif + old_border = 1; + + /* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to + * do it twice to make the intended change). So skip parts of the tests on + * those platforms */ + if( !iswin9x) { + test_setborder(1, 1, dpi); + test_setborder(0, 1, dpi); + test_setborder(2, 1, dpi); + } + test_setborder(1, 0, dpi); + test_setborder(0, 0, dpi); + test_setborder(3, 0, dpi); + + rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncmsave, + SPIF_UPDATEINIFILE| SPIF_SENDCHANGE); + test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); + ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n", + rc,GetLastError()); +} static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */ { @@ -590,12 +761,43 @@ ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } +/* test_SPI_ICONHORIZONTALSPACING helper */ +static void dotest_spi_iconhorizontalspacing( INT curr_val) +{ + BOOL rc; + INT spacing, regval; + ICONMETRICSA im; + + rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0, + SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_ICONHORIZONTALSPACING, 0 ); + if( curr_val < 32) curr_val = 32; + /* The registry keys depend on the Windows version and the values too + * let's test (works on win95,ME,NT4,2k,XP) + */ + regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY2, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); + if( regval != curr_val) + regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); + ok( curr_val == regval, + "wrong value in registry %d, expected %d\n", regval, curr_val); + /* compare with what SPI_ICONHORIZONTALSPACING returns */ + rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d"); + /* and with a system metrics */ + eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" ); + /* and with what SPI_GETICONMETRICS returns */ + im.cbSize = sizeof(ICONMETRICSA); + rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( im.iHorzSpacing, curr_val, "SPI_GETICONMETRICS", "%d" ); +} + static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */ { BOOL rc; INT old_spacing; - INT spacing; - INT curr_val; trace("testing SPI_ICONHORIZONTALSPACING\n"); SetLastError(0xdeadbeef); @@ -603,34 +805,10 @@ rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 ); if (!test_error_msg(rc,"SPI_ICONHORIZONTALSPACING")) return; - /* do not increase the value as it would upset the user's icon layout */ - curr_val = (old_spacing > 32 ? old_spacing-1 : 32); - rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0, - SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - test_change_message( SPI_ICONHORIZONTALSPACING, 0 ); - /* The registry keys depend on the Windows version and the values too - * => don't test them - */ - - rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d"); - eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" ); - - curr_val = 10; - rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0, - SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - curr_val = 32; /*min value*/ - test_change_message( SPI_ICONHORIZONTALSPACING, 0 ); - - rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" ); - eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" ); - + dotest_spi_iconhorizontalspacing( old_spacing - 1); + dotest_spi_iconhorizontalspacing( 10); /* minimum is 32 */ + /* restore */ rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE ); ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } @@ -745,12 +923,44 @@ ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } + +/* test_SPI_ICONVERTICALSPACING helper */ +static void dotest_spi_iconverticalspacing( INT curr_val) +{ + BOOL rc; + INT spacing, regval; + ICONMETRICSA im; + + rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0, + SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_ICONVERTICALSPACING, 0 ); + if( curr_val < 32) curr_val = 32; + /* The registry keys depend on the Windows version and the values too + * let's test (works on win95,ME,NT4,2k,XP) + */ + regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY2, SPI_ICONVERTICALSPACING_VALNAME, dpi); + if( regval != curr_val) + regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); + ok( curr_val == regval, + "wrong value in registry %d, expected %d\n", regval, curr_val); + /* compare with what SPI_ICONVERTICALSPACING returns */ + rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" ); + /* and with a system metrics */ + eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" ); + /* and with what SPI_GETICONMETRICS returns */ + im.cbSize = sizeof(ICONMETRICSA); + rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( im.iVertSpacing, curr_val, "SPI_GETICONMETRICS", "%d" ); +} + static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */ { BOOL rc; INT old_spacing; - INT spacing; - INT curr_val; trace("testing SPI_ICONVERTICALSPACING\n"); SetLastError(0xdeadbeef); @@ -758,37 +968,15 @@ rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 ); if (!test_error_msg(rc,"SPI_ICONVERTICALSPACING")) return; - /* do not increase the value as it would upset the user's icon layout */ - curr_val = old_spacing-1; - rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0, - SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - test_change_message( SPI_ICONVERTICALSPACING, 0 ); - /* The registry keys depend on the Windows version and the values too - * => don't test them - */ - - rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" ); - eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" ); - - curr_val = 10; - rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0, - SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - curr_val = 32; /*min value*/ - test_change_message( SPI_ICONVERTICALSPACING, 0 ); - - rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" ); - eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" ); - + dotest_spi_iconverticalspacing( old_spacing - 1); + /* same tests with a value less than the minimum 32 */ + dotest_spi_iconverticalspacing( 10); + /* restore */ rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE ); - ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); + ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n", + rc,GetLastError()); } static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */ @@ -797,6 +985,7 @@ BOOL old_b; const UINT vals[]={TRUE,FALSE}; unsigned int i; + ICONMETRICSA im; /* These tests hang when XFree86 4.0 for Windows is running (tested on * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is @@ -814,19 +1003,28 @@ for (i=0;i<sizeof(vals)/sizeof(*vals);i++) { UINT v; + UINT regval; rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); test_change_message( SPI_SETICONTITLEWRAP, 1 ); - test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1, - SPI_SETICONTITLEWRAP_REGKEY2, - SPI_SETICONTITLEWRAP_VALNAME, - vals[i] ? "1" : "0" ); + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, + SPI_SETICONTITLEWRAP_VALNAME, dpi); + if( regval != vals[i]) + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, + SPI_SETICONTITLEWRAP_VALNAME, dpi); + ok( regval == vals[i], + "wrong value in registry %d, expected %d\n", regval, vals[i] ); rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 ); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" ); + /* and test with what SPI_GETICONMETRICS returns */ + im.cbSize = sizeof(ICONMETRICSA); + rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + eq( im.iTitleWrap, (BOOL)vals[i], "SPI_GETICONMETRICS", "%d" ); } rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE ); @@ -1011,7 +1209,7 @@ rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEBUTTONSWAP")) - return; + break; test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 ); test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY, @@ -1019,6 +1217,10 @@ vals[i] ? "1" : "0" ); eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i], "SM_SWAPBUTTON", "%d" ); + rc=SwapMouseButton((BOOL)vals[i^1]); + eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i^1], + "SwapMouseButton", "%d" ); + ok( rc==(BOOL)vals[i], "SwapMouseButton does not return previous state (really %d)\n", rc ); } rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0, @@ -1078,9 +1280,179 @@ ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } +#define test_reg_metric( KEY, VAL, val) \ +{ INT regval;\ + regval = metricfromreg( KEY, VAL, dpi);\ + ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\ +} + +#define test_reg_metric2( KEY1, KEY2, VAL, val) \ +{ INT regval;\ + regval = metricfromreg( KEY1, VAL, dpi);\ + if( regval != val) regval = metricfromreg( KEY2, VAL, dpi);\ + ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\ +} + +#define test_reg_font( KEY, VAL, LF) \ +{ LOGFONTA lfreg;\ + lffromreg( KEY, VAL, &lfreg);\ + ok( (lfreg.lfHeight < 0 ? (LF).lfHeight == lfreg.lfHeight :\ + MulDiv( -(LF).lfHeight , 72, dpi) == lfreg.lfHeight )&&\ + (LF).lfWidth == lfreg.lfWidth &&\ + (LF).lfWeight == lfreg.lfWeight &&\ + !strcmp( (LF).lfFaceName, lfreg.lfFaceName)\ + , "wrong value \"%s\" in registry %ld, %ld\n", VAL, (LF).lfHeight, lfreg.lfHeight);\ +} + +#define TEST_NONCLIENTMETRICS_REG( ncm) \ +test_reg_metric2( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, (ncm).iBorderWidth);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLWIDTH_VALNAME, (ncm).iScrollWidth);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLHEIGHT_VALNAME, (ncm).iScrollHeight);\ +/*FIXME: test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONWIDTH_VALNAME, (ncm).iCaptionWidth);*/\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONHEIGHT_VALNAME, (ncm).iCaptionHeight);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONWIDTH_VALNAME, (ncm).iSmCaptionWidth);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, (ncm).iSmCaptionHeight);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUWIDTH_VALNAME, (ncm).iMenuWidth);\ +test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, (ncm).iMenuHeight);\ +test_reg_font( SPI_METRIC_REGKEY, SPI_MENUFONT_VALNAME, (ncm).lfMenuFont);\ +test_reg_font( SPI_METRIC_REGKEY, SPI_CAPTIONFONT_VALNAME, (ncm).lfCaptionFont);\ +test_reg_font( SPI_METRIC_REGKEY, SPI_SMCAPTIONFONT_VALNAME, (ncm).lfSmCaptionFont);\ +test_reg_font( SPI_METRIC_REGKEY, SPI_STATUSFONT_VALNAME, (ncm).lfStatusFont);\ +test_reg_font( SPI_METRIC_REGKEY, SPI_MESSAGEFONT_VALNAME, (ncm).lfMessageFont); + +/* get text metric height value for the specified logfont */ +static int get_tmheight( LOGFONTA *plf, int flag) +{ + TEXTMETRICA tm; + HFONT hfont = CreateFontIndirectA( plf); + hfont = SelectObject( hdc, hfont); + GetTextMetricsA( hdc, &tm); + hfont = SelectObject( hdc, hfont); + return tm.tmHeight + (flag ? tm.tmExternalLeading : 0); +} + +void test_GetSystemMetrics( void); + +static void test_SPI_SETNONCLIENTMETRICS( void ) /* 44 */ +{ + BOOL rc; + INT expect; + NONCLIENTMETRICSA Ncmorig; + NONCLIENTMETRICSA Ncmnew; + NONCLIENTMETRICSA Ncmcur; + NONCLIENTMETRICSA Ncmstart; + + Ncmorig.cbSize = sizeof(NONCLIENTMETRICSA); + Ncmnew.cbSize = sizeof(NONCLIENTMETRICSA); + Ncmcur.cbSize = sizeof(NONCLIENTMETRICSA); + Ncmstart.cbSize = sizeof(NONCLIENTMETRICSA); + + trace("testing SPI_{GET,SET}NONCLIENTMETRICS\n"); + SetLastError(0xdeadbeef); + rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmorig, FALSE ); + if (!test_error_msg(rc,"SPI_{GET,SET}NONCLIENTMETRICS")) + return; + Ncmstart = Ncmorig; + /* SPI_GETNONCLIENTMETRICS returns some "cooked" values. For instance if + the caption font height is higher than the CaptionHeight field, + the latter is adjusted accordingly. To be able to restore these setting + accurately be restore the raw values. */ + Ncmorig.iCaptionWidth = metricfromreg( SPI_METRIC_REGKEY, SPI_CAPTIONWIDTH_VALNAME, dpi); + Ncmorig.iCaptionHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_CAPTIONHEIGHT_VALNAME, dpi); + Ncmorig.iSmCaptionHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, dpi); + Ncmorig.iMenuHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, dpi); + /* test registry entries */ + TEST_NONCLIENTMETRICS_REG( Ncmorig) + /* make small changes */ + Ncmnew = Ncmstart; + Ncmnew.iBorderWidth += 1; + Ncmnew.iScrollWidth += 1; + Ncmnew.iScrollHeight -= 1; + Ncmnew.iCaptionWidth -= 2; + Ncmnew.iCaptionHeight += 2; + Ncmnew.lfCaptionFont.lfHeight +=1; + Ncmnew.lfCaptionFont.lfWidth +=2; + Ncmnew.lfCaptionFont.lfWeight +=1; + Ncmnew.iSmCaptionWidth += 1; + Ncmnew.iSmCaptionHeight += 2; + Ncmnew.lfSmCaptionFont.lfHeight +=3; + Ncmnew.lfSmCaptionFont.lfWidth -=1; + Ncmnew.lfSmCaptionFont.lfWeight +=3; + Ncmnew.iMenuWidth += 1; + Ncmnew.iMenuHeight += 2; + Ncmnew.lfMenuFont.lfHeight +=1; + Ncmnew.lfMenuFont.lfWidth +=1; + Ncmnew.lfMenuFont.lfWeight +=2; + Ncmnew.lfStatusFont.lfHeight -=1; + Ncmnew.lfStatusFont.lfWidth -=1; + Ncmnew.lfStatusFont.lfWeight +=3; + Ncmnew.lfMessageFont.lfHeight -=2; + Ncmnew.lfMessageFont.lfWidth -=1; + Ncmnew.lfMessageFont.lfWeight +=4; + + rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &Ncmnew, SPIF_UPDATEINIFILE| + SPIF_SENDCHANGE); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); + /* get them back */ + rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmcur, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + /* test registry entries */ + TEST_NONCLIENTMETRICS_REG( Ncmcur) + /* test the systemm metrics with these settings */ + test_GetSystemMetrics(); + /* now for something invalid: increase the {menu|caption|smcaption} fonts + by a large amount will increase the {menu|caption|smcaption} height*/ + Ncmnew = Ncmstart; + Ncmnew.lfMenuFont.lfHeight -= 8; + Ncmnew.lfCaptionFont.lfHeight =-4; + Ncmnew.lfSmCaptionFont.lfHeight -=10; + /* also show that a few values are lo limited */ + Ncmnew.iCaptionWidth = 0; + Ncmnew.iCaptionHeight = 0; + Ncmnew.iScrollHeight = 0; + Ncmnew.iScrollWidth = 0; + + rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &Ncmnew, SPIF_UPDATEINIFILE| + SPIF_SENDCHANGE); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); + /* raw values are in registry */ + TEST_NONCLIENTMETRICS_REG( Ncmnew) + /* get them back */ + rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmcur, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + /* cooked values are returned */ + expect = max( Ncmnew.iMenuHeight, 2 + get_tmheight( &Ncmnew.lfMenuFont, 1)); + ok( Ncmcur.iMenuHeight == expect, + "MenuHeight: %d expected %d\n", Ncmcur.iMenuHeight, expect); + expect = max( Ncmnew.iCaptionHeight, 2 + get_tmheight(&Ncmnew.lfCaptionFont, 0)); + ok( Ncmcur.iCaptionHeight == expect, + "CaptionHeight: %d expected %d\n", Ncmcur.iCaptionHeight, expect); + expect = max( Ncmnew.iSmCaptionHeight, 2 + get_tmheight( &Ncmnew.lfSmCaptionFont, 0)); + ok( Ncmcur.iSmCaptionHeight == expect, + "SmCaptionHeight: %d expected %d\n", Ncmcur.iSmCaptionHeight, expect); + + ok( Ncmcur.iCaptionWidth == 8 || + Ncmcur.iCaptionWidth == Ncmstart.iCaptionWidth, /* with windows XP theme, the value never changes */ + "CaptionWidth: %d expected 8\n", Ncmcur.iCaptionWidth); + ok( Ncmcur.iScrollWidth == 8, + "ScrollWidth: %d expected 8\n", Ncmcur.iScrollWidth); + ok( Ncmcur.iScrollHeight == 8, + "ScrollHeight: %d expected 8\n", Ncmcur.iScrollHeight); + /* test the systemm metrics with these settings */ + test_GetSystemMetrics(); + /* restore */ + rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), + &Ncmorig, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); + test_change_message( SPI_SETNONCLIENTMETRICS, 0 ); + ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); +} + static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */ { BOOL rc; + INT regval; MINIMIZEDMETRICS lpMm_orig; MINIMIZEDMETRICS lpMm_new; MINIMIZEDMETRICS lpMm_cur; @@ -1094,23 +1466,49 @@ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_orig, FALSE ); if (!test_error_msg(rc,"SPI_{GET,SET}MINIMIZEDMETRICS")) return; - + /* test registry */ + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); + ok( regval == lpMm_orig.iWidth, "wrong value in registry %d, expected %d\n", + regval, lpMm_orig.iWidth); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); + ok( regval == lpMm_orig.iHorzGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_orig.iHorzGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); + ok( regval == lpMm_orig.iVertGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_orig.iVertGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); + ok( regval == lpMm_orig.iArrange, "wrong value in registry %d, expected %d\n", + regval, lpMm_orig.iArrange); + /* set some new values */ lpMm_cur.iWidth = 180; lpMm_cur.iHorzGap = 1; lpMm_cur.iVertGap = 1; lpMm_cur.iArrange = 5; - - rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_cur, FALSE ); - ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - + rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), + &lpMm_cur, SPIF_UPDATEINIFILE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + /* read them back */ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - + /* and compare */ eq( lpMm_new.iWidth, lpMm_cur.iWidth, "iWidth", "%d" ); eq( lpMm_new.iHorzGap, lpMm_cur.iHorzGap, "iHorzGap", "%d" ); eq( lpMm_new.iVertGap, lpMm_cur.iVertGap, "iVertGap", "%d" ); eq( lpMm_new.iArrange, lpMm_cur.iArrange, "iArrange", "%d" ); - + /* test registry */ + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); + ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iWidth); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); + ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iHorzGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); + ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iVertGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); + ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iArrange); + /* test some system metrics */ eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6, lpMm_new.iWidth, "iWidth", "%d" ); eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ), @@ -1119,13 +1517,53 @@ lpMm_new.iVertGap, "iVertGap", "%d" ); eq( GetSystemMetrics( SM_ARRANGE ), lpMm_new.iArrange, "iArrange", "%d" ); - - rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_orig, FALSE ); - ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); - + /* now some realy invalid settings */ + lpMm_cur.iWidth = -1; + lpMm_cur.iHorzGap = -1; + lpMm_cur.iVertGap = -1; + lpMm_cur.iArrange = - 1; + rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), + &lpMm_cur, SPIF_UPDATEINIFILE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); + /* read back */ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - + /* the width and H/V gaps have minimum 0, arrange is and'd with 0xf */ + eq( lpMm_new.iWidth, 0, "iWidth", "%d" ); + eq( lpMm_new.iHorzGap, 0, "iHorzGap", "%d" ); + eq( lpMm_new.iVertGap, 0, "iVertGap", "%d" ); + eq( lpMm_new.iArrange, 0xf & lpMm_cur.iArrange, "iArrange", "%d" ); + /* test registry */ +#if 0 /* FIXME: cannot understand the results of this (11, 11, 11, 0) */ + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); + ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iWidth); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); + ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iHorzGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); + ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iVertGap); + regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); + ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n", + regval, lpMm_new.iArrange); +#endif + /* test some system metrics */ + eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6, + lpMm_new.iWidth, "iWidth", "%d" ); + eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ), + lpMm_new.iHorzGap, "iHorzGap", "%d" ); + eq( GetSystemMetrics( SM_CYMINSPACING ) - GetSystemMetrics( SM_CYMINIMIZED ), + lpMm_new.iVertGap, "iVertGap", "%d" ); + eq( GetSystemMetrics( SM_ARRANGE ), + lpMm_new.iArrange, "iArrange", "%d" ); + /* restore */ + rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), + &lpMm_orig, SPIF_UPDATEINIFILE ); + ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); + /* check that */ + rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); + ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); eq( lpMm_new.iWidth, lpMm_orig.iWidth, "iWidth", "%d" ); eq( lpMm_new.iHorzGap, lpMm_orig.iHorzGap, "iHorzGap", "%d" ); eq( lpMm_new.iVertGap, lpMm_orig.iVertGap, "iVertGap", "%d" ); @@ -1134,10 +1572,12 @@ static void test_SPI_SETICONMETRICS( void ) /* 46 */ { - BOOL rc; + BOOL rc, wrap; + INT spacing; ICONMETRICSA im_orig; ICONMETRICSA im_new; ICONMETRICSA im_cur; + INT regval; im_orig.cbSize = sizeof(ICONMETRICSA); im_new.cbSize = sizeof(ICONMETRICSA); @@ -1148,33 +1588,50 @@ rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE ); if (!test_error_msg(rc,"SPI_{GET,SET}ICONMETRICS")) return; - - im_cur.iHorzSpacing = 65; - im_cur.iVertSpacing = 65; - im_cur.iTitleWrap = 0; - im_cur.lfFont.lfHeight = 1; - im_cur.lfFont.lfWidth = 1; + /* check some registry values */ + regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); + ok( regval==im_orig.iHorzSpacing, "wrong value in registry %d, expected %d\n", regval, im_orig.iHorzSpacing); + regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); + ok( regval==im_orig.iVertSpacing, "wrong value in registry %d, expected %d\n", regval, im_orig.iVertSpacing); + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi); + if( regval != im_orig.iTitleWrap) + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi); + ok( regval==im_orig.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_orig.iTitleWrap); + + /* change everything without creating something invalid ( Win9x would ignore + * an invalid font for instance) */ + im_cur = im_orig; + im_cur.iHorzSpacing += 10; + im_cur.iVertSpacing += 6; + im_cur.iTitleWrap = !im_cur.iTitleWrap; + im_cur.lfFont.lfHeight += 1; + im_cur.lfFont.lfWidth += 2; im_cur.lfFont.lfEscapement = 1; - im_cur.lfFont.lfWeight = 1; - im_cur.lfFont.lfItalic = 1; - im_cur.lfFont.lfStrikeOut = 1; - im_cur.lfFont.lfUnderline = 1; - im_cur.lfFont.lfCharSet = 1; - im_cur.lfFont.lfOutPrecision = 1; - im_cur.lfFont.lfClipPrecision = 1; - im_cur.lfFont.lfPitchAndFamily = 1; - im_cur.lfFont.lfQuality = 1; - - rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_cur, FALSE ); + im_cur.lfFont.lfWeight = im_cur.lfFont.lfWeight > 100 ? 1 : 314; + im_cur.lfFont.lfItalic = !im_cur.lfFont.lfItalic; + im_cur.lfFont.lfStrikeOut = !im_cur.lfFont.lfStrikeOut; + im_cur.lfFont.lfUnderline = !im_cur.lfFont.lfUnderline; + im_cur.lfFont.lfCharSet = im_cur.lfFont.lfCharSet ? 0 : 1; + im_cur.lfFont.lfOutPrecision = im_cur.lfFont.lfOutPrecision == OUT_DEFAULT_PRECIS ? + OUT_TT_PRECIS : OUT_DEFAULT_PRECIS; + im_cur.lfFont.lfClipPrecision ^= CLIP_LH_ANGLES; + im_cur.lfFont.lfPitchAndFamily = im_cur.lfFont.lfPitchAndFamily ? 0 : 1; + im_cur.lfFont.lfQuality = im_cur.lfFont.lfQuality == DEFAULT_QUALITY ? + DRAFT_QUALITY : DEFAULT_QUALITY; + if( strcmp( im_cur.lfFont.lfFaceName, "MS Serif")) + strcpy( im_cur.lfFont.lfFaceName, "MS Serif"); + else + strcpy( im_cur.lfFont.lfFaceName, "MS Sans Serif"); + + rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_cur, SPIF_UPDATEINIFILE ); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE ); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); - + /* test GET <-> SETICONMETRICS */ eq( im_new.iHorzSpacing, im_cur.iHorzSpacing, "iHorzSpacing", "%d" ); eq( im_new.iVertSpacing, im_cur.iVertSpacing, "iVertSpacing", "%d" ); eq( im_new.iTitleWrap, im_cur.iTitleWrap, "iTitleWrap", "%d" ); - eq( im_new.lfFont.lfHeight, im_cur.lfFont.lfHeight, "lfHeight", "%ld" ); eq( im_new.lfFont.lfWidth, im_cur.lfFont.lfWidth, "lfWidth", "%ld" ); eq( im_new.lfFont.lfEscapement, im_cur.lfFont.lfEscapement, "lfEscapement", "%ld" ); @@ -1187,13 +1644,38 @@ eq( im_new.lfFont.lfClipPrecision, im_cur.lfFont.lfClipPrecision, "lfClipPrecision", "%d" ); eq( im_new.lfFont.lfPitchAndFamily, im_cur.lfFont.lfPitchAndFamily, "lfPitchAndFamily", "%d" ); eq( im_new.lfFont.lfQuality, im_cur.lfFont.lfQuality, "lfQuality", "%d" ); - + ok( !strcmp( im_new.lfFont.lfFaceName, im_cur.lfFont.lfFaceName), + "wrong facename \"%s\", should be \"%s\"\n", im_new.lfFont.lfFaceName, + im_cur.lfFont.lfFaceName); + /* test some system metrics */ eq( GetSystemMetrics( SM_CXICONSPACING ), im_new.iHorzSpacing, "iHorzSpacing", "%d" ); eq( GetSystemMetrics( SM_CYICONSPACING ), im_new.iVertSpacing, "iVertSpacing", "%d" ); - - rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE ); + /* check some registry values */ + regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); + ok( regval==im_cur.iHorzSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iHorzSpacing); + regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); + ok( regval==im_cur.iVertSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iVertSpacing); + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi); + if( regval != im_cur.iTitleWrap) + regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi); + ok( regval==im_cur.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_cur.iTitleWrap); + /* test some values from other SPI_GETxxx calls */ + rc = SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 ); + ok( rc && spacing == im_cur.iHorzSpacing, + "SystemParametersInfoA( SPI_ICONHORIZONTALSPACING...) failed or returns wrong value %d instead of %d\n", + spacing, im_cur.iHorzSpacing); + rc = SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 ); + ok( rc && spacing == im_cur.iVertSpacing, + "SystemParametersInfoA( SPI_ICONVERTICALSPACING...) failed or returns wrong value %d instead of %d\n", + spacing, im_cur.iVertSpacing); + rc = SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &wrap, 0 ); + ok( rc && wrap == im_cur.iTitleWrap, + "SystemParametersInfoA( SPI_GETICONTITLEWRAP...) failed or returns wrong value %d instead of %d\n", + wrap, im_cur.iTitleWrap); + /* restore old values */ + rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig,SPIF_UPDATEINIFILE ); ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE ); @@ -1314,7 +1796,7 @@ rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &v, 0 ); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); - eq( v, vals[i], "SPI_GETKEYBOARDPREF", "%d" ); + eq( v, (BOOL)vals[i], "SPI_GETKEYBOARDPREF", "%d" ); } rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, old_b, 0, SPIF_UPDATEINIFILE ); @@ -1348,10 +1830,45 @@ rc=SystemParametersInfoA( SPI_GETSCREENREADER, 0, &v, 0 ); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); - eq( v, vals[i], "SPI_GETSCREENREADER", "%d" ); + eq( v, (BOOL)vals[i], "SPI_GETSCREENREADER", "%d" ); } rc=SystemParametersInfoA( SPI_SETSCREENREADER, old_b, 0, SPIF_UPDATEINIFILE ); + ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); +} + +static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */ +{ + BOOL rc; + BOOL old_b; + const UINT vals[]={0xffffffff,0,1,2}; + unsigned int i; + + trace("testing SPI_{GET,SET}FONTSMOOTHING\n"); + if( iswin9x) return; /* 95/98/ME don't seem to implement this fully */ + SetLastError(0xdeadbeef); + rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &old_b, 0 ); + if (!test_error_msg(rc,"SPI_{GET,SET}FONTSMOOTHING")) + return; + + for (i=0;i<sizeof(vals)/sizeof(*vals);i++) + { + UINT v; + + rc=SystemParametersInfoA( SPI_SETFONTSMOOTHING, vals[i], 0, + SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); + ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); + test_change_message( SPI_SETFONTSMOOTHING, 0 ); + test_reg_key( SPI_SETFONTSMOOTHING_REGKEY, + SPI_SETFONTSMOOTHING_VALNAME, + vals[i] ? "2" : "0" ); + + rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &v, 0 ); + ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); + eq( v, vals[i] ? 1 : 0, "SPI_GETFONTSMOOTHING", "%d" ); + } + + rc=SystemParametersInfoA( SPI_SETFONTSMOOTHING, old_b, 0, SPIF_UPDATEINIFILE ); ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); } @@ -1655,8 +2172,7 @@ { test_SPI_SETBEEP(); /* 1 */ test_SPI_SETMOUSE(); /* 4 */ - /* Messes up systems settings on Win9x */ - /*test_SPI_SETBORDER();*/ /* 6 */ + test_SPI_SETBORDER(); /* 6 */ test_SPI_SETKEYBOARDSPEED(); /* 10 */ test_SPI_ICONHORIZONTALSPACING(); /* 13 */ test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */ @@ -1672,12 +2188,14 @@ test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */ test_SPI_SETFASTTASKSWITCH(); /* 36 */ test_SPI_SETDRAGFULLWINDOWS(); /* 37 */ + test_SPI_SETNONCLIENTMETRICS(); /* 42 */ test_SPI_SETMINIMIZEDMETRICS(); /* 44 */ test_SPI_SETICONMETRICS(); /* 46 */ test_SPI_SETWORKAREA(); /* 47 */ test_SPI_SETSHOWSOUNDS(); /* 57 */ test_SPI_SETKEYBOARDPREF(); /* 69 */ test_SPI_SETSCREENREADER(); /* 71 */ + test_SPI_SETFONTSMOOTHING(); /* 75 */ test_SPI_SETLOWPOWERACTIVE(); /* 85 */ test_SPI_SETPOWEROFFACTIVE(); /* 86 */ test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */ @@ -1690,6 +2208,227 @@ return 0; } +/* test calculation of GetSystemMetrics values (mostly) from non client metrics, + * icon metrics and minimized metrics. + */ + +/* copied from wine's GdiGetCharDimensions, which is not available on most + * windows versions */ +static LONG _GdiGetCharDimensions(HDC hdc, LPTEXTMETRICA lptm, LONG *height) +{ + SIZE sz; + static const CHAR alphabet[] = { + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', + 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H', + 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0}; + + if(lptm && !GetTextMetricsA(hdc, lptm)) return 0; + + if(!GetTextExtentPointA(hdc, alphabet, 52, &sz)) return 0; + + if (height) *height = sz.cy; + return (sz.cx / 26 + 1) / 2; +} + +/* get text metrics and/or "average" char width of the specified logfont + * for the specified dc */ +void get_text_metr_size( HDC hdc, LOGFONTA *plf, TEXTMETRICA * ptm, UINT *psz) +{ + HFONT hfont, hfontsav; + TEXTMETRICA tm; + if( !ptm) ptm = &tm; + hfont = CreateFontIndirectA( plf); + if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) { + ptm->tmHeight = -1; + if( psz) *psz = 10; + if( hfont) DeleteObject( hfont); + return; + } + GetTextMetricsA( hdc, ptm); + if( psz) + if( !(*psz = _GdiGetCharDimensions( hdc, ptm, NULL))) + *psz = 10; + SelectObject( hdc, hfontsav); + DeleteObject( hfont); +} + +static int gsm_error_ctr; +static UINT smcxsmsize = 999999999; + +#define ok_gsm( i, e)\ +{\ + int exp = (e);\ + int act = GetSystemMetrics( (i));\ + if( exp != act) gsm_error_ctr++;\ + ok( !( exp != act),"GetSystemMetrics(%s): expected %d actual %d\n", #i, exp,act);\ +} +#define ok_gsm_2( i, e1, e2)\ +{\ + int exp1 = (e1);\ + int exp2 = (e2);\ + int act = GetSystemMetrics( (i));\ + if( exp1 != act && exp2 != act) gsm_error_ctr++;\ + ok( !( exp1 != act && exp2 != act), "GetSystemMetrics(%s): expected %d or %d actual %d\n", #i, exp1, exp2, act);\ +} +#define ok_gsm_3( i, e1, e2, e3)\ +{\ + int exp1 = (e1);\ + int exp2 = (e2);\ + int exp3 = (e3);\ + int act = GetSystemMetrics( (i));\ + if( exp1 != act && exp2 != act && exp3 != act) gsm_error_ctr++;\ + ok( !( exp1 != act && exp2 != act && exp3 != act),"GetSystemMetrics(%s): expected %d or %d or %d actual %d\n", #i, exp1, exp2, exp3, act);\ +} + +void test_GetSystemMetrics( void) +{ + TEXTMETRICA tmMenuFont; + UINT IconSpacing, IconVerticalSpacing; + + HDC hdc = CreateIC( "Display", 0, 0, 0); + UINT avcwCaption; + INT CaptionWidth; + MINIMIZEDMETRICS minim; + NONCLIENTMETRICS ncm; + minim.cbSize = sizeof( minim); + ncm.cbSize = sizeof( ncm); + SystemParametersInfo( SPI_GETMINIMIZEDMETRICS, 0, &minim, 0); + SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); + + /* CaptionWidth from the registry may have different value of iCaptionWidth + * from the non client metrics (observed on WinXP) */ + CaptionWidth = metricfromreg( + "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi); + get_text_metr_size( hdc, &ncm.lfMenuFont, &tmMenuFont, NULL); + get_text_metr_size( hdc, &ncm.lfCaptionFont, NULL, &avcwCaption); + /* FIXME: use icon metric */ + if( !SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &IconVerticalSpacing, 0)) + IconVerticalSpacing = 0; + if( !SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &IconSpacing, 0 )) + IconSpacing = 0; + /* reset error counters */ + gsm_error_ctr = 0; + + /* the tests: */ + + /* SM_CXSCREEN, cannot test these two */ + /* SM_CYSCREEN */ + ok_gsm( SM_CXVSCROLL, ncm.iScrollWidth); + ok_gsm( SM_CYHSCROLL, ncm.iScrollWidth); + ok_gsm( SM_CYCAPTION, ncm.iCaptionHeight+1); + ok_gsm( SM_CXBORDER, 1); + ok_gsm( SM_CYBORDER, 1); + ok_gsm( SM_CXDLGFRAME, 3); + ok_gsm( SM_CYDLGFRAME, 3); + ok_gsm( SM_CYVTHUMB, ncm.iScrollHeight); + ok_gsm( SM_CXHTHUMB, ncm.iScrollHeight); + /* SM_CXICON */ + /* SM_CYICON */ + /* SM_CXCURSOR */ + /* SM_CYCURSOR */ + ok_gsm( SM_CYMENU, ncm.iMenuHeight + 1); + ok_gsm( SM_CXFULLSCREEN, + GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME)); + ok_gsm( SM_CYFULLSCREEN, + GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN)); + /* SM_CYKANJIWINDOW */ + /* SM_MOUSEPRESENT */ + ok_gsm( SM_CYVSCROLL, ncm.iScrollHeight); + ok_gsm( SM_CXHSCROLL, ncm.iScrollHeight); + /* SM_DEBUG */ + /* SM_SWAPBUTTON */ + /* SM_RESERVED1 */ + /* SM_RESERVED2 */ + /* SM_RESERVED3 */ + /* SM_RESERVED4 */ + ok_gsm( SM_CXMIN, 3 * max( CaptionWidth, 8) + GetSystemMetrics( SM_CYSIZE) + + 4 + 4 * avcwCaption + 2 * GetSystemMetrics( SM_CXFRAME)); + ok_gsm( SM_CYMIN, GetSystemMetrics( SM_CYCAPTION) + + 2 * GetSystemMetrics( SM_CYFRAME)); + ok_gsm_2( SM_CXSIZE, + ncm.iCaptionWidth, /* classic/standard windows style */ + GetSystemMetrics( SM_CYCAPTION) - 1 /* WinXP style */ + ); + ok_gsm( SM_CYSIZE, ncm.iCaptionHeight); + ok_gsm( SM_CXFRAME, ncm.iBorderWidth + 3); + ok_gsm( SM_CYFRAME, ncm.iBorderWidth + 3); + ok_gsm( SM_CXMINTRACK, GetSystemMetrics( SM_CXMIN)); + ok_gsm( SM_CYMINTRACK, GetSystemMetrics( SM_CYMIN)); + /* SM_CXDOUBLECLK */ + /* SM_CYDOUBLECLK */ + if( IconSpacing) ok_gsm( SM_CXICONSPACING, IconSpacing); + if( IconVerticalSpacing) ok_gsm( SM_CYICONSPACING, IconVerticalSpacing); + /* SM_MENUDROPALIGNMENT */ + /* SM_PENWINDOWS */ + /* SM_DBCSENABLED */ + /* SM_CMOUSEBUTTONS */ + /* SM_SECURE */ + ok_gsm( SM_CXEDGE, 2); + ok_gsm( SM_CYEDGE, 2); + ok_gsm( SM_CXMINSPACING, GetSystemMetrics( SM_CXMINIMIZED) + minim.iHorzGap ); + ok_gsm( SM_CYMINSPACING, GetSystemMetrics( SM_CYMINIMIZED) + minim.iVertGap ); + /* SM_CXSMICON */ + /* SM_CYSMICON */ + ok_gsm( SM_CYSMCAPTION, ncm.iSmCaptionHeight + 1); + ok_gsm_3( SM_CXSMSIZE, + ncm.iSmCaptionWidth, /* classic/standard windows style */ + GetSystemMetrics( SM_CYSMCAPTION) - 1, /* WinXP style */ + smcxsmsize /* winXP seems to cache this value: setnonclientmetric + does not change it */ + ); + ok_gsm( SM_CYSMSIZE, GetSystemMetrics( SM_CYSMCAPTION) - 1); + ok_gsm( SM_CXMENUSIZE, ncm.iMenuWidth); + ok_gsm( SM_CYMENUSIZE, ncm.iMenuHeight); + /* SM_ARRANGE */ + ok_gsm( SM_CXMINIMIZED, minim.iWidth + 6); + ok_gsm( SM_CYMINIMIZED, GetSystemMetrics( SM_CYCAPTION) + 5); + ok_gsm( SM_CXMAXTRACK, GetSystemMetrics( SM_CXSCREEN) + + 4 + 2 * GetSystemMetrics( SM_CXFRAME)); + ok_gsm( SM_CYMAXTRACK, GetSystemMetrics( SM_CYSCREEN) + + 4 + 2 * GetSystemMetrics( SM_CYFRAME)); + /* the next two cannot really be tested as they depend on (application) + * toolbars */ + /* SM_CXMAXIMIZED */ + /* SM_CYMAXIMIZED */ + /* SM_NETWORK */ + /* */ + /* */ + /* */ + /* SM_CLEANBOOT */ + /* SM_CXDRAG */ + /* SM_CYDRAG */ + /* SM_SHOWSOUNDS */ + ok_gsm( SM_CXMENUCHECK, + ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1); + ok_gsm( SM_CYMENUCHECK, + ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1); + /* SM_SLOWMACHINE */ + /* SM_MIDEASTENABLED */ + /* SM_MOUSEWHEELPRESENT */ + /* SM_XVIRTUALSCREEN */ + /* SM_YVIRTUALSCREEN */ + /* SM_CXVIRTUALSCREEN */ + /* SM_CYVIRTUALSCREEN */ + /* SM_CMONITORS */ + /* SM_SAMEDISPLAYFORMAT */ + /* SM_IMMENABLED */ + /* SM_CXFOCUSBORDER */ + /* SM_CYFOCUSBORDER */ + /* SM_TABLETPC */ + /* SM_MEDIACENTER */ + /* SM_CMETRICS */ + /* end of tests */ + if( gsm_error_ctr ) { /* if any errors where found */ + trace( "BorderWidth %d CaptionWidth %d CaptionHeight %d IconSpacing %d IconVerticalSpacing %d\n", + ncm.iBorderWidth, ncm.iCaptionWidth, ncm.iCaptionHeight, IconSpacing, IconVerticalSpacing); + trace( "MenuHeight %d MenuWidth %d ScrollHeight %d ScrollWidth %d SmCaptionHeight %d SmCaptionWidth %d\n", + ncm.iMenuHeight, ncm.iMenuWidth, ncm.iScrollHeight, ncm.iScrollWidth, ncm.iSmCaptionHeight, ncm.iSmCaptionWidth); + trace( "Captionfontchar width %d MenuFont %ld,%ld CaptionWidth from registry: %d\n", + avcwCaption, tmMenuFont.tmHeight, tmMenuFont.tmExternalLeading, CaptionWidth); + } + ReleaseDC( 0, hdc); +} + START_TEST(sysparams) { int argc; @@ -1700,6 +2439,10 @@ DWORD dwThreadId; HANDLE hInstance = GetModuleHandleA( NULL ); + hdc = GetDC(0); + dpi = GetDeviceCaps( hdc, LOGPIXELSY); + iswin9x = GetVersion() & 0x80000000; + /* This test requires interactivity, if we don't have it, give up */ if (!SystemParametersInfoA( SPI_SETBEEP, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ) && GetLastError()==ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION) return; @@ -1707,6 +2450,9 @@ argc = winetest_get_mainargs(&argv); strict=(argc >= 3 && strcmp(argv[2],"strict")==0); trace("strict=%d\n",strict); + + trace("testing GetSystemMetrics with your current desktop settings\n"); + test_GetSystemMetrics( ); change_counter = 0; change_last_param = 0; @@ -1734,4 +2480,6 @@ TranslateMessage( &msg ); DispatchMessageA( &msg ); } -} + ReleaseDC( 0, hdc); + +} Propchange: trunk/reactos/regtests/winetests/user32/sysparams.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/testlist.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/t…
============================================================================== --- trunk/reactos/regtests/winetests/user32/testlist.c (original) +++ trunk/reactos/regtests/winetests/user32/testlist.c Wed Apr 5 06:34:10 2006 @@ -22,6 +22,7 @@ extern void func_input(void); extern void func_listbox(void); extern void func_menu(void); +extern void func_monitor(void); extern void func_msg(void); extern void func_resource(void); extern void func_sysparams(void); @@ -41,6 +42,7 @@ { "input", func_input }, { "listbox", func_listbox }, { "menu", func_menu }, + { "monitor", func_monitor }, { "msg", func_msg }, { "resource", func_resource }, { "sysparams", func_sysparams }, Propchange: trunk/reactos/regtests/winetests/user32/testlist.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/text.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/t…
============================================================================== --- trunk/reactos/regtests/winetests/user32/text.c (original) +++ trunk/reactos/regtests/winetests/user32/text.c Wed Apr 5 06:34:10 2006 @@ -36,6 +36,9 @@ LOGFONTA lf; const char text[] = "Example text for testing DrawText in " "MM_HIENGLISH mode"; + const WCHAR textW[] = {'W','i','d','e',' ','c','h','a','r',' ', + 's','t','r','i','n','g','\0'}; + const WCHAR emptystringW[] = { 0 }; INT textlen,textheight; RECT rect = { 0, 0, 100, 0 }; BOOL ret; @@ -100,6 +103,49 @@ "should return a positive rectangle bottom. (bot=%ld)\n", rect.bottom); + /* empty or null text should in some cases calc an empty rectangle */ + /* note: testing the function's return value is useless, it differs + * ( 0 or 1) on every Windows version I tried */ + SetRect( &rect, 10,10, 100, 100); + textheight = DrawTextExA(hdc, (char *) text, 0, &rect, DT_CALCRECT, NULL ); + ok( !(rect.left == rect.right && rect.bottom == rect.top), + "rectangle should NOT be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + SetLastError( 0); + textheight = DrawTextExA(hdc, "", -1, &rect, DT_CALCRECT, NULL ); + ok( (rect.left == rect.right && rect.bottom == rect.top), + "rectangle should be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + SetLastError( 0); + textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT, NULL ); + ok( (rect.left == rect.right && rect.bottom == rect.top), + "rectangle should be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT, NULL ); + ok( !(rect.left == rect.right && rect.bottom == rect.top), + "rectangle should NOT be empty.\n"); + + /* Wide char versions */ + SetRect( &rect, 10,10, 100, 100); + SetLastError( 0); + textheight = DrawTextExW(hdc, (WCHAR *) textW, 0, &rect, DT_CALCRECT, NULL ); + if( GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) { + ok( !(rect.left == rect.right && rect.bottom == rect.top), + "rectangle should NOT be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + textheight = DrawTextExW(hdc, (WCHAR *) emptystringW, -1, &rect, DT_CALCRECT, NULL ); + ok( (rect.left == rect.right && rect.bottom == rect.top), + "rectangle should be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT, NULL ); + ok( !(rect.left == rect.right && rect.bottom == rect.top), + "rectangle should NOT be empty.\n"); + SetRect( &rect, 10,10, 100, 100); + textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT, NULL ); + ok( !(rect.left == rect.right && rect.bottom == rect.top), + "rectangle should NOT be empty.\n"); + } + SelectObject(hdc, hOldFont); ret = DeleteObject(hFont); ok( ret, "DeleteObject error %lu\n", GetLastError()); @@ -111,7 +157,97 @@ ok( ret, "DestroyWindow error %lu\n", GetLastError()); } +/* replace tabs by \t */ +static void strfmt( char *str, char *strout) +{ + unsigned int i,j ; + for(i=0,j=0;i<=strlen(str);i++,j++) + if((strout[j]=str[i])=='\t') { + strout[j++]='\\'; + strout[j]='t'; + } +} + + +#define TABTEST( tabval, tabcount, string, _exp) \ +{ int i,x_act, x_exp; char strdisp[64];\ + for(i=0;i<8;i++) tabs[i]=(i+1)*(tabval); \ + extent = GetTabbedTextExtentA( hdc, string, strlen( string), (tabcount), tabs); \ + strfmt( string, strdisp); \ + /* trace( "Extent is %08lx\n", extent); */\ + x_act = LOWORD( extent); \ + x_exp = (_exp); \ + ok( x_act == x_exp, "Test case \"%s\". Text extent is %d, expected %d tab %d tabcount %d\n", \ + strdisp, x_act, x_exp, tabval, tabcount); \ +} \ + + +static void test_TabbedText(void) +{ + HWND hwnd; + HDC hdc; + BOOL ret; + TEXTMETRICA tm; + DWORD extent; + INT tabs[8], cx, cy, tab, tabcount,t,align; + + /* Initialization */ + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, + 0, 0, 200, 200, 0, 0, 0, NULL); + ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError()); + hdc = GetDC(hwnd); + ok(hdc != 0, "GetDC error %lu\n", GetLastError()); + + ret = GetTextMetricsA( hdc, &tm); + ok( ret, "GetTextMetrics error %lu\n", GetLastError()); + + extent = GetTabbedTextExtentA( hdc, "x", 1, 1, tabs); + cx = LOWORD( extent); + cy = HIWORD( extent); + trace( "cx is %d cy is %d\n", cx, cy); + + align=1; + for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to + catch the one off errors */ + tab = (cx *4 + t); + /* test the special case tabcount =1 and the general array (80 of tabs */ + for( tabcount = 1; tabcount <= 8; tabcount +=7) { + TABTEST( align * tab, tabcount, "\t", tab) + TABTEST( align * tab, tabcount, "xxx\t", tab) + TABTEST( align * tab, tabcount, "\tx", tab+cx) + TABTEST( align * tab, tabcount, "\t\t", tab*2) + TABTEST( align * tab, tabcount, "\tx\t", tab*2) + TABTEST( align * tab, tabcount, "x\tx", tab+cx) + TABTEST( align * tab, tabcount, "xx\tx", tab+cx) + TABTEST( align * tab, tabcount, "xxx\tx", tab+cx) + TABTEST( align * tab, tabcount, "xxxx\tx", t>0 ? tab + cx : 2*tab+cx) + TABTEST( align * tab, tabcount, "xxxxx\tx", 2*tab+cx) + } + } + align=-1; + for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to + catch the one off errors */ + tab = (cx *4 + t); + /* test the special case tabcount =1 and the general array (8) of tabs */ + for( tabcount = 1; tabcount <= 8; tabcount +=7) { + TABTEST( align * tab, tabcount, "\t", tab) + TABTEST( align * tab, tabcount, "xxx\t", tab) + TABTEST( align * tab, tabcount, "\tx", tab) + TABTEST( align * tab, tabcount, "\t\t", tab*2) + TABTEST( align * tab, tabcount, "\tx\t", tab*2) + TABTEST( align * tab, tabcount, "x\tx", tab) + TABTEST( align * tab, tabcount, "xx\tx", tab) + TABTEST( align * tab, tabcount, "xxx\tx", 4 * cx >= tab ? 2*tab :tab) + TABTEST( align * tab, tabcount, "xxxx\tx", 2*tab) + TABTEST( align * tab, tabcount, "xxxxx\tx", 2*tab) + } + } + + +} + START_TEST(text) { + test_TabbedText(); test_DrawTextCalcRect(); } Propchange: trunk/reactos/regtests/winetests/user32/text.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/user32.rbuild URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/u…
============================================================================== --- trunk/reactos/regtests/winetests/user32/user32.rbuild (original) +++ trunk/reactos/regtests/winetests/user32/user32.rbuild Wed Apr 5 06:34:10 2006 @@ -4,6 +4,8 @@ <library>ntdll</library> <library>user32</library> <library>gdi32</library> + <library>advapi32</library> + <library>kernel32</library> <file>class.c</file> <file>clipboard.c</file> <file>dce.c</file> @@ -13,6 +15,7 @@ <file>input.c</file> <file>listbox.c</file> <file>menu.c</file> + <file>monitor.c</file> <file>msg.c</file> <file>resource.c</file> <file>sysparams.c</file> Propchange: trunk/reactos/regtests/winetests/user32/user32.rbuild ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/win.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/w…
============================================================================== --- trunk/reactos/regtests/winetests/user32/win.c (original) +++ trunk/reactos/regtests/winetests/user32/win.c Wed Apr 5 06:34:10 2006 @@ -42,6 +42,8 @@ #define SPI_GETDESKWALLPAPER 0x0073 #endif +#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom)))) + #define LONG_PTR INT_PTR #define ULONG_PTR UINT_PTR @@ -60,6 +62,21 @@ #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0])) +/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT ); + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + diff = time - GetTickCount(); + } +} + /* check the values returned by the various parent/owner functions on a given window */ static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent, HWND gw_owner, HWND ga_root, HWND ga_root_owner ) @@ -71,7 +88,7 @@ res = pGetAncestor( hwnd, GA_PARENT ); ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent ); } - res = (HWND)GetWindowLongA( hwnd, GWL_HWNDPARENT ); + res = (HWND)GetWindowLongPtrA( hwnd, GWLP_HWNDPARENT ); ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent ); res = GetParent( hwnd ); ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent ); @@ -86,6 +103,21 @@ } } +BOOL CALLBACK EnumChildProc( HWND hwndChild, LPARAM lParam) +{ + (*(LPINT)lParam)++; + trace("EnumChildProc on %p\n", hwndChild); + if (*(LPINT)lParam > 1) return FALSE; + return TRUE; +} + +/* will search for the given window */ +BOOL CALLBACK EnumChildProc1( HWND hwndChild, LPARAM lParam) +{ + trace("EnumChildProc1 on %p\n", hwndChild); + if ((HWND)lParam == hwndChild) return FALSE; + return TRUE; +} static HWND create_tool_window( LONG style, HWND parent ) { @@ -102,6 +134,7 @@ HWND test, owner, ret; HWND desktop = GetDesktopWindow(); HWND child = create_tool_window( WS_CHILD, hwndMain ); + INT numChildren; trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child ); @@ -300,24 +333,24 @@ test = create_tool_window( WS_CHILD, hwndMain ); trace( "created child %p\n", test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 ); ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain ); check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child ); ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 ); check_parents( test, child, child, child, 0, hwndMain, hwndMain ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)desktop ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)desktop ); ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child ); check_parents( test, desktop, 0, desktop, 0, test, desktop ); - /* window is now child of desktop so GWL_HWNDPARENT changes owner from now on */ - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child ); + /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */ + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child ); ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret ); check_parents( test, desktop, child, desktop, child, test, desktop ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 ); ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child ); check_parents( test, desktop, 0, desktop, 0, test, desktop ); DestroyWindow( test ); @@ -326,15 +359,15 @@ test = create_tool_window( 0, 0 ); trace( "created top-level %p\n", test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 ); ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret ); check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child ); ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 ); check_parents( test, desktop, child, 0, child, test, test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 ); ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child ); check_parents( test, desktop, 0, 0, 0, test, test ); DestroyWindow( test ); @@ -343,15 +376,15 @@ test = create_tool_window( WS_POPUP, 0 ); trace( "created popup %p\n", test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 ); ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret ); check_parents( test, desktop, hwndMain2, hwndMain2, hwndMain2, test, hwndMain2 ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child ); ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 ); check_parents( test, desktop, child, child, child, test, hwndMain ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 ); ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child ); check_parents( test, desktop, 0, 0, 0, test, test ); DestroyWindow( test ); @@ -390,7 +423,7 @@ ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop ); check_parents( test, child, child, hwndMain2, hwndMain2, hwndMain, hwndMain2 ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)hwndMain ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (ULONG_PTR)hwndMain ); ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child ); check_parents( test, hwndMain, hwndMain, hwndMain2, hwndMain2, hwndMain, hwndMain2 ); DestroyWindow( test ); @@ -426,7 +459,7 @@ owner = create_tool_window( WS_CHILD, hwndMain2 ); test = create_tool_window( WS_POPUP, 0 ); trace( "created owner %p and popup %p\n", owner, test ); - ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)owner ); + ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (ULONG_PTR)owner ); ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret ); check_parents( test, desktop, owner, owner, owner, test, hwndMain2 ); DestroyWindow( owner ); @@ -440,6 +473,69 @@ /* final cleanup */ DestroyWindow(child); + + + owner = create_tool_window( WS_OVERLAPPED, 0 ); + test = create_tool_window( WS_POPUP, desktop ); + + ok( !GetWindow( test, GW_OWNER ), "Wrong owner window\n" ); + numChildren = 0; + ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned FALSE\n" ); + ok( numChildren == 0, "numChildren should be 0 got %d\n", numChildren ); + + SetWindowLongA( test, GWL_STYLE, (GetWindowLongA( test, GWL_STYLE ) & ~WS_POPUP) | WS_CHILD ); + ret = SetParent( test, owner ); + ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop ); + + numChildren = 0; + ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned TRUE\n" ); + ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren ); + + child = create_tool_window( WS_CHILD, owner ); + numChildren = 0; + ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned FALSE\n" ); + ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren ); + DestroyWindow( child ); + + child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner ); + ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" ); + numChildren = 0; + ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned TRUE\n" ); + ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren ); + + ret = SetParent( child, owner ); + ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" ); + ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop ); + numChildren = 0; + ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned FALSE\n" ); + ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren ); + + ret = SetParent( child, NULL ); + ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" ); + ok( ret == owner, "SetParent return value %p expected %p\n", ret, owner ); + numChildren = 0; + ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ), + "EnumChildWindows should have returned TRUE\n" ); + ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren ); + + /* even GW_OWNER == owner it's still a desktop's child */ + ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ), + "EnumChildWindows should have found %p and returned FALSE\n", child ); + + DestroyWindow( child ); + child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, NULL ); + + ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ), + "EnumChildWindows should have found %p and returned FALSE\n", child ); + + DestroyWindow( child ); + DestroyWindow( test ); + DestroyWindow( owner ); } @@ -459,7 +555,7 @@ minmax->ptMaxPosition.x, minmax->ptMaxPosition.y, minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y, minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y); - SetWindowLongA(hwnd, GWL_USERDATA, 0x20031021); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021); break; } case WM_WINDOWPOSCHANGING: @@ -516,7 +612,7 @@ } case WM_NCCREATE: { - BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) == 0x20031021; + BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021; CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam; trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd, cs->hwndParent, cs->style); @@ -554,12 +650,12 @@ minmax->ptMaxPosition.x, minmax->ptMaxPosition.y, minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y, minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y); - SetWindowLongA(hwnd, GWL_USERDATA, 0x20031021); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021); break; } case WM_NCCREATE: { - BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) == 0x20031021; + BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021; CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam; trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd, cs->hwndParent, cs->style); @@ -670,7 +766,7 @@ DWORD style, exstyle; RECT rc_window, rc_client, rc; BOOL menu; - BOOL is_win9x = GetWindowLongW(hwnd, GWL_WNDPROC) == 0; + BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0; style = GetWindowLongA(hwnd, GWL_STYLE); exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE); @@ -973,14 +1069,14 @@ mdi_cs.lParam = (LPARAM)mdi_lParam_test_message; mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); mdi_cs.style = 0x7fffffff; /* without WS_POPUP */ mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -993,7 +1089,7 @@ else { ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1014,7 +1110,7 @@ } else { - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1026,7 +1122,7 @@ mdi_client, GetModuleHandle(0), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1037,7 +1133,7 @@ mdi_client, GetModuleHandle(0), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1054,7 +1150,7 @@ else { ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1076,7 +1172,7 @@ } else { - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1088,7 +1184,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1099,7 +1195,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); @@ -1116,7 +1212,7 @@ else { ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1138,7 +1234,7 @@ } else { - ok(GetWindowLongA(mdi_child, GWL_ID) == first_id, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == first_id, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0); ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n"); } @@ -1162,7 +1258,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); DestroyWindow(mdi_child); mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child", @@ -1172,7 +1268,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); DestroyWindow(mdi_child); /* maximized child */ @@ -1183,7 +1279,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); DestroyWindow(mdi_child); trace("Creating maximized child with a caption\n"); @@ -1194,7 +1290,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); DestroyWindow(mdi_child); trace("Creating maximized child with a caption and a thick frame\n"); @@ -1205,7 +1301,7 @@ mdi_client, 0, GetModuleHandle(0), (LPVOID)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); - ok(GetWindowLongA(mdi_child, GWL_ID) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child, GWL_ID)); + ok(GetWindowLongPtrA(mdi_child, GWLP_ID) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child, GWLP_ID)); DestroyWindow(mdi_child); } @@ -1860,8 +1956,18 @@ for (i = 0; i < total; i++) { - child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10, - parent, 0, 0, NULL); + if (style[i] & DS_CONTROL) + { + child[i] = CreateWindowExA(0, MAKEINTATOMA(32770), "", style[i] & ~WS_VISIBLE, + 0,0,0,0, parent, (HMENU)i, 0, NULL); + if (style[i] & WS_VISIBLE) + ShowWindow(child[i], SW_SHOW); + + SetWindowPos(child[i], HWND_BOTTOM, 0,0,10,10, SWP_NOACTIVATE); + } + else + child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10, + parent, (HMENU)i, 0, NULL); trace("child[%d] = %p\n", i, child[i]); ok(child[i] != 0, "CreateWindowEx failed to create child window\n"); } @@ -1897,6 +2003,10 @@ const int complex_order_3[3] = { 1, 0, 2 }; const int complex_order_4[4] = { 1, 0, 2, 3 }; const int complex_order_5[5] = { 4, 1, 0, 2, 3 }; + const DWORD complex_style_6[3] = { WS_CHILD | WS_VISIBLE, + WS_CHILD | WS_CLIPSIBLINGS | DS_CONTROL | WS_VISIBLE, + WS_CHILD | WS_VISIBLE }; + const int complex_order_6[3] = { 0, 1, 2 }; /* simple WS_CHILD */ test_window_tree(parent, simple_style, simple_order, 5); @@ -1907,6 +2017,38 @@ test_window_tree(parent, complex_style, complex_order_3, 3); test_window_tree(parent, complex_style, complex_order_4, 4); test_window_tree(parent, complex_style, complex_order_5, 5); + + /* another set of complex children styles */ + test_window_tree(parent, complex_style_6, complex_order_6, 3); +} + +static void test_vis_rgn( HWND hwnd ) +{ + RECT win_rect, rgn_rect; + HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); + HDC hdc; + + ShowWindow(hwnd,SW_SHOW); + hdc = GetDC( hwnd ); + ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" ); + GetWindowRect( hwnd, &win_rect ); + GetRgnBox( hrgn, &rgn_rect ); + if (GetVersion() & 0x80000000) + { + trace("win9x, mapping to screen coords\n"); + MapWindowPoints( hwnd, 0, (POINT *)&rgn_rect, 2 ); + } + trace("win: %ld,%ld-%ld,%ld\n", win_rect.left, win_rect.top, win_rect.right, win_rect.bottom ); + trace("rgn: %ld,%ld-%ld,%ld\n", rgn_rect.left, rgn_rect.top, rgn_rect.right, rgn_rect.bottom ); + ok( win_rect.left <= rgn_rect.left, "rgn left %ld not inside win rect %ld\n", + rgn_rect.left, win_rect.left ); + ok( win_rect.top <= rgn_rect.top, "rgn top %ld not inside win rect %ld\n", + rgn_rect.top, win_rect.top ); + ok( win_rect.right >= rgn_rect.right, "rgn right %ld not inside win rect %ld\n", + rgn_rect.right, win_rect.right ); + ok( win_rect.bottom >= rgn_rect.bottom, "rgn bottom %ld not inside win rect %ld\n", + rgn_rect.bottom, win_rect.bottom ); + ReleaseDC( hwnd, hdc ); } static void test_SetFocus(HWND hwnd) @@ -2144,6 +2286,8 @@ static void test_capture_3(HWND hwnd1, HWND hwnd2) { + BOOL ret; + ShowWindow(hwnd1, SW_HIDE); ShowWindow(hwnd2, SW_HIDE); @@ -2159,7 +2303,10 @@ ShowWindow(hwnd1, SW_SHOW); check_wnd_state(hwnd1, hwnd1, hwnd1, hwnd2); - ReleaseCapture(); + ret = ReleaseCapture(); + ok (ret, "releasecapture did not return TRUE.\n"); + ret = ReleaseCapture(); + ok (ret, "releasecapture did not return TRUE after second try.\n"); } static void test_keyboard_input(HWND hwnd) @@ -2169,6 +2316,7 @@ ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); + flush_events(); ok(GetActiveWindow() == hwnd, "wrong active window %p\n", GetActiveWindow()); @@ -2235,6 +2383,7 @@ HWND popup; MSG msg; BOOL ret; + LRESULT res; ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); @@ -2344,6 +2493,39 @@ ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n"); ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p message %04x\n", msg.hwnd, msg.message); ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n"); + + /* Test WM_MOUSEACTIVATE */ +#define TEST_MOUSEACTIVATE(A,B) \ + res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \ + ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res); + + TEST_MOUSEACTIVATE(HTERROR,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTTRANSPARENT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTNOWHERE,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTCLIENT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTCAPTION,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTSYSMENU,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTSIZE,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTMENU,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTHSCROLL,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTVSCROLL,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTMINBUTTON,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTMAXBUTTON,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTLEFT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTRIGHT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTTOP,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTTOPLEFT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTTOPRIGHT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTBOTTOM,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTBOTTOMLEFT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTBOTTOMRIGHT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTBORDER,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTOBJECT,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTCLOSE,MA_ACTIVATE); + TEST_MOUSEACTIVATE(HTHELP,MA_ACTIVATE); + + /* Clear any messages left behind by WM_MOUSEACTIVATE tests */ + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); DestroyWindow(popup); } @@ -2649,6 +2831,9 @@ * hwnd2 because of the WS_CLIPSIBLING style */ HWND hwnd1, hwnd2; + clipping = CreateRectRgn(0,0,0,0); + tmprgn = CreateRectRgn(0,0,0,0); + exprgn = CreateRectRgn(0,0,0,0); hwnd2 = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER , 75, 30, 100, 100, parent, 0, 0, NULL); @@ -2659,17 +2844,17 @@ UpdateWindow( parent); GetClientRect( hwnd1, &rc); cliprc=rc; - clipping = CreateRectRgn( 10, 10, 90, 90); + SetRectRgn( clipping, 10, 10, 90, 90); hdc = GetDC( hwnd1); /* for a visual touch */ TextOut( hdc, 0,10, "0123456789", 10); ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu); if (winetest_debug > 0) dump_region(hrgn); /* create a region with what is expected */ - exprgn = CreateRectRgn( 39,0,49,74); - tmprgn = CreateRectRgn( 88,79,98,93); + SetRectRgn( exprgn, 39,0,49,74); + SetRectRgn( tmprgn, 88,79,98,93); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); - tmprgn = CreateRectRgn( 0,93,98,98); + SetRectRgn( tmprgn, 0,93,98,98); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); trace("update rect is %ld,%ld - %ld,%ld\n", @@ -2679,10 +2864,10 @@ ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu); if (winetest_debug > 0) dump_region(hrgn); /* create a region with what is expected */ - exprgn = CreateRectRgn( 39,10,49,74); - tmprgn = CreateRectRgn( 80,79,90,85); + SetRectRgn( exprgn, 39,10,49,74); + SetRectRgn( tmprgn, 80,79,90,85); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); - tmprgn = CreateRectRgn( 10,85,90,90); + SetRectRgn( tmprgn, 10,85,90,90); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); trace("update rect is %ld,%ld - %ld,%ld\n", @@ -2699,8 +2884,8 @@ ScrollWindowEx( hwnd1, -10, 0, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE); if (winetest_debug > 0) dump_region(hrgn); - exprgn = CreateRectRgn( 88,0,98,98); - tmprgn = CreateRectRgn( 30, 40, 50, 50); + SetRectRgn( exprgn, 88,0,98,98); + SetRectRgn( tmprgn, 30, 40, 50, 50); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); @@ -2721,8 +2906,8 @@ ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE); if (winetest_debug > 0) dump_region(hrgn); - exprgn = CreateRectRgn( 88,0,98,88); - tmprgn = CreateRectRgn( 0,88,98,98); + SetRectRgn( exprgn, 88,0,98,88); + SetRectRgn( tmprgn, 0,88,98,98); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); @@ -2750,12 +2935,12 @@ ValidateRect( hwnd2, NULL); ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE); if (winetest_debug > 0) dump_region(hrgn); - exprgn = CreateRectRgn( 88,0,98,20); - tmprgn = CreateRectRgn( 20,20,98,30); + SetRectRgn( exprgn, 88,0,98,20); + SetRectRgn( tmprgn, 20,20,98,30); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); - tmprgn = CreateRectRgn( 20,30,30,88); + SetRectRgn( tmprgn, 20,30,30,88); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); - tmprgn = CreateRectRgn( 0,88,30,98); + SetRectRgn( tmprgn, 0,88,30,98); CombineRgn( exprgn, exprgn, tmprgn, RGN_OR); ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); @@ -2803,14 +2988,97 @@ DestroyWindow( hwnd); } +static void test_scrolldc( HWND parent) +{ + HDC hdc; + HRGN exprgn, tmprgn, hrgn; + RECT rc, rc2, rcu, cliprc; + HWND hwnd1; + COLORREF colr; + + hrgn = CreateRectRgn(0,0,0,0); + tmprgn = CreateRectRgn(0,0,0,0); + exprgn = CreateRectRgn(0,0,0,0); + + hwnd1 = CreateWindowExA(0, "static", NULL, + WS_CHILD| WS_VISIBLE, + 25, 50, 100, 100, parent, 0, 0, NULL); + ShowWindow( parent, SW_SHOW); + UpdateWindow( parent); + GetClientRect( hwnd1, &rc); + hdc = GetDC( hwnd1); + /* paint the upper half of the window black */ + rc2 = rc; + rc2.bottom = ( rc.top + rc.bottom) /2; + FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH)); + /* clip region is the lower half */ + cliprc=rc; + cliprc.top = (rc.top + rc.bottom) /2; + /* test whether scrolled pixels are properly clipped */ + colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1); + ok ( colr == 0, "pixel should be black, color is %08lx\n", colr); + /* this scroll should not cause any visible changes */ + ScrollDC( hdc, 5, -20, &rc, &cliprc, hrgn, &rcu); + colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1); + ok ( colr == 0, "pixel should be black, color is %08lx\n", colr); + /* test with NULL clip rect */ + ScrollDC( hdc, 20, -20, &rc, NULL, hrgn, &rcu); + /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/ + trace("update rect: %ld,%ld - %ld,%ld\n", + rcu.left, rcu.top, rcu.right, rcu.bottom); + if (winetest_debug > 0) dump_region(hrgn); + SetRect(&rc2, 0, 0, 100, 100); + ok(EqualRect(&rcu, &rc2), "rects do not match (%ld,%ld-%ld,%ld) / (%ld,%ld-%ld,%ld)\n", + rcu.left, rcu.top, rcu.right, rcu.bottom, rc2.left, rc2.top, rc2.right, rc2.bottom); + + SetRectRgn( exprgn, 0, 0, 20, 80); + SetRectRgn( tmprgn, 0, 80, 100, 100); + CombineRgn(exprgn, exprgn, tmprgn, RGN_OR); + if (winetest_debug > 0) dump_region(exprgn); + ok(EqualRgn(exprgn, hrgn), "wrong update region\n"); + /* test clip rect > scroll rect */ + FillRect( hdc, &rc, GetStockObject(WHITE_BRUSH)); + rc2=rc; + InflateRect( &rc2, -(rc.right-rc.left)/4, -(rc.bottom-rc.top)/4); + FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH)); + ScrollDC( hdc, 10, 10, &rc2, &rc, hrgn, &rcu); + SetRectRgn( exprgn, 25, 25, 75, 35); + SetRectRgn( tmprgn, 25, 35, 35, 75); + CombineRgn(exprgn, exprgn, tmprgn, RGN_OR); + ok(EqualRgn(exprgn, hrgn), "wrong update region\n"); + colr = GetPixel( hdc, 80, 80); + ok ( colr == 0, "pixel should be black, color is %08lx\n", colr); + trace("update rect: %ld,%ld - %ld,%ld\n", + rcu.left, rcu.top, rcu.right, rcu.bottom); + if (winetest_debug > 0) dump_region(hrgn); + + /* clean up */ + DeleteObject(hrgn); + DeleteObject(exprgn); + DeleteObject(tmprgn); + DestroyWindow(hwnd1); +} + static void test_params(void) { + HWND hwnd; INT rc; /* Just a param check */ SetLastError(0xdeadbeef); rc = GetWindowText(hwndMain2, NULL, 1024); ok( rc==0, "GetWindowText: rc=%d err=%ld\n",rc,GetLastError()); + + SetLastError(0xdeadbeef); + hwnd=CreateWindow("LISTBOX", "TestList", + (LBS_STANDARD & ~LBS_SORT), + 0, 0, 100, 100, + NULL, (HMENU)1, NULL, 0); + + ok(!hwnd, "CreateWindow with invalid menu handle should fail\n"); + ok(GetLastError() == ERROR_INVALID_MENU_HANDLE || /* NT */ + GetLastError() == 0xdeadbeef, /* Win9x */ + "wrong last error value %ld\n", GetLastError()); } static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu) @@ -3005,7 +3273,7 @@ RECT rc; PAINTSTRUCT ps; - struct parentdc_stat *t = (struct parentdc_stat *)GetWindowLongPtrA(hwnd, GWL_USERDATA); + struct parentdc_stat *t = (struct parentdc_stat *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); switch (msg) { @@ -3163,16 +3431,17 @@ AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, FALSE, 0); hwndMain = CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, 0, NULL); - SetWindowLongPtrA(hwndMain, GWL_USERDATA, (DWORD_PTR)&test_answer.main); + SetWindowLongPtrA(hwndMain, GWLP_USERDATA, (DWORD_PTR)&test_answer.main); hwnd1 = CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD, 20, 20, 40, 40, hwndMain, NULL, 0, NULL); - SetWindowLongPtrA(hwnd1, GWL_USERDATA, (DWORD_PTR)&test_answer.child1); + SetWindowLongPtrA(hwnd1, GWLP_USERDATA, (DWORD_PTR)&test_answer.child1); hwnd2 = CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD, 40, 40, 40, 40, hwndMain, NULL, 0, NULL); - SetWindowLongPtrA(hwnd2, GWL_USERDATA, (DWORD_PTR)&test_answer.child2); + SetWindowLongPtrA(hwnd2, GWLP_USERDATA, (DWORD_PTR)&test_answer.child2); ShowWindow(hwndMain, SW_SHOW); ShowWindow(hwnd1, SW_SHOW); ShowWindow(hwnd2, SW_SHOW); + flush_events(); zero_parentdc_test(&test_answer); InvalidateRect(hwndMain, NULL, TRUE); @@ -3377,6 +3646,7 @@ assert( hwndMain ); assert( hwndMain2 ); + /* Add the tests below this line */ test_params(); test_capture_1(); @@ -3400,13 +3670,16 @@ test_validatergn(hwndMain); test_nccalcscroll( hwndMain); test_scrollvalidate( hwndMain); + test_scrolldc( hwndMain); test_scroll(); test_IsWindowUnicode(); - - UnhookWindowsHookEx(hhook); + test_vis_rgn(hwndMain); test_AdjustWindowRect(); test_window_styles(); test_redrawnow(); test_csparentdc(); -} + + /* add the tests above this line */ + UnhookWindowsHookEx(hhook); +} Propchange: trunk/reactos/regtests/winetests/user32/win.c ------------------------------------------------------------------------------ native = class.c Modified: trunk/reactos/regtests/winetests/user32/winstation.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/regtests/winetests/user32/w…
============================================================================== --- trunk/reactos/regtests/winetests/user32/winstation.c (original) +++ trunk/reactos/regtests/winetests/user32/winstation.c Wed Apr 5 06:34:10 2006 @@ -42,12 +42,29 @@ trace( "obj %p type '%s'\n", obj, buffer ); } +static void register_class(void) +{ + WNDCLASSA cls; + + cls.style = CS_DBLCLKS; + cls.lpfnWndProc = DefWindowProcA; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "WinStationClass"; + RegisterClassA(&cls); +} + static HDESK initial_desktop; static DWORD CALLBACK thread( LPVOID arg ) { HDESK d1, d2; - HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0); + HWND hwnd = CreateWindowExA(0,"WinStationClass","test",WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0); ok( hwnd != 0, "CreateWindow failed\n" ); d1 = GetThreadDesktop(GetCurrentThreadId()); trace( "thread %p desktop: %p\n", arg, d1 ); @@ -89,6 +106,8 @@ HDESK d1, d2, d3; HANDLE hthread; DWORD id, flags; + ATOM atom; + char buffer[20]; /* win stations */ @@ -143,6 +162,28 @@ w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); ok( !w3, "open foobar station succeeded\n" ); + + w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); + ok( w2 != 0, "create foobar station failed\n" ); + w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); + ok( w3 != 0, "create foobar station failed\n" ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" ); + + SetProcessWindowStation( w2 ); + register_class(); + atom = GlobalAddAtomA("foo"); + ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); + ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); + + ok( !CloseWindowStation( w2 ), "CloseWindowStation succeeded\n" ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + + SetProcessWindowStation( w3 ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); + ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); + ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); /* desktops */ d1 = GetThreadDesktop(GetCurrentThreadId()); Propchange: trunk/reactos/regtests/winetests/user32/winstation.c ------------------------------------------------------------------------------ native = class.c Propchange: trunk/reactos/regtests/winetests/user32/wsprintf.c ------------------------------------------------------------------------------ native = class.c
1
0
0
0
[tretiakov] 21454: Improved code a bit. Added ContextHandleNdr structure
by alekseyï¼ studiocerebral.com
04 Apr '06
04 Apr '06
Author: tretiakov Date: Tue Apr 4 16:56:32 2006 New Revision: 21454 URL:
http://svn.reactos.ru/svn/reactos?rev=21454&view=rev
Log: Improved code a bit. Added ContextHandleNdr structure Modified: trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c trunk/reactos/dll/win32/rpcrt4/rpc_binding.h Modified: trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/rpcrt4/ndr_marsha…
============================================================================== --- trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c (original) +++ trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c Tue Apr 4 16:56:32 2006 @@ -3236,7 +3236,7 @@ void WINAPI NDRCContextMarshall(NDR_CCONTEXT CContext, void *pBuff ) { CContextHandle *ctx = (CContextHandle*)CContext; - memcpy(pBuff, ctx->Ndr, CONTEXT_HANDLE_NDR_SIZE); + memcpy(pBuff, &ctx->Ndr, sizeof(ContextHandleNdr)); } /*********************************************************************** @@ -3252,7 +3252,7 @@ NDRCContextMarshall(ContextHandle, pStubMsg->Buffer); - pStubMsg->Buffer += CONTEXT_HANDLE_NDR_SIZE; + pStubMsg->Buffer += sizeof(ContextHandleNdr); } @@ -3265,16 +3265,12 @@ void *pBuff, unsigned long DataRepresentation ) { - CContextHandle *ctx; + CContextHandle *ctx = (CContextHandle*)*pCContext; + ContextHandleNdr *ndr = (ContextHandleNdr*)pBuff; RPC_STATUS status; - char *buf = (char*)pBuff; - int i; - - for(i = 0; i < CONTEXT_HANDLE_NDR_SIZE && !buf[i]; i++); - - if(i == CONTEXT_HANDLE_NDR_SIZE) + + if(UuidIsNil(&ndr->uuid, &status)) { - ctx = (CContextHandle*)*pCContext; if(ctx) { RPCRT4_DestroyBinding(ctx->Binding); @@ -3290,7 +3286,7 @@ status = RpcBindingCopy(hBinding, (RPC_BINDING_HANDLE*) &ctx->Binding); if(status != RPC_S_OK) RpcRaiseException(status); - memcpy(ctx->Ndr, pBuff, CONTEXT_HANDLE_NDR_SIZE); + memcpy(&ctx->Ndr, ndr, sizeof(ContextHandleNdr)); *pCContext = (NDR_CCONTEXT)ctx; } } @@ -3310,7 +3306,7 @@ pStubMsg->Buffer, pStubMsg->RpcMsg->DataRepresentation); - pStubMsg->Buffer += CONTEXT_HANDLE_NDR_SIZE; + pStubMsg->Buffer += sizeof(ContextHandleNdr); } void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg, Modified: trunk/reactos/dll/win32/rpcrt4/rpc_binding.h URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/rpcrt4/rpc_bindin…
============================================================================== --- trunk/reactos/dll/win32/rpcrt4/rpc_binding.h (original) +++ trunk/reactos/dll/win32/rpcrt4/rpc_binding.h Tue Apr 4 16:56:32 2006 @@ -53,12 +53,16 @@ RpcConnection* FromConn; } RpcBinding; -#define CONTEXT_HANDLE_NDR_SIZE 20 +typedef struct _ContextHandleNdr +{ + UINT attributes; + UUID uuid; +} ContextHandleNdr; typedef struct _CContextHandle { RpcBinding *Binding; - BYTE Ndr[CONTEXT_HANDLE_NDR_SIZE]; + ContextHandleNdr Ndr; } CContextHandle; LPSTR RPCRT4_strndupA(LPCSTR src, INT len);
1
0
0
0
← Newer
1
...
7016
7017
7018
7019
7020
7021
7022
...
8139
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
Results per page:
10
25
50
100
200