mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 01:52:06 +00:00
[USER32]
Gray close button if SC_CLOSE is disabled is sysmenu or class has CS_NOCLOSE flag See issue #5272 for more details. svn path=/trunk/; revision=51128
This commit is contained in:
parent
fcd25281d9
commit
cd1a61c18f
1 changed files with 19 additions and 13 deletions
|
@ -161,7 +161,7 @@ UserDrawSysMenuButton(HWND hWnd, HDC hDC, LPRECT Rect, BOOL Down)
|
||||||
* - Center the buttons verticaly in the rect
|
* - Center the buttons verticaly in the rect
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
UserDrawCaptionButton(LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDown, ULONG Type)
|
UserDrawCaptionButton(HWND hWnd, LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDown, ULONG Type)
|
||||||
{
|
{
|
||||||
RECT TempRect;
|
RECT TempRect;
|
||||||
|
|
||||||
|
@ -214,6 +214,9 @@ UserDrawCaptionButton(LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDo
|
||||||
}
|
}
|
||||||
case DFCS_CAPTIONCLOSE:
|
case DFCS_CAPTIONCLOSE:
|
||||||
{
|
{
|
||||||
|
HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
|
||||||
|
UINT MenuState = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND); /* in case of error MenuState==0xFFFFFFFF */
|
||||||
|
|
||||||
/* FIXME: A tool window has a smaller Close button */
|
/* FIXME: A tool window has a smaller Close button */
|
||||||
|
|
||||||
if (ExStyle & WS_EX_TOOLWINDOW)
|
if (ExStyle & WS_EX_TOOLWINDOW)
|
||||||
|
@ -231,7 +234,7 @@ UserDrawCaptionButton(LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDo
|
||||||
|
|
||||||
DrawFrameControl(hDC, &TempRect, DFC_CAPTION,
|
DrawFrameControl(hDC, &TempRect, DFC_CAPTION,
|
||||||
(DFCS_CAPTIONCLOSE | (bDown ? DFCS_PUSHED : 0) |
|
(DFCS_CAPTIONCLOSE | (bDown ? DFCS_PUSHED : 0) |
|
||||||
((Style & WS_SYSMENU) ? 0 : DFCS_INACTIVE)));
|
((!(MenuState & (MF_GRAYED|MF_DISABLED)) && !(GetClassLong(hWnd, GCL_STYLE) & CS_NOCLOSE)) ? 0 : DFCS_INACTIVE)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +255,7 @@ UserDrawCaptionButtonWnd(HWND hWnd, HDC hDC, BOOL bDown, ULONG Type)
|
||||||
ExStyle = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);
|
ExStyle = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);
|
||||||
UserGetWindowBorders(Style, ExStyle, &WindowBorder, FALSE);
|
UserGetWindowBorders(Style, ExStyle, &WindowBorder, FALSE);
|
||||||
InflateRect(&WindowRect, -WindowBorder.cx, -WindowBorder.cy);
|
InflateRect(&WindowRect, -WindowBorder.cx, -WindowBorder.cy);
|
||||||
UserDrawCaptionButton(&WindowRect, Style, ExStyle, hDC, bDown, Type);
|
UserDrawCaptionButton(hWnd, &WindowRect, Style, ExStyle, hDC, bDown, Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note from Wine:
|
// Note from Wine:
|
||||||
|
@ -419,11 +422,11 @@ DefWndNCPaint(HWND hWnd, HRGN hRgn, BOOL Active)
|
||||||
/* Draw buttons */
|
/* Draw buttons */
|
||||||
if (Style & WS_SYSMENU)
|
if (Style & WS_SYSMENU)
|
||||||
{
|
{
|
||||||
UserDrawCaptionButton(&TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONCLOSE);
|
UserDrawCaptionButton(hWnd, &TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONCLOSE);
|
||||||
if ((Style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) && !(ExStyle & WS_EX_TOOLWINDOW))
|
if ((Style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) && !(ExStyle & WS_EX_TOOLWINDOW))
|
||||||
{
|
{
|
||||||
UserDrawCaptionButton(&TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONMIN);
|
UserDrawCaptionButton(hWnd, &TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONMIN);
|
||||||
UserDrawCaptionButton(&TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONMAX);
|
UserDrawCaptionButton(hWnd, &TempRect, Style, ExStyle, hDC, FALSE, DFCS_CAPTIONMAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!(Style & WS_MINIMIZE))
|
if(!(Style & WS_MINIMIZE))
|
||||||
|
@ -665,8 +668,8 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
|
||||||
RECT WindowRect, ClientRect, OrigWndRect;
|
RECT WindowRect, ClientRect, OrigWndRect;
|
||||||
POINT ClientPoint;
|
POINT ClientPoint;
|
||||||
SIZE WindowBorders;
|
SIZE WindowBorders;
|
||||||
ULONG Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
|
DWORD Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
|
||||||
ULONG ExStyle = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);
|
DWORD ExStyle = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);
|
||||||
|
|
||||||
GetWindowRect(hWnd, &WindowRect);
|
GetWindowRect(hWnd, &WindowRect);
|
||||||
if (!PtInRect(&WindowRect, Point))
|
if (!PtInRect(&WindowRect, Point))
|
||||||
|
@ -787,8 +790,6 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
|
||||||
|
|
||||||
if(!(Style & WS_MINIMIZE))
|
if(!(Style & WS_MINIMIZE))
|
||||||
{
|
{
|
||||||
HMENU menu;
|
|
||||||
|
|
||||||
ClientPoint = Point;
|
ClientPoint = Point;
|
||||||
ScreenToClient(hWnd, &ClientPoint);
|
ScreenToClient(hWnd, &ClientPoint);
|
||||||
GetClientRect(hWnd, &ClientRect);
|
GetClientRect(hWnd, &ClientRect);
|
||||||
|
@ -798,7 +799,7 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
|
||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((menu = GetMenu(hWnd)) && !(Style & WS_CHILD))
|
if (GetMenu(hWnd) && !(Style & WS_CHILD))
|
||||||
{
|
{
|
||||||
if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
|
if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
|
||||||
return HTMENU;
|
return HTMENU;
|
||||||
|
@ -878,13 +879,18 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
|
||||||
HDC WindowDC;
|
HDC WindowDC;
|
||||||
BOOL Pressed = TRUE, OldState;
|
BOOL Pressed = TRUE, OldState;
|
||||||
WPARAM SCMsg;
|
WPARAM SCMsg;
|
||||||
ULONG ButtonType, Style;
|
HMENU hSysMenu;
|
||||||
|
ULONG ButtonType;
|
||||||
|
DWORD Style;
|
||||||
|
UINT MenuState;
|
||||||
|
|
||||||
Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
|
Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case HTCLOSE:
|
case HTCLOSE:
|
||||||
if (!(Style & WS_SYSMENU))
|
hSysMenu = GetSystemMenu(hWnd, FALSE);
|
||||||
|
MenuState = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND); /* in case of error MenuState==0xFFFFFFFF */
|
||||||
|
if (!(Style & WS_SYSMENU) || (MenuState & (MF_GRAYED|MF_DISABLED)) || (GetClassLongPtrW(hWnd, GCL_STYLE) & CS_NOCLOSE))
|
||||||
return;
|
return;
|
||||||
ButtonType = DFCS_CAPTIONCLOSE;
|
ButtonType = DFCS_CAPTIONCLOSE;
|
||||||
SCMsg = SC_CLOSE;
|
SCMsg = SC_CLOSE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue