user32: Dialog creation code should force WS_CHILD style for dialog controls.

This commit is contained in:
Dmitry Timoshkov 2011-11-15 15:27:13 +08:00 committed by Alexandre Julliard
parent 50d37fe0ab
commit 2429ef905c
3 changed files with 54 additions and 1 deletions

View File

@ -263,7 +263,9 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
{ {
template = (LPCSTR)DIALOG_GetControl32( (const WORD *)template, &info, template = (LPCSTR)DIALOG_GetControl32( (const WORD *)template, &info,
dlgTemplate->dialogEx ); dlgTemplate->dialogEx );
/* Is this it? */ info.style &= ~WS_POPUP;
info.style |= WS_CHILD;
if (info.style & WS_BORDER) if (info.style & WS_BORDER)
{ {
info.style &= ~WS_BORDER; info.style &= ~WS_BORDER;

View File

@ -33,6 +33,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#define WINVER 0x0600 /* For NONCLIENTMETRICS with padding */
#include "wine/test.h" #include "wine/test.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
@ -1058,11 +1060,50 @@ static INT_PTR CALLBACK TestReturnKeyDlgProc (HWND hDlg, UINT uiMsg,
return FALSE; 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) static void test_DialogBoxParamA(void)
{ {
INT_PTR ret; INT_PTR ret;
HWND hwnd_invalid = (HWND)0x4444; 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); SetLastError(0xdeadbeef);
ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG" , hwnd_invalid, 0 , 0); ret = DialogBoxParamA(GetModuleHandle(NULL), "IDD_DIALOG" , hwnd_invalid, 0 , 0);
ok(0 == ret || broken(ret == -1), "DialogBoxParamA returned %ld, expected 0\n", ret); ok(0 == ret || broken(ret == -1), "DialogBoxParamA returned %ld, expected 0\n", ret);

View File

@ -45,6 +45,16 @@ STRINGTABLE
65534 "Test high id" 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 TEST_DIALOG DIALOG 0, 0, 60, 30
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
CAPTION "Test dialog" CAPTION "Test dialog"