[PATCH] user32/msgbox: Fix static control id

Nikolay Sivov nsivov at codeweavers.com
Sun May 7 09:49:59 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

For https://bugs.winehq.org/show_bug.cgi?id=34977

 dlls/user32/msgbox.c       |  5 +----
 dlls/user32/resources.h    |  2 +-
 dlls/user32/tests/dialog.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/msgbox.c b/dlls/user32/msgbox.c
index 0839f97dcb..d3d11d6ceb 100644
--- a/dlls/user32/msgbox.c
+++ b/dlls/user32/msgbox.c
@@ -28,15 +28,12 @@
 #include "winternl.h"
 #include "dlgs.h"
 #include "user_private.h"
+#include "resources.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
 WINE_DECLARE_DEBUG_CHANNEL(msgbox);
 
-#define MSGBOX_IDICON stc1
-#define MSGBOX_IDTEXT 100
-#define IDS_ERROR     2
-
 struct ThreadWindows
 {
     UINT numHandles;
diff --git a/dlls/user32/resources.h b/dlls/user32/resources.h
index d9cc9ccd11..3cb8c48ae4 100644
--- a/dlls/user32/resources.h
+++ b/dlls/user32/resources.h
@@ -26,5 +26,5 @@
 #define MDI_IDC_LISTBOX         100
 #define IDS_MDI_MOREWINDOWS     13
 #define MSGBOX_IDICON           stc1
-#define MSGBOX_IDTEXT           100
+#define MSGBOX_IDTEXT           0xffff
 #define IDS_ERROR               2
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index a37c6780a6..6b9d7046aa 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -1522,6 +1522,47 @@ static void test_timer_message(void)
     DialogBoxA(g_hinst, "RADIO_TEST_DIALOG", NULL, timer_message_dlg_proc);
 }
 
+static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
+{
+    if (code == HCBT_ACTIVATE)
+    {
+        HWND msgbox = (HWND)wParam, msghwnd;
+        char text[64];
+
+        if (msgbox)
+        {
+            text[0] = 0;
+            GetWindowTextA(msgbox, text, sizeof(text));
+            ok(!strcmp(text, "MSGBOX caption"), "Unexpected window text \"%s\"\n", text);
+
+            msghwnd = GetDlgItem(msgbox, 0xffff);
+            ok(msghwnd != NULL, "Expected static control\n");
+
+            text[0] = 0;
+            GetWindowTextA(msghwnd, text, sizeof(text));
+            ok(!strcmp(text, "Text"), "Unexpected window text \"%s\"\n", text);
+
+            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;
+    int ret;
+
+    hook = SetWindowsHookExA(WH_CBT, msgbox_hook_proc, NULL, GetCurrentThreadId());
+
+    ret = MessageBoxA(NULL, "Text", "MSGBOX caption", MB_OKCANCEL);
+    ok(ret == IDCANCEL, "got %d\n", ret);
+
+    UnhookWindowsHookEx(hook);
+}
+
 START_TEST(dialog)
 {
     g_hinst = GetModuleHandleA (0);
@@ -1539,4 +1580,5 @@ START_TEST(dialog)
     test_MessageBoxFontTest();
     test_SaveRestoreFocus();
     test_timer_message();
+    test_MessageBox();
 }
-- 
2.11.0




More information about the wine-patches mailing list