mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 06:57:08 +00:00
- Cleanup DefWndDoButton function.
- Fix some loops where GetMessage was inadvertently used. svn path=/trunk/; revision=14247
This commit is contained in:
parent
3a6ab460dd
commit
2315100314
|
@ -317,7 +317,8 @@ DefWndStartSizeMove(HWND hWnd, WPARAM wParam, POINT *capturePoint)
|
|||
{
|
||||
while(!hittest)
|
||||
{
|
||||
GetMessageW(&msg, NULL, 0, 0);
|
||||
if (GetMessageW(&msg, NULL, 0, 0) <= 0)
|
||||
break;
|
||||
switch(msg.message)
|
||||
{
|
||||
case WM_MOUSEMOVE:
|
||||
|
@ -572,7 +573,8 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
|
|||
{
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
GetMessageW(&msg, 0, 0, 0);
|
||||
if (GetMessageW(&msg, 0, 0, 0) <= 0)
|
||||
break;
|
||||
|
||||
/* Exit on button-up, Return, or Esc */
|
||||
if ((msg.message == WM_LBUTTONUP) ||
|
||||
|
|
|
@ -882,79 +882,75 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
|
|||
VOID
|
||||
DefWndDoButton(HWND hWnd, WPARAM wParam)
|
||||
{
|
||||
MSG Msg;
|
||||
BOOL InBtn, HasBtn = FALSE;
|
||||
ULONG Btn, Style;
|
||||
WPARAM SCMsg, CurBtn = wParam, OrigBtn = wParam;
|
||||
HDC WindowDC = NULL;
|
||||
MSG Msg;
|
||||
HDC WindowDC;
|
||||
BOOL Pressed = TRUE, OldState;
|
||||
WPARAM SCMsg;
|
||||
ULONG ButtonType, Style;
|
||||
|
||||
Style = GetWindowLongW(hWnd, GWL_STYLE);
|
||||
switch(wParam)
|
||||
{
|
||||
case HTCLOSE:
|
||||
Btn = DFCS_CAPTIONCLOSE;
|
||||
SCMsg = SC_CLOSE;
|
||||
HasBtn = (Style & WS_SYSMENU);
|
||||
break;
|
||||
case HTMINBUTTON:
|
||||
Btn = DFCS_CAPTIONMIN;
|
||||
SCMsg = ((Style & WS_MINIMIZE) ? SC_RESTORE : SC_MINIMIZE);
|
||||
HasBtn = (Style & WS_MINIMIZEBOX);
|
||||
break;
|
||||
case HTMAXBUTTON:
|
||||
Btn = DFCS_CAPTIONMAX;
|
||||
SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE);
|
||||
HasBtn = (Style & WS_MAXIMIZEBOX);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
Style = GetWindowLongW(hWnd, GWL_STYLE);
|
||||
switch (wParam)
|
||||
{
|
||||
case HTCLOSE:
|
||||
if (!(Style & WS_SYSMENU))
|
||||
return;
|
||||
ButtonType = DFCS_CAPTIONCLOSE;
|
||||
SCMsg = SC_CLOSE;
|
||||
break;
|
||||
case HTMINBUTTON:
|
||||
if (!(Style & WS_MINIMIZEBOX))
|
||||
return;
|
||||
ButtonType = DFCS_CAPTIONMIN;
|
||||
SCMsg = ((Style & WS_MINIMIZE) ? SC_RESTORE : SC_MINIMIZE);
|
||||
break;
|
||||
case HTMAXBUTTON:
|
||||
if (!(Style & WS_MAXIMIZEBOX))
|
||||
return;
|
||||
ButtonType = DFCS_CAPTIONMAX;
|
||||
SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE);
|
||||
break;
|
||||
|
||||
InBtn = HasBtn;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
SetCapture(hWnd);
|
||||
/*
|
||||
* FIXME: Not sure where to do this, but we must flush the pending
|
||||
* window updates when someone clicks on the close button and at
|
||||
* the same time the window is overlapped with another one. This
|
||||
* looks like a good place for now...
|
||||
*/
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
if(HasBtn)
|
||||
{
|
||||
WindowDC = GetWindowDC(hWnd);
|
||||
UserDrawCaptionButtonWnd(hWnd, WindowDC, HasBtn , Btn);
|
||||
}
|
||||
WindowDC = GetWindowDC(hWnd);
|
||||
UserDrawCaptionButtonWnd(hWnd, WindowDC, TRUE, ButtonType);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
GetMessageW(&Msg, 0, 0, 0);
|
||||
switch(Msg.message)
|
||||
{
|
||||
case WM_LBUTTONUP:
|
||||
if(InBtn)
|
||||
goto done;
|
||||
else
|
||||
{
|
||||
ReleaseCapture();
|
||||
if (HasBtn)
|
||||
ReleaseDC(hWnd, WindowDC);
|
||||
return;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
if(HasBtn)
|
||||
{
|
||||
CurBtn = DefWndNCHitTest(hWnd, Msg.pt);
|
||||
if(InBtn != (CurBtn == OrigBtn))
|
||||
{
|
||||
UserDrawCaptionButtonWnd( hWnd, WindowDC, (CurBtn == OrigBtn) , Btn);
|
||||
}
|
||||
InBtn = CurBtn == OrigBtn;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetCapture(hWnd);
|
||||
|
||||
done:
|
||||
UserDrawCaptionButtonWnd( hWnd, WindowDC, FALSE , Btn);
|
||||
ReleaseDC(hWnd, WindowDC);
|
||||
ReleaseCapture();
|
||||
SendMessageW(hWnd, WM_SYSCOMMAND, SCMsg, 0);
|
||||
return;
|
||||
for (;;)
|
||||
{
|
||||
if (GetMessageW(&Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST) <= 0)
|
||||
break;
|
||||
|
||||
if (Msg.message == WM_LBUTTONUP)
|
||||
break;
|
||||
|
||||
if (Msg.message != WM_MOUSEMOVE)
|
||||
continue;
|
||||
|
||||
OldState = Pressed;
|
||||
Pressed = (DefWndNCHitTest(hWnd, Msg.pt) == wParam);
|
||||
if (Pressed != OldState)
|
||||
UserDrawCaptionButtonWnd(hWnd, WindowDC, Pressed, ButtonType);
|
||||
}
|
||||
|
||||
if (Pressed)
|
||||
UserDrawCaptionButtonWnd(hWnd, WindowDC, FALSE, ButtonType);
|
||||
ReleaseCapture();
|
||||
ReleaseDC(hWnd, WindowDC);
|
||||
if (Pressed)
|
||||
SendMessageW(hWnd, WM_SYSCOMMAND, SCMsg, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue