From: Santino Mazza smazza@codeweavers.com
--- dlls/user32/tests/dialog.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index 3df1a0eab32..b439b6f08c0 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -2151,6 +2151,25 @@ static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam) return CallNextHookEx(NULL, code, wParam, lParam); }
+static LRESULT CALLBACK msgbox_sysmodal_hook_proc(INT code, WPARAM wParam, LPARAM lParam) +{ + if (code == HCBT_ACTIVATE) + { + HWND msgbox = (HWND)wParam; + LONG exstyles = GetWindowLongA(msgbox, GWL_EXSTYLE); + + if (msgbox) + { + todo_wine ok(exstyles & WS_EX_TOPMOST, "expected message box to have topmost exstyle set\n"); + + SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0); + SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONUP, 0, 0); + } + } + + return CallNextHookEx(NULL, code, wParam, lParam); +} + static void test_MessageBox(void) { HHOOK hook; @@ -2162,6 +2181,13 @@ static void test_MessageBox(void) ok(ret == IDCANCEL, "got %d\n", ret);
UnhookWindowsHookEx(hook); + + /* Test for MB_SYSTEMMODAL */ + hook = SetWindowsHookExA(WH_CBT, msgbox_sysmodal_hook_proc, NULL, GetCurrentThreadId()); + + MessageBoxA(NULL, NULL, "system modal", MB_OKCANCEL | MB_SYSTEMMODAL); + + UnhookWindowsHookEx(hook); }
static INT_PTR CALLBACK custom_test_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
From: Santino Mazza smazza@codeweavers.com
--- dlls/user32/msgbox.c | 10 ++++++---- dlls/user32/tests/dialog.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/msgbox.c b/dlls/user32/msgbox.c index cc53ab0457e..22ddc30efed 100644 --- a/dlls/user32/msgbox.c +++ b/dlls/user32/msgbox.c @@ -109,6 +109,12 @@ static void MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb) lpszText = lpmb->lpszText; }
+ /* handle modal message boxes */ + if (((lpmb->dwStyle & MB_TASKMODAL) && (lpmb->hwndOwner==NULL))) + NtUserSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ); + else if (lpmb->dwStyle & MB_SYSTEMMODAL) + NtUserSetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED ); + TRACE_(msgbox)("%s\n", debugstr_w(lpszText)); SetWindowTextW(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText);
@@ -309,10 +315,6 @@ static void MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb) } }
- /*handle modal message boxes*/ - if (((lpmb->dwStyle & MB_TASKMODAL) && (lpmb->hwndOwner==NULL)) || (lpmb->dwStyle & MB_SYSTEMMODAL)) - NtUserSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ); - HeapFree( GetProcessHeap(), 0, buffer ); }
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index b439b6f08c0..21958ddb193 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -2160,7 +2160,7 @@ static LRESULT CALLBACK msgbox_sysmodal_hook_proc(INT code, WPARAM wParam, LPARA
if (msgbox) { - todo_wine ok(exstyles & WS_EX_TOPMOST, "expected message box to have topmost exstyle set\n"); + ok(exstyles & WS_EX_TOPMOST, "expected message box to have topmost exstyle set\n");
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0); SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONUP, 0, 0);
This merge request was approved by Huw Davies.