user32: Send WM_CANCELMODE to the current capture window after initializing a modal dialog.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48860
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-01-06 22:49:48 -06:00 committed by Alexandre Julliard
parent c75e065288
commit 32f5dfde0d
2 changed files with 8 additions and 3 deletions

View File

@ -667,6 +667,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
if (DIALOG_CreateControls32( hwnd, dlgTemplate, &template, hInst, unicode )) if (DIALOG_CreateControls32( hwnd, dlgTemplate, &template, hInst, unicode ))
{ {
HWND capture;
/* Send initialisation messages and set focus */ /* Send initialisation messages and set focus */
if (dlgProc) if (dlgProc)
@ -695,6 +697,9 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
} }
} }
if (modal_owner && (capture = GetCapture()))
SendMessageW( capture, WM_CANCELMODE, 0, 0 );
if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
{ {
ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */ ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */

View File

@ -2192,7 +2192,7 @@ static INT_PTR CALLBACK capture_release_proc(HWND dialog, UINT message, WPARAM w
HWND child = (HWND)lparam; HWND child = (HWND)lparam;
DWORD style; DWORD style;
todo_wine ok(!GetCapture(), "got capture %p\n", GetCapture()); ok(!GetCapture(), "got capture %p\n", GetCapture());
style = GetWindowLongA(child, GWL_STYLE); style = GetWindowLongA(child, GWL_STYLE);
ok(!(style & WS_DISABLED), "child should not be disabled\n"); ok(!(style & WS_DISABLED), "child should not be disabled\n");
@ -2233,12 +2233,12 @@ static void test_capture_release(void)
SetCapture(child); SetCapture(child);
ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", NULL, capture_release_proc, (LPARAM)child); ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", NULL, capture_release_proc, (LPARAM)child);
ok(ret == 1, "got %#Ix\n", ret); ok(ret == 1, "got %#Ix\n", ret);
todo_wine ok(!GetCapture(), "got capture %p\n", GetCapture()); ok(!GetCapture(), "got capture %p\n", GetCapture());
SetCapture(child); SetCapture(child);
ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", window, capture_release_proc, (LPARAM)child); ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", window, capture_release_proc, (LPARAM)child);
ok(ret == 1, "got %#Ix\n", ret); ok(ret == 1, "got %#Ix\n", ret);
todo_wine ok(!GetCapture(), "got capture %p\n", GetCapture()); ok(!GetCapture(), "got capture %p\n", GetCapture());
SetCapture(child); SetCapture(child);
dialog = CreateDialogParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", dialog = CreateDialogParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG",