9 modified files
reactos/lib/user32
diff -u -r1.31 -r1.32
--- user32.rc 30 Jan 2004 15:53:36 -0000 1.31
+++ user32.rc 22 Feb 2004 23:40:58 -0000 1.32
@@ -119,20 +119,13 @@
SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE
{
- POPUP ""
- {
- MENUITEM "&Restore", 61728
- MENUITEM "&Move", 61456
- MENUITEM "&Size", 61440
- MENUITEM "Mi&nimize", 61472
- MENUITEM "Ma&ximize", 61488
- MENUITEM SEPARATOR
- MENUITEM "&Close\tAlt-F4", 61536
- //MENUITEM SEPARATOR
- //MENUITEM "&Switch to ...\tCtrl-Esc", 61744
- //MENUITEM SEPARATOR
- //MENUITEM "&About ReactOS ...", 61761
- }
+ MENUITEM "&Restore", 61728
+ MENUITEM "&Move", 61456
+ MENUITEM "&Size", 61440
+ MENUITEM "Mi&nimize", 61472
+ MENUITEM "Ma&ximize", 61488
+ MENUITEM SEPARATOR
+ MENUITEM "&Close\tAlt-F4", 61536
}
/////////////////////////////////////////////////////////////////////////////
reactos/lib/user32/windows
diff -u -r1.123 -r1.124
--- defwnd.c 26 Jan 2004 08:44:51 -0000 1.123
+++ defwnd.c 22 Feb 2004 23:40:58 -0000 1.124
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.123 2004/01/26 08:44:51 weiden Exp $
+/* $Id: defwnd.c,v 1.124 2004/02/22 23:40:58 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -817,7 +817,7 @@
SendMessageA(hWnd, WM_CLOSE, 0, 0);
break;
case SC_MOUSEMENU:
- MenuTrackMouseMenuBar(hWnd, wParam, Pt);
+ MenuTrackMouseMenuBar(hWnd, wParam & 0x000f, Pt);
break;
case SC_KEYMENU:
MenuTrackKbdMenuBar(hWnd, wParam, Pt.x);
reactos/lib/user32/windows
diff -u -r1.49 -r1.50
--- menu.c 22 Feb 2004 18:04:52 -0000 1.49
+++ menu.c 22 Feb 2004 23:40:58 -0000 1.50
@@ -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.49 2004/02/22 18:04:52 gvg Exp $
+/* $Id: menu.c,v 1.50 2004/02/22 23:40:58 gvg Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/menu.c
@@ -1929,6 +1929,35 @@
}
/***********************************************************************
+ * MenuInitSysMenuPopup
+ *
+ * Grey the appropriate items in System menu.
+ */
+static void FASTCALL
+MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle )
+{
+ BOOL Gray;
+
+ Gray = 0 == (Style & WS_THICKFRAME) || 0 != (Style & (WS_MAXIMIZE | WS_MINIMIZE));
+ EnableMenuItem(Menu, SC_SIZE, (Gray ? MF_GRAYED : MF_ENABLED));
+ Gray = 0 != (Style & WS_MAXIMIZE);
+ EnableMenuItem(Menu, SC_MOVE, (Gray ? MF_GRAYED : MF_ENABLED));
+ Gray = 0 == (Style & WS_MINIMIZEBOX) || 0 != (Style & WS_MINIMIZE);
+ EnableMenuItem(Menu, SC_MINIMIZE, (Gray ? MF_GRAYED : MF_ENABLED));
+ Gray = 0 == (Style & WS_MAXIMIZEBOX) || 0 != (Style & WS_MAXIMIZE);
+ EnableMenuItem(Menu, SC_MAXIMIZE, (Gray ? MF_GRAYED : MF_ENABLED));
+ Gray = 0 == (Style & (WS_MAXIMIZE | WS_MINIMIZE));
+ EnableMenuItem(Menu, SC_RESTORE, (Gray ? MF_GRAYED : MF_ENABLED));
+ Gray = 0 != (ClsStyle & CS_NOCLOSE);
+
+ /* The menu item must keep its state if it's disabled */
+ if (Gray)
+ {
+ EnableMenuItem(Menu, SC_CLOSE, MF_GRAYED);
+ }
+}
+
+/***********************************************************************
* MenuShowSubPopup
*
* Display the sub-menu of the selected item of this menu.
@@ -1937,6 +1966,7 @@
static HMENU FASTCALL
MenuShowSubPopup(HWND WndOwner, PROSMENUINFO MenuInfo, BOOL SelectFirst, UINT Flags)
{
+ extern void FASTCALL NcGetSysPopupPos(HWND Wnd, RECT *Rect);
RECT Rect;
ROSMENUITEMINFO ItemInfo;
ROSMENUINFO SubMenuInfo;
@@ -2012,16 +2042,14 @@
if (IS_SYSTEM_MENU(MenuInfo))
{
-#if 0 /* FIXME */
- MENU_InitSysMenuPopup(item->hSubMenu,
- GetWindowLongW( menu->hWnd, GWL_STYLE ),
- GetClassLongW( menu->hWnd, GCL_STYLE));
-
- NC_GetSysPopupPos( menu->hWnd, &rect );
- rect.top = rect.bottom;
- rect.right = GetSystemMetrics(SM_CXSIZE);
- rect.bottom = GetSystemMetrics(SM_CYSIZE);
-#endif
+ MenuInitSysMenuPopup(ItemInfo.hSubMenu,
+ GetWindowLongW(MenuInfo->Wnd, GWL_STYLE ),
+ GetClassLongW(MenuInfo->Wnd, GCL_STYLE));
+
+ NcGetSysPopupPos(MenuInfo->Wnd, &Rect);
+ Rect.top = Rect.bottom;
+ Rect.right = GetSystemMetrics(SM_CXSIZE);
+ Rect.bottom = GetSystemMetrics(SM_CYSIZE);
}
else
{
@@ -2345,11 +2373,7 @@
}
else if (HTSYSMENU == Ht)
{
-#if 0 /* FIXME */
- Ret = get_win_sys_menu( menu->hWnd );
-#else
- Ret = NULL;
-#endif
+ Ret = NtUserGetSystemMenu(MenuInfo.Wnd, FALSE);
}
else if (HTMENU == Ht)
{
@@ -2529,7 +2553,6 @@
static LRESULT FASTCALL
MenuDoNextMenu(MTRACKER* Mt, UINT Vk)
{
-#if 0 /* FIXME */
ROSMENUINFO TopMenuInfo;
ROSMENUINFO MenuInfo;
@@ -2579,10 +2602,8 @@
}
else if (0 != (Style & WS_SYSMENU))
{
-#if 0 /* FIXME */
/* switch to the system menu */
- NewMenu = get_win_sys_menu(NewWnd);
-#endif
+ NewMenu = NtUserGetSystemMenu(NewWnd, FALSE);
}
else
{
@@ -2598,17 +2619,13 @@
{
DWORD Style = GetWindowLongW(NewWnd, GWL_STYLE);
-#if 0 /* FIXME */
if (0 != (Style & WS_SYSMENU)
- && GetSubMenu(get_win_sys_menu(NewWnd), 0) == NewMenu)
+ && GetSystemMenu(NewWnd, FALSE) == NewMenu)
{
/* get the real system menu */
- NewMenu = get_win_sys_menu(NewWnd);
+ NewMenu = NtUserGetSystemMenu(NewWnd, FALSE);
}
else if (0 != (Style & WS_CHILD) || GetMenu(NewWnd) != NewMenu)
-#else
- if (0 != (Style & WS_CHILD) || GetMenu(NewWnd) != NewMenu)
-#endif
{
/* FIXME: Not sure what to do here;
* perhaps try to track NewMenu as a popup? */
@@ -2647,7 +2664,6 @@
return TRUE;
}
-#endif
return FALSE;
}
@@ -2894,15 +2910,24 @@
MenuFindItemByKey(HWND WndOwner, PROSMENUINFO MenuInfo,
WCHAR Key, BOOL ForceMenuChar)
{
+ ROSMENUINFO SysMenuInfo;
PROSMENUITEMINFO Items, ItemInfo;
LRESULT MenuChar;
UINT i;
DPRINT("\tlooking for '%c' (0x%02x) in [%p]\n", (char) Key, Key, MenuInfo);
-#if 0 /* FIXME */
- if (! IsMenu( hmenu )) hmenu = GetSubMenu( get_win_sys_menu(hwndOwner), 0);
-#endif
+ if (NULL == MenuInfo || ! IsMenu(MenuInfo->Self))
+ {
+ if (MenuGetRosMenuInfo(&SysMenuInfo, GetSystemMenu(WndOwner, FALSE)))
+ {
+ MenuInfo = &SysMenuInfo;
+ }
+ else
+ {
+ MenuInfo = NULL;
+ }
+ }
if (NULL != MenuInfo)
{
@@ -3328,20 +3353,9 @@
VOID
MenuTrackMouseMenuBar(HWND Wnd, ULONG Ht, POINT Pt)
{
-#if 0 /* FIXME */
- HMENU Menu = (ht == HTSYSMENU) ? get_win_sys_menu( Wnd ) : GetMenu( Wnd );
- UINT Flags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON;
-#else
- HMENU Menu;
+ HMENU Menu = (HTSYSMENU == Ht) ? NtUserGetSystemMenu(Wnd, FALSE) : GetMenu(Wnd);
UINT Flags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON;
- if (HTSYSMENU == Ht)
- {
- return;
- }
- Menu = GetMenu(Wnd);
-#endif
-
DPRINT("wnd=%p ht=0x%04x (%ld,%ld)\n", Wnd, Ht, pt.x, pt.y);
if (IsMenu(Menu))
@@ -3760,10 +3774,26 @@
if (NtUserMenuItemInfo(hMenu, (UINT)nPos, MF_BYPOSITION, &mi, FALSE))
{
- return mi.hSubMenu;
+ return IsMenu(mi.hSubMenu) ? mi.hSubMenu : NULL;
}
- return (HMENU)0;
+ return NULL;
+}
+
+/*
+ * @implemented
+ */
+HMENU
+STDCALL
+GetSystemMenu(
+ HWND hWnd,
+ BOOL bRevert)
+{
+ HMENU TopMenu;
+
+ TopMenu = NtUserGetSystemMenu(hWnd, bRevert);
+
+ return NULL == TopMenu ? NULL : GetSubMenu(TopMenu, 0);
}
@@ -4259,6 +4289,28 @@
return FALSE;
}
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+SetSystemMenu (
+ HWND hwnd,
+ HMENU hMenu)
+{
+ if(!hwnd)
+ {
+ SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+ return FALSE;
+ }
+ if(!hMenu)
+ {
+ SetLastError(ERROR_INVALID_MENU_HANDLE);
+ return FALSE;
+ }
+ return NtUserSetSystemMenu(hwnd, hMenu);
+}
+
/*
* @implemented
reactos/lib/user32/windows
diff -u -r1.44 -r1.45
--- nonclient.c 10 Feb 2004 10:17:30 -0000 1.44
+++ nonclient.c 22 Feb 2004 23:40:58 -0000 1.45
@@ -1321,3 +1321,85 @@
UNIMPLEMENTED;
return FALSE;
}
+
+/***********************************************************************
+ * NcGetInsideRect
+ *
+ * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
+ * but without the borders (if any).
+ * The rectangle is in window coordinates (for drawing with GetWindowDC()).
+ */
+static void FASTCALL
+NcGetInsideRect(HWND Wnd, RECT *Rect)
+{
+ DWORD Style;
+ DWORD ExStyle;
+
+ GetWindowRect(Wnd, Rect);
+ Rect->right = Rect->right - Rect->left;
+ Rect->left = 0;
+ Rect->bottom = Rect->bottom - Rect->top;
+ Rect->top = 0;
+
+ Style = GetWindowLongW(Wnd, GWL_STYLE);
+ if (0 != (Style & WS_ICONIC))
+ {
+ return;
+ }
+
+ /* Remove frame from rectangle */
+ ExStyle = GetWindowLongW(Wnd, GWL_EXSTYLE);
+ if (HAS_THICKFRAME(Style, ExStyle))
+ {
+ InflateRect(Rect, - GetSystemMetrics(SM_CXFRAME), - GetSystemMetrics(SM_CYFRAME));
+ }
+ else if (HAS_DLGFRAME(Style, ExStyle))
+ {
+ InflateRect(Rect, - GetSystemMetrics(SM_CXDLGFRAME), - GetSystemMetrics(SM_CYDLGFRAME));
+ }
+ else if (HAS_THINFRAME(Style, ExStyle))
+ {
+ InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER));
+ }
+
+ /* We have additional border information if the window
+ * is a child (but not an MDI child) */
+ if (0 != (Style & WS_CHILD)
+ && 0 == (ExStyle & WS_EX_MDICHILD))
+ {
+ if (0 != (ExStyle & WS_EX_CLIENTEDGE))
+ {
+ InflateRect(Rect, - GetSystemMetrics(SM_CXEDGE), - GetSystemMetrics(SM_CYEDGE));
+ }
+ if (0 != (ExStyle & WS_EX_STATICEDGE))
+ {
+ InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER));
+ }
+ }
+}
+
+/***********************************************************************
+ * NcGetSysPopupPos
+ */
+void FASTCALL
+NcGetSysPopupPos(HWND Wnd, RECT *Rect)
+{
+ RECT WindowRect;
+
+ if (IsIconic(Wnd))
+ {
+ GetWindowRect(Wnd, Rect);
+ }
+ else
+ {
+ NcGetInsideRect(Wnd, Rect);
+ GetWindowRect(Wnd, &WindowRect);
+ OffsetRect(Rect, WindowRect.left, WindowRect.top);
+ if (0 != (GetWindowLongW(Wnd, GWL_STYLE) & WS_CHILD))
+ {
+ ClientToScreen(GetParent(Wnd), (POINT *) Rect);
+ }
+ Rect->right = Rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
+ Rect->bottom = Rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
+ }
+}
reactos/lib/user32/windows
diff -u -r1.98 -r1.99
--- window.c 2 Feb 2004 11:46:41 -0000 1.98
+++ window.c 22 Feb 2004 23:40:58 -0000 1.99
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.98 2004/02/02 11:46:41 ea Exp $
+/* $Id: window.c,v 1.99 2004/02/22 23:40:58 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -1465,45 +1465,6 @@
/*
* @implemented
*/
-BOOL
-STDCALL
-SetSystemMenu (
- HWND hwnd,
- HMENU hMenu)
-{
- if(!hwnd)
- {
- SetLastError(ERROR_INVALID_WINDOW_HANDLE);
- return FALSE;
- }
- if(!hMenu)
- {
- SetLastError(ERROR_INVALID_MENU_HANDLE);
- return FALSE;
- }
- return NtUserSetSystemMenu(hwnd, hMenu);
-}
-
-/*
- * @implemented
- */
-HMENU
-STDCALL
-GetSystemMenu(
- HWND hWnd,
- BOOL bRevert)
-{
- if(!hWnd)
- {
- SetLastError(ERROR_INVALID_WINDOW_HANDLE);
- return (HMENU)0;
- }
- return NtUserGetSystemMenu(hWnd, bRevert);
-}
-
-/*
- * @implemented
- */
HWND
STDCALL
GetFocus(VOID)
reactos/subsys/win32k/include
diff -u -r1.27 -r1.28
--- menu.h 15 Feb 2004 07:39:12 -0000 1.27
+++ menu.h 22 Feb 2004 23:40:58 -0000 1.28
@@ -101,6 +101,9 @@
BOOL FASTCALL
IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process);
+BOOL FASTCALL
+IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
+ PROSMENUITEMINFO ItemInfo);
NTSTATUS FASTCALL
reactos/subsys/win32k/ntuser
diff -u -r1.47 -r1.48
--- menu.c 22 Feb 2004 18:04:52 -0000 1.47
+++ menu.c 22 Feb 2004 23:40:58 -0000 1.48
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: menu.c,v 1.47 2004/02/22 18:04:52 gvg Exp $
+/* $Id: menu.c,v 1.48 2004/02/22 23:40:58 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -763,8 +763,8 @@
}
else
{
- FreeMenuText(MenuItem);
- MenuItem->fType = MF_SEPARATOR;
+ MenuItem->fType |= MF_SEPARATOR;
+ RtlInitUnicodeString(&MenuItem->Text, NULL);
}
}
else
@@ -781,7 +781,7 @@
return TRUE;
}
-static BOOL FASTCALL
+BOOL FASTCALL
IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
PROSMENUITEMINFO ItemInfo)
{
reactos/subsys/win32k/ntuser
diff -u -r1.189 -r1.190
--- window.c 22 Feb 2004 15:14:27 -0000 1.189
+++ window.c 22 Feb 2004 23:40:58 -0000 1.190
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: window.c,v 1.189 2004/02/22 15:14:27 navaraf Exp $
+/* $Id: window.c,v 1.190 2004/02/22 23:40:58 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -589,9 +589,10 @@
PMENU_OBJECT FASTCALL
IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu)
{
- PMENU_OBJECT MenuObject, NewMenuObject, ret = NULL;
+ PMENU_OBJECT MenuObject, NewMenuObject, SysMenuObject, ret = NULL;
PW32PROCESS W32Process;
- HMENU NewMenu;
+ HMENU NewMenu, SysMenu;
+ ROSMENUITEMINFO ItemInfo;
if(bRevert)
{
@@ -623,6 +624,7 @@
{
WindowObject->SystemMenu = NewMenuObject->MenuInfo.Self;
NewMenuObject->MenuInfo.Flags |= MF_SYSMENU;
+ NewMenuObject->MenuInfo.Wnd = WindowObject->Self;
ret = NewMenuObject;
//IntReleaseMenuObject(NewMenuObject);
}
@@ -630,20 +632,53 @@
}
else
{
+ SysMenu = NtUserCreateMenu(FALSE);
+ if (NULL == SysMenu)
+ {
+ return NULL;
+ }
+ SysMenuObject = IntGetMenuObject(SysMenu);
+ if (NULL == SysMenuObject)
+ {
+ NtUserDestroyMenu(SysMenu);
+ return NULL;
+ }
+ SysMenuObject->MenuInfo.Flags |= MF_SYSMENU;
+ SysMenuObject->MenuInfo.Wnd = WindowObject->Self;
NewMenu = IntLoadSysMenuTemplate();
if(!NewMenu)
+ {
+ IntReleaseMenuObject(SysMenuObject);
+ NtUserDestroyMenu(SysMenu);
return NULL;
+ }
MenuObject = IntGetMenuObject(NewMenu);
if(!MenuObject)
+ {
+ IntReleaseMenuObject(SysMenuObject);
+ NtUserDestroyMenu(SysMenu);
return NULL;
+ }
NewMenuObject = IntCloneMenu(MenuObject);
if(NewMenuObject)
{
- WindowObject->SystemMenu = NewMenuObject->MenuInfo.Self;
- NewMenuObject->MenuInfo.Flags |= MF_SYSMENU;
- ret = NewMenuObject;
- //IntReleaseMenuObject(NewMenuObject);
+ NewMenuObject->MenuInfo.Flags |= MF_SYSMENU | MF_POPUP;
+ IntReleaseMenuObject(NewMenuObject);
+ NtUserSetMenuDefaultItem(NewMenuObject->MenuInfo.Self, SC_CLOSE, FALSE);
+
+ ItemInfo.cbSize = sizeof(MENUITEMINFOW);
+ ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
+ ItemInfo.fType = MF_POPUP;
+ ItemInfo.fState = MFS_ENABLED;
+ ItemInfo.dwTypeData = NULL;
+ ItemInfo.cch = 0;
+ ItemInfo.hSubMenu = NewMenuObject->MenuInfo.Self;
+ IntInsertMenuItem(SysMenuObject, (UINT) -1, TRUE, &ItemInfo);
+
+ WindowObject->SystemMenu = SysMenuObject->MenuInfo.Self;
+
+ ret = SysMenuObject;
}
IntDestroyMenuObject(MenuObject, FALSE, TRUE);
IntReleaseMenuObject(MenuObject);
@@ -2317,17 +2352,7 @@
MenuObject = IntGetSystemMenu(WindowObject, bRevert, FALSE);
if (MenuObject)
{
- /*
- * Return the handle of the first submenu.
- */
- ExAcquireFastMutexUnsafe(&MenuObject->MenuItemsLock);
- if (MenuObject->MenuItemList)
- {
- Result = MenuObject->MenuItemList->hSubMenu;
- if (!IntIsMenu(Result))
- Result = 0;
- }
- ExReleaseFastMutexUnsafe(&MenuObject->MenuItemsLock);
+ Result = MenuObject->MenuInfo.Self;
IntReleaseMenuObject(MenuObject);
}
reactos
diff -u -r1.217 -r1.218
--- ChangeLog 22 Feb 2004 18:04:52 -0000 1.217
+++ ChangeLog 22 Feb 2004 23:40:58 -0000 1.218
@@ -1,6 +1,7 @@
2004-02-22 Ge van Geldorp <ge@gse.nl>
* Implement keyboard navigation for menus
+ * Implement system menus
2004-02-22 Casper S. Hornstrup <chorns@users.sourceforge.net>
CVSspam 0.2.8