Patch by Dmitry Timoshkov dmitry@baikal.ru. Take into account CS_NOCLOSE window class style and SC_CLOSE system menu item state while adding MDI system menu buttons and generating WM_SYSCOMMAND messages.

svn path=/trunk/; revision=16890
This commit is contained in:
James Tabor 2005-07-29 23:37:11 +00:00
parent 8fe920ee49
commit af30e6342b

View file

@ -264,6 +264,20 @@ static MDICLIENTINFO *get_client_info( HWND client )
#endif #endif
} }
static BOOL is_close_enabled(HWND hwnd, HMENU hSysMenu)
{
if (GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) return FALSE;
if (!hSysMenu) hSysMenu = GetSystemMenu(hwnd, FALSE);
if (hSysMenu)
{
UINT state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED)))
return FALSE;
}
return TRUE;
}
/********************************************************************** /**********************************************************************
* MDI_MenuModifyItem * MDI_MenuModifyItem
*/ */
@ -1108,13 +1122,13 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild )
if (!(hSysPopup = GetSystemMenu(hChild, FALSE))) if (!(hSysPopup = GetSystemMenu(hChild, FALSE)))
return 0; return 0;
AppendMenuA(menu,MF_HELP | MF_BITMAP, AppendMenuW(menu, MF_HELP | MF_BITMAP,
SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ; SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ;
AppendMenuA(menu,MF_HELP | MF_BITMAP, AppendMenuW(menu, MF_HELP | MF_BITMAP,
SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE ); SC_RESTORE, (LPCWSTR)HBMMENU_MBAR_RESTORE );
AppendMenuW(menu, MF_HELP | MF_BITMAP,
AppendMenuA(menu,MF_HELP | MF_BITMAP, SC_CLOSE, is_close_enabled(hChild, hSysPopup) ?
SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE ); (LPCWSTR)HBMMENU_MBAR_CLOSE : (LPCWSTR)HBMMENU_MBAR_CLOSE_D );
/* The system menu is replaced by the child icon */ /* The system menu is replaced by the child icon */
hIcon = (HICON)GetClassLongW(hChild, GCL_HICONSM); hIcon = (HICON)GetClassLongW(hChild, GCL_HICONSM);
@ -1612,13 +1626,14 @@ LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient,
if( !ci->hwndChildMaximized ) break; if( !ci->hwndChildMaximized ) break;
switch( id ) switch( id )
{ {
case SC_CLOSE:
if (!is_close_enabled(ci->hwndActiveChild, 0)) break;
case SC_SIZE: case SC_SIZE:
case SC_MOVE: case SC_MOVE:
case SC_MINIMIZE: case SC_MINIMIZE:
case SC_MAXIMIZE: case SC_MAXIMIZE:
case SC_NEXTWINDOW: case SC_NEXTWINDOW:
case SC_PREVWINDOW: case SC_PREVWINDOW:
case SC_CLOSE:
case SC_RESTORE: case SC_RESTORE:
return SendMessageW( ci->hwndChildMaximized, WM_SYSCOMMAND, return SendMessageW( ci->hwndChildMaximized, WM_SYSCOMMAND,
wParam, lParam); wParam, lParam);
@ -2033,8 +2048,12 @@ BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg )
break; break;
case VK_F4: case VK_F4:
case VK_RBUTTON: case VK_RBUTTON:
wParam = SC_CLOSE; if (is_close_enabled(ci->hwndActiveChild, 0))
break; {
wParam = SC_CLOSE;
break;
}
/* fall through */
default: default:
return 0; return 0;
} }