mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
properly initialize system menu items
svn path=/trunk/; revision=8951
This commit is contained in:
parent
eec82162fb
commit
23e366974c
2 changed files with 43 additions and 15 deletions
|
@ -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 DefWndNCActivate(HWND hWnd, WPARAM wParam);
|
|||
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 @@ User32DefWindowProc(HWND hWnd,
|
|||
}
|
||||
else
|
||||
{
|
||||
LONG HitCode;
|
||||
POINT Pt;
|
||||
DWORD Style;
|
||||
LONG HitCode;
|
||||
|
||||
Style = GetWindowLongW(hWnd, GWL_STYLE);
|
||||
|
||||
|
@ -1062,18 +1063,19 @@ User32DefWindowProc(HWND hWnd,
|
|||
if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
|
||||
{
|
||||
HMENU SystemMenu;
|
||||
UINT DefItem = SC_CLOSE;
|
||||
UINT Flags;
|
||||
|
||||
if((SystemMenu = GetSystemMenu(hWnd, FALSE)))
|
||||
{
|
||||
MenuInitSysMenuPopup(SystemMenu, GetWindowLongW(hWnd, GWL_STYLE),
|
||||
GetClassLongW(hWnd, GCL_STYLE), HitCode);
|
||||
|
||||
if(HitCode == HTCAPTION)
|
||||
DefItem = ((Style & (WS_MAXIMIZE | WS_MINIMIZE)) ?
|
||||
SC_RESTORE : SC_MAXIMIZE);
|
||||
Flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON;
|
||||
else
|
||||
Flags = TPM_LEFTBUTTON;
|
||||
|
||||
SetMenuDefaultItem(SystemMenu, DefItem, MF_BYCOMMAND);
|
||||
|
||||
TrackPopupMenu(SystemMenu,
|
||||
TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
|
||||
TrackPopupMenu(SystemMenu, Flags,
|
||||
Pt.x, Pt.y, 0, hWnd, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 @@ MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset)
|
|||
*
|
||||
* 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 @@ MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle )
|
|||
{
|
||||
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 @@ MenuShowSubPopup(HWND WndOwner, PROSMENUINFO MenuInfo, BOOL SelectFirst, UINT Fl
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue