Module: wine Branch: master Commit: 2429ef905c46aec91465ac187c5f0b528cd35612 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2429ef905c46aec91465ac187c...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Tue Nov 15 15:27:13 2011 +0800
user32: Dialog creation code should force WS_CHILD style for dialog controls.
---
dlls/user32/dialog.c | 4 +++- dlls/user32/tests/dialog.c | 41 +++++++++++++++++++++++++++++++++++++++++ dlls/user32/tests/resource.rc | 10 ++++++++++ 3 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index 1e47374..7643241 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -263,7 +263,9 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL { template = (LPCSTR)DIALOG_GetControl32( (const WORD *)template, &info, dlgTemplate->dialogEx ); - /* Is this it? */ + info.style &= ~WS_POPUP; + info.style |= WS_CHILD; + if (info.style & WS_BORDER) { info.style &= ~WS_BORDER; diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index f749278..a716f79 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -33,6 +33,8 @@ #include <stdio.h> #include <stdarg.h>
+#define WINVER 0x0600 /* For NONCLIENTMETRICS with padding */ + #include "wine/test.h" #include "windef.h" #include "winbase.h" @@ -1058,11 +1060,50 @@ static INT_PTR CALLBACK TestReturnKeyDlgProc (HWND hDlg, UINT uiMsg, return FALSE; }
+static INT_PTR CALLBACK TestControlStyleDlgProc(HWND hdlg, UINT msg, + WPARAM wparam, LPARAM lparam) +{ + HWND control; + DWORD style, exstyle; + char buf[256]; + + switch (msg) + { + case WM_INITDIALOG: + control = GetDlgItem(hdlg, 7); + ok(control != 0, "dialog control with id 7 not found\n"); + style = GetWindowLong(control, GWL_STYLE); + ok(style == (WS_CHILD|WS_VISIBLE), "expected WS_CHILD|WS_VISIBLE, got %#x\n", style); + exstyle = GetWindowLong(control, GWL_EXSTYLE); + ok(exstyle == (WS_EX_NOPARENTNOTIFY|WS_EX_TRANSPARENT|WS_EX_CLIENTEDGE), "expected WS_EX_NOPARENTNOTIFY|WS_EX_TRANSPARENT|WS_EX_CLIENTEDGE, got %#x\n", exstyle); + buf[0] = 0; + GetWindowText(control, buf, sizeof(buf)); + ok(lstrcmp(buf, "bump7") == 0, "expected bump7, got %s\n", buf); + + control = GetDlgItem(hdlg, 8); + ok(control != 0, "dialog control with id 8 not found\n"); + style = GetWindowLong(control, GWL_STYLE); + ok(style == (WS_CHILD|WS_VISIBLE), "expected WS_CHILD|WS_VISIBLE, got %#x\n", style); + exstyle = GetWindowLong(control, GWL_EXSTYLE); + ok(exstyle == (WS_EX_NOPARENTNOTIFY|WS_EX_TRANSPARENT), "expected WS_EX_NOPARENTNOTIFY|WS_EX_TRANSPARENT, got %#x\n", exstyle); + buf[0] = 0; + GetWindowText(control, buf, sizeof(buf)); + ok(lstrcmp(buf, "bump8") == 0, "expected bump8, got %s\n", buf); + + EndDialog(hdlg, -7); + return TRUE; + } + return FALSE; +} + static void test_DialogBoxParamA(void) { INT_PTR ret; HWND hwnd_invalid = (HWND)0x4444;
+ ret = DialogBoxParamA(GetModuleHandle(0), "TEST_DLG_CHILD_POPUP", 0, TestControlStyleDlgProc, 0); + ok(ret == -7, "expected -7, got %ld\n", ret); + SetLastError(0xdeadbeef); ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG" , hwnd_invalid, 0 , 0); ok(0 == ret || broken(ret == -1), "DialogBoxParamA returned %ld, expected 0\n", ret); diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc index 4341710..cce1478 100644 --- a/dlls/user32/tests/resource.rc +++ b/dlls/user32/tests/resource.rc @@ -45,6 +45,16 @@ STRINGTABLE 65534 "Test high id" }
+/* Test dialog with a mixed style WS_CHILD | WS_POPUP control */ +TEST_DLG_CHILD_POPUP DIALOG 0, 0, 60, 30 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Test dialog with mixed style controls" +FONT 8, "MS Shell Dlg" +{ + CONTROL "bump7",7,"static",WS_CHILD|WS_POPUP|WS_BORDER,0,0,40,10,WS_EX_TRANSPARENT + CONTROL "bump8",8,"static",WS_POPUP,0,10,40,10,WS_EX_TRANSPARENT +} + TEST_DIALOG DIALOG 0, 0, 60, 30 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE CAPTION "Test dialog"