user32: Fix DefWindowProc behavior on WM_NCRBUTTONDOWN message.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-08-26 17:53:17 +02:00 committed by Alexandre Julliard
parent ae7398e3a4
commit 1c73fcdbcb
2 changed files with 41 additions and 4 deletions

View File

@ -1487,8 +1487,6 @@ LRESULT NC_HandleNCRButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
{
case HTCAPTION:
case HTSYSMENU:
if (!GetSystemMenu( hwnd, FALSE )) break;
SetCapture( hwnd );
for (;;)
{
@ -1502,7 +1500,7 @@ LRESULT NC_HandleNCRButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam )
}
ReleaseCapture();
if (hittest == HTCAPTION || hittest == HTSYSMENU)
SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, msg.lParam );
SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, MAKELPARAM(msg.pt.x, msg.pt.y));
break;
}
return 0;

View File

@ -8199,6 +8199,12 @@ static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
return 0;
}
if (message == WM_CONTEXTMENU)
{
/* don't create context menu */
return 0;
}
defwndproc_counter++;
ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
: DefWindowProcA(hwnd, message, wParam, lParam);
@ -13887,13 +13893,46 @@ static void test_paintingloop(void)
DestroyWindow(hwnd);
}
static const struct message NCRBUTTONDOWNSeq[] =
{
{ EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
{ EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
{ WM_CAPTURECHANGED, sent },
{ WM_CONTEXTMENU, sent, /*hwnd*/0, -1 },
{ 0 }
};
static void test_defwinproc(void)
{
HWND hwnd;
MSG msg;
BOOL gotwmquit = FALSE;
hwnd = CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP, 0,0,0,0,0,0,0, NULL);
POINT pos;
RECT rect;
INT x, y;
LRESULT res;
hwnd = CreateWindowExA(0, "TestWindowClass", "test_defwndproc",
WS_VISIBLE | WS_CAPTION | WS_OVERLAPPEDWINDOW, 0,0,500,100,0,0,0, NULL);
assert(hwnd);
flush_events();
GetCursorPos(&pos);
GetWindowRect(hwnd, &rect);
x = (rect.left+rect.right) / 2;
y = rect.top + GetSystemMetrics(SM_CYFRAME) + 1;
SetCursorPos(x, y);
flush_events();
res = DefWindowProcA( hwnd, WM_NCHITTEST, 0, MAKELPARAM(x, y));
ok(res == HTCAPTION, "WM_NCHITTEST returned %ld\n", res);
flush_sequence();
PostMessageA( hwnd, WM_RBUTTONUP, 0, 0);
DefWindowProcA( hwnd, WM_NCRBUTTONDOWN, HTCAPTION, MAKELPARAM(x, y));
ok_sequence(NCRBUTTONDOWNSeq, "WM_NCRBUTTONDOWN on caption", FALSE);
SetCursorPos(pos.x, pos.y);
DefWindowProcA( hwnd, WM_ENDSESSION, 1, 0);
while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) {
if( msg.message == WM_QUIT) gotwmquit = TRUE;