reactos/lib/user32/windows
diff -u -r1.127 -r1.128
--- defwnd.c 31 Mar 2004 14:12:04 -0000 1.127
+++ defwnd.c 2 Apr 2004 19:00:56 -0000 1.128
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.127 2004/03/31 14:12:04 weiden Exp $
+/* $Id: defwnd.c,v 1.128 2004/04/02 19:00:56 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -30,6 +30,7 @@
LRESULT DefWndNCHitTest(HWND hWnd, POINT Point);
LRESULT DefWndNCLButtonDown(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT DefWndNCLButtonDblClk(HWND hWnd, WPARAM wParam, LPARAM lParam);
+void FASTCALL MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle, LONG HitTest );
/* GLOBALS *******************************************************************/
@@ -1044,9 +1045,9 @@
}
else
{
- LONG HitCode;
POINT Pt;
DWORD Style;
+ LONG HitCode;
Style = GetWindowLongW(hWnd, GWL_STYLE);
@@ -1062,18 +1063,19 @@
if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
{
HMENU SystemMenu;
- UINT DefItem = SC_CLOSE;
+ UINT Flags;
if((SystemMenu = GetSystemMenu(hWnd, FALSE)))
{
- if(HitCode == HTCAPTION)
- DefItem = ((Style & (WS_MAXIMIZE | WS_MINIMIZE)) ?
- SC_RESTORE : SC_MAXIMIZE);
+ MenuInitSysMenuPopup(SystemMenu, GetWindowLongW(hWnd, GWL_STYLE),
+ GetClassLongW(hWnd, GCL_STYLE), HitCode);
- SetMenuDefaultItem(SystemMenu, DefItem, MF_BYCOMMAND);
+ if(HitCode == HTCAPTION)
+ Flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON;
+ else
+ Flags = TPM_LEFTBUTTON;
- TrackPopupMenu(SystemMenu,
- TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
+ TrackPopupMenu(SystemMenu, Flags,
Pt.x, Pt.y, 0, hWnd, NULL);
}
}
reactos/lib/user32/windows
diff -u -r1.59 -r1.60
--- menu.c 1 Apr 2004 23:17:28 -0000 1.59
+++ menu.c 2 Apr 2004 19:00:56 -0000 1.60
@@ -21,7 +21,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: menu.c,v 1.59 2004/04/01 23:17:28 gvg Exp $
+/* $Id: menu.c,v 1.60 2004/04/02 19:00:56 weiden Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/menu.c
@@ -1984,10 +1984,12 @@
*
* Grey the appropriate items in System menu.
*/
-static void FASTCALL
-MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle )
+void FASTCALL
+MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle, LONG HitTest )
{
BOOL Gray;
+ UINT DefItem;
+ MENUITEMINFOW mii;
Gray = 0 == (Style & WS_THICKFRAME) || 0 != (Style & (WS_MAXIMIZE | WS_MINIMIZE));
EnableMenuItem(Menu, SC_SIZE, (Gray ? MF_GRAYED : MF_ENABLED));
@@ -2006,6 +2008,31 @@
{
EnableMenuItem(Menu, SC_CLOSE, MF_GRAYED);
}
+
+ /* Set default menu item */
+ if(Style & WS_MINIMIZE)
+ {
+ DefItem = SC_RESTORE;
+ }
+ else
+ {
+ if(HitTest == HTCAPTION)
+ {
+ DefItem = ((Style & (WS_MAXIMIZE | WS_MINIMIZE)) ? SC_RESTORE : SC_MAXIMIZE);
+ }
+ else
+ {
+ DefItem = SC_CLOSE;
+ }
+ }
+ mii.cbSize = sizeof(MENUITEMINFOW);
+ mii.fMask = MIIM_STATE;
+ if(GetMenuItemInfoW(Menu, DefItem, FALSE, &mii) &&
+ (mii.fState & (MFS_GRAYED | MFS_DISABLED)))
+ {
+ DefItem = SC_CLOSE;
+ }
+ SetMenuDefaultItem(Menu, DefItem, MF_BYCOMMAND);
}
/***********************************************************************
@@ -2093,9 +2120,8 @@
if (IS_SYSTEM_MENU(MenuInfo))
{
- MenuInitSysMenuPopup(ItemInfo.hSubMenu,
- GetWindowLongW(MenuInfo->Wnd, GWL_STYLE ),
- GetClassLongW(MenuInfo->Wnd, GCL_STYLE));
+ MenuInitSysMenuPopup(ItemInfo.hSubMenu, GetWindowLongW(MenuInfo->Wnd, GWL_STYLE),
+ GetClassLongW(MenuInfo->Wnd, GCL_STYLE), FALSE);
NcGetSysPopupPos(MenuInfo->Wnd, &Rect);
Rect.top = Rect.bottom;