Author: jimtabor
Date: Fri Apr 4 14:49:22 2014
New Revision: 62610
URL:
http://svn.reactos.org/svn/reactos?rev=62610&view=rev
Log:
[User32]
- Patch by Piotr Caban : Make it possible to activate a window with parent and no WS_CHILD
flag in WS_NCLBUTTONDOWN function.
- Sync port from wine with modifications and addons.
Modified:
trunk/reactos/win32ss/user/user32/windows/nonclient.c
Modified: trunk/reactos/win32ss/user/user32/windows/nonclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/nonclient.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/nonclient.c [iso-8859-1] Fri Apr 4 14:49:22
2014
@@ -980,26 +980,44 @@
LRESULT
DefWndNCLButtonDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
+ PWND Wnd = ValidateHwnd(hWnd);
+
switch (wParam)
{
case HTCAPTION:
{
- HWND hTopWnd = GetAncestor(hWnd, GA_ROOT);
- if ( NtUserCallHwndLock(hTopWnd, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOWMOUSE) ||
- GetActiveWindow() == hTopWnd)
- {
- SendMessageW(hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam);
- }
- break;
+ HWND hTopWnd = hWnd, parent;
+ while(1)
+ {
+ if ((GetWindowLongW( hTopWnd, GWL_STYLE ) & (WS_POPUP|WS_CHILD)) !=
WS_CHILD)
+ break;
+ parent = GetAncestor( hTopWnd, GA_PARENT );
+ if (!parent || parent == GetDesktopWindow()) break;
+ hTopWnd = parent;
+ }
+
+ if ( NtUserCallHwndLock(hTopWnd, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOWMOUSE)
||
+ GetActiveWindow() == hTopWnd)
+ {
+ SendMessageW(hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam);
+ }
+ break;
}
case HTSYSMENU:
{
LONG style = GetWindowLongPtrW( hWnd, GWL_STYLE );
if (style & WS_SYSMENU)
- {
- SendMessageW(hWnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU,
- lParam);
- }
+ {
+ if( Wnd && !(style & WS_MINIMIZE) )
+ {
+ RECT rect;
+ HDC hDC = GetWindowDC(hWnd);
+ UserGetInsideRectNC(Wnd, &rect);
+ UserDrawSysMenuButton(hWnd, hDC, &rect, TRUE);
+ ReleaseDC( hWnd, hDC );
+ }
+ SendMessageW(hWnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, lParam);
+ }
break;
}
case HTMENU:
@@ -1070,7 +1088,14 @@
}
case HTSYSMENU:
{
- SendMessageW(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+ HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
+ UINT state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
+
+ /* If the close item of the sysmenu is disabled or not present do nothing */
+ if ((state & (MF_DISABLED | MF_GRAYED)) || (state == 0xFFFFFFFF))
+ break;
+
+ SendMessageW(hWnd, WM_SYSCOMMAND, SC_CLOSE, lParam);
break;
}
default: