Module: wine Branch: master Commit: 0739aa610cc073beb0cf32dbaf8c2a8a83aa1ecd URL: https://gitlab.winehq.org/wine/wine/-/commit/0739aa610cc073beb0cf32dbaf8c2a8...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Aug 19 20:50:41 2022 +0200
user32: Pass resource ID as a string in DIALOG_CreateControls32.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53566
---
dlls/user32/dialog.c | 23 ++++++++++++++++- dlls/user32/tests/dialog.c | 59 +++++++++++++++++++++++++++++++++++++++++++ dlls/user32/tests/resource.rc | 10 ++++++++ 3 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index c8d1596a01b..fc7ddb303ff 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -220,8 +220,19 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL } if (unicode) { + const WCHAR *caption = info.windowName; + WCHAR caption_buf[3]; + + if (IS_INTRESOURCE(caption) && caption) + { + caption_buf[0] = 0xffff; + caption_buf[1] = PtrToUlong( caption ); + caption_buf[2] = 0; + caption = caption_buf; + } + hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, - info.className, info.windowName, + info.className, caption, info.style | WS_CHILD, MulDiv(info.x, dlgInfo->xBaseUnit, 4), MulDiv(info.y, dlgInfo->yBaseUnit, 8), @@ -236,6 +247,7 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL LPCSTR caption = (LPCSTR)info.windowName; LPSTR class_tmp = NULL; LPSTR caption_tmp = NULL; + char caption_buf[4];
if (!IS_INTRESOURCE(class)) { @@ -251,6 +263,15 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, caption_tmp, len, NULL, NULL ); caption = caption_tmp; } + else if (caption) + { + caption_buf[0] = 0xff; + caption_buf[1] = PtrToUlong( caption ); + caption_buf[2] = PtrToUlong( caption ) >> 8; + caption_buf[3] = 0; + caption = caption_buf; + } + hwndCtrl = CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY, class, caption, info.style | WS_CHILD, MulDiv(info.x, dlgInfo->xBaseUnit, 4), diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index 0ac1d48a375..3df1a0eab32 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -2260,6 +2260,64 @@ static void test_capture_release(void) DestroyWindow(window); }
+static WNDPROC orig_static_proc; +static WCHAR cs_name_paramW[3]; +static char cs_name_paramA[4]; + +static LRESULT WINAPI test_static_create_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if (msg == WM_NCCREATE) + { + CREATESTRUCTW *cs = (CREATESTRUCTW *)lparam; + memcpy( cs_name_paramW, cs->lpszName, sizeof(cs_name_paramW) ); + } + + return orig_static_proc(hwnd, msg, wparam, lparam); +} + +static LRESULT WINAPI test_static_create_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if (msg == WM_NCCREATE) + { + CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam; + memcpy( cs_name_paramA, cs->lpszName, sizeof(cs_name_paramA) ); + } + + return orig_static_proc(hwnd, msg, wparam, lparam); +} + +static void test_create_controls(void) +{ + HWND control; + INT_PTR ret; + + control = CreateWindowA("static", "", 0, 100, 200, 300, 400, NULL, NULL, NULL, NULL); + ok(control != 0, "failed to create control window\n"); + + orig_static_proc = (WNDPROC)SetClassLongPtrA(control, GCLP_WNDPROC, (ULONG_PTR)test_static_create_procA); + + cs_name_paramW[0] = 0; + ret = DialogBoxParamA(GetModuleHandleA(NULL), "IDD_SS_ICON_DIALOG", 0, DestroyOnCloseDlgWinProc, 0); + ok(0 == ret, "DialogBoxParamA returned %Id, expected 0\n", ret); + ok(!memcmp(cs_name_paramA, "\xff\0\x61", 3), "name param = %s\n", debugstr_an(cs_name_paramA, 3)); + + SetClassLongPtrA(control, GCLP_WNDPROC, (ULONG_PTR)orig_static_proc); + DestroyWindow(control); + + control = CreateWindowW(L"static", L"", 0, 100, 200, 300, 400, NULL, NULL, NULL, NULL); + ok(control != 0, "failed to create control window\n"); + + orig_static_proc = (WNDPROC)SetClassLongPtrW(control, GCLP_WNDPROC, (ULONG_PTR)test_static_create_procW); + + ret = DialogBoxParamW(GetModuleHandleW(NULL), L"IDD_SS_ICON_DIALOG", 0, DestroyOnCloseDlgWinProc, 0); + ok(0 == ret, "DialogBoxParamW returned %Id, expected 0\n", ret); + ok(!memcmp(cs_name_paramW, L"\xffff\x6100", 2 * sizeof(WCHAR)), + "name param = %s\n", debugstr_wn(cs_name_paramW, 2)); + + SetClassLongPtrW(control, GCLP_WNDPROC, (ULONG_PTR)orig_static_proc); + DestroyWindow(control); +} + START_TEST(dialog) { g_hinst = GetModuleHandleA (0); @@ -2273,6 +2331,7 @@ START_TEST(dialog) test_focus(); test_GetDlgItem(); test_GetDlgItemText(); + test_create_controls(); test_DialogBoxParam(); test_DisabledDialogTest(); test_MessageBoxFontTest(); diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc index 89aaf5a61c5..a957e50689d 100644 --- a/dlls/user32/tests/resource.rc +++ b/dlls/user32/tests/resource.rc @@ -276,3 +276,13 @@ FONT 8, "MS Shell Dlg" } MENUITEM "&Quit", 300 } + +IDD_SS_ICON_DIALOG DIALOG 0, 0, 186, 95 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL 0x6100, 1003, "STATIC", SS_ICON | WS_CHILD | WS_VISIBLE, 7, 57, 21, 20 + DEFPUSHBUTTON "OK",IDOK,129,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 +END