Index: apitests/user32/CMakeLists.txt
===================================================================
--- apitests/user32/CMakeLists.txt	(Revision 67545)
+++ apitests/user32/CMakeLists.txt	(Arbeitskopie)
@@ -4,6 +4,8 @@
     helper.c
     CreateDialog.c
     CreateIconFromResourceEx.c
+    CreateWndDlgHelper.c
+    CreateWindow.c
     DeferWindowPos.c
     DestroyCursorIcon.c
     DrawIconEx.c
Index: apitests/user32/CreateDialog.c
===================================================================
--- apitests/user32/CreateDialog.c	(Revision 67545)
+++ apitests/user32/CreateDialog.c	(Arbeitskopie)
@@ -12,194 +12,222 @@
 #include <wingdi.h>
 #include <winuser.h>
 
-#define TEST_MAX_MSG 50
+#include "CreateWndDlgHelper.h"
 
-// cmpflag
-#define MSGLST_CMP_WP  0x1
-#define MSGLST_CMP_LP  0x2
-#define MSGLST_CMP_RES 0x4
-#define MSGLST_CMP_ALL (MSGLST_CMP_WP | MSGLST_CMP_LP | MSGLST_CMP_RES)
-
-typedef struct
+INT_PTR CALLBACK Test_CreateDialogW_DLGPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    BOOL DlgProc; // true = DlgProg, false WndProc
-    UINT msg;
-    WPARAM wParam;
-    LPARAM lParam;
-    int result;
-    int cmpflag;
-} tagMsgInfo;
+    int msgNr;
+    WCHAR* msgName;
 
-typedef struct
-{
-    int msgCount;
-    tagMsgInfo msgList[TEST_MAX_MSG];
-} tagMsgList;
-
-tagMsgList msglist;
-
-/* the expected message-list */
-const tagMsgList t1msgList =
-{
-    9,
+    msgNr = rcvMsgLst.msgCount;
+    if (msgNr < TEST_MAX_MSG)
     {
-        // DlgProc, msg,              wParam,   lParam, result, cmpflag
-        {  FALSE,  WM_NCCREATE,            0,         0,     1, MSGLST_CMP_WP | MSGLST_CMP_RES },
-        {  FALSE,  WM_NCCALCSIZE,          0,         0,     0, MSGLST_CMP_WP | MSGLST_CMP_RES },
-        {  FALSE,  WM_CREATE,              0,         0,     0, MSGLST_CMP_WP | MSGLST_CMP_RES },
-        {  FALSE,  WM_SIZE,                0, 0x145012c,     0, MSGLST_CMP_ALL }, // FIXME: size is 400x400 on Win7?
-        {  FALSE,  WM_MOVE,                0, 0x0160003,     0, MSGLST_CMP_ALL },
-        {  TRUE,   WM_SETFONT,             0,         0,     0, MSGLST_CMP_LP | MSGLST_CMP_RES },
-        {  FALSE,  WM_SETFONT,             0,         0,     0, MSGLST_CMP_LP | MSGLST_CMP_RES },
-        {  TRUE,   WM_INITDIALOG,          0,         0,     0, MSGLST_CMP_LP | MSGLST_CMP_RES },
-        {  FALSE,  WM_INITDIALOG,          0,         0,     0, MSGLST_CMP_LP | MSGLST_CMP_RES },
+        rcvMsgLst.msgList[msgNr].DlgProc = TRUE;
+        rcvMsgLst.msgList[msgNr].msg     = msg;
+        rcvMsgLst.msgList[msgNr].wParam  = wParam;
+        rcvMsgLst.msgList[msgNr].lParam  = lParam;
+        rcvMsgLst.msgList[msgNr].result  = 0;
+        rcvMsgLst.msgCount++;
     }
-};
 
-void DumpMsgList(const char* lstName, const tagMsgList *ml)
-{
-    const char *dlgProcName;
-    int i1;
-
-    printf("%s\n", lstName);
-    for (i1 = 0; i1 < ml->msgCount; i1++)
-    {
-        dlgProcName = (ml->msgList[i1].DlgProc)  ? "DlgProc" : "WndProc";
-        printf("#%.3d %s, msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %d\n",
-               i1,
-               dlgProcName,
-               ml->msgList[i1].msg,
-               ml->msgList[i1].wParam,
-               ml->msgList[i1].lParam,
-               ml->msgList[i1].result);
-    }
+    msgName = GetWinMsgName(msg);
+    trace("DlgProc: msg 0x%x ""%S"", wParam 0x%x, lParam 0x%Ix\n",
+          msg, msgName, wParam, lParam);
+    return FALSE;
 }
 
-BOOL CmpMsgList(const tagMsgList *recvd,
-                const tagMsgList *expect)
+void Test_CreateDialogW(TestParams* tp)
 {
-    int i1;
-    BOOL isOk;
+    HWND hWnd;
+    HWND hWndParent;
+    HMODULE hMod;
+    tagLPDLGTEMPLATEEXPART* pRes;
+    tagLPDLGTEMPLATEEXPART* pResCpy;
+    HRSRC hRes;
+    HGLOBAL hGlob;
+    DWORD exstyle;
+    DWORD style;
+    DWORD resSize;
 
-    isOk = TRUE;
-    if (recvd->msgCount != expect->msgCount)
+    trace(">> testing style 0x%Ix, exstyle 0x%Ix\n",tp->initStyle,tp->initExStyle);
+
+    pResCpy = 0;
+    hWndParent = 0;
+    hWnd = 0;
+
+    hMod = GetModuleHandle(NULL);
+    ok(hMod != NULL, "\n");
+
+    rcvMsgLst.msgCount = 0;
+    rcvMsgLst.isDlg = TRUE;
+    rcvMsgLst.isPatched = FALSE;
+    rcvMsgLst.pTestParams = tp;
+
+    // MSVC-Compiler does not allow to change resource.
+    // Load resource and copy it. So we can change style
+    // and exstyle.
+    hRes = FindResourceW(hMod,L"TESTDIALOG",MAKEINTRESOURCEW(RT_DIALOG));
+    resSize = SizeofResource(hMod,hRes);
+    if (resSize == 0)
     {
-        ok(FALSE, "%d messages expected, %d messages received!\n",
-           expect->msgCount, recvd->msgCount);
-        isOk = FALSE;
+         ok(FALSE, "Error getting size of resource ""TESTDIALOG""\n");
+         return;
     }
-    else
+    hGlob = LoadResource(hMod,hRes);
+    pRes = LockResource(hGlob);
+    // modify the style and exstyle params. We modify
+    // the dialogresource directly in memory. This allows
+    // it to check multiple style- and exstyle-flags with
+    // only one dialog resource included in build.
+    pResCpy = calloc(1,resSize);
+    if (pResCpy == 0)
     {
-        for (i1 = 0; i1 < recvd->msgCount; i1++)
-        {
-            if (expect->msgList[i1].DlgProc != recvd->msgList[i1].DlgProc)
-                isOk = FALSE;
-            if (expect->msgList[i1].msg != recvd->msgList[i1].msg)
-                isOk = FALSE;
-            if ((expect->msgList[i1].cmpflag & MSGLST_CMP_WP) &&
-                (expect->msgList[i1].wParam != recvd->msgList[i1].wParam))
-                isOk = FALSE;
-            if ((expect->msgList[i1].cmpflag & MSGLST_CMP_LP) &&
-                (expect->msgList[i1].lParam != recvd->msgList[i1].lParam))
-                isOk = FALSE;
-            if ((expect->msgList[i1].cmpflag & MSGLST_CMP_RES) &&
-                (expect->msgList[i1].result != recvd->msgList[i1].result))
-                isOk = FALSE;
-            if (!isOk)
-            {
-                ok(FALSE, "Message #%.3d not equal\n", i1);
-                break;
-            }
-        }
+         ok(FALSE, "Error: calloc returns 0\n");
+         return;
     }
+    memcpy(pResCpy,pRes,resSize);
 
-    if (!isOk)
+    pResCpy->exstyle = tp->initExStyle;
+    pResCpy->style = tp->initStyle;
+    pResCpy->cx = (SHORT)tp->initWndSize.cx;
+    pResCpy->cy = (SHORT)tp->initWndSize.cy;
+
+    hWndParent = 0;
+    if ((tp->initStyle & WS_CHILD) > 0)
     {
-        DumpMsgList("RECEIVED", recvd);
-        DumpMsgList("EXPECTED", expect);
-        return FALSE;
+        hWndParent = CreateWindowExW(0,
+                                     L"TestParentWindowClass",
+                                     L"Parent Window",
+                                     WS_POPUP | WS_CAPTION |
+                                     WS_SYSMENU | DS_SETFONT,
+                                     0,0,200,200,0,0,hMod,NULL);
+        ok(hWndParent != NULL, "Can't create parentwindow! Error: %lu\n", GetLastError());
+        if (hWndParent == NULL)
+            goto cleanup;
     }
 
-    ok(TRUE, "\n");
-    return TRUE;
-}
+    hWnd = CreateDialogIndirectW(hMod,
+                                 (LPCDLGTEMPLATE)pResCpy,
+                                 hWndParent,
+                                 Test_CreateDialogW_DLGPROC);
+    ok(hWnd != NULL, "Can't create window! Error: %lu\n", GetLastError());
 
-INT_PTR CALLBACK Test_CreateDialogW_DLGPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-    if (msglist.msgCount < TEST_MAX_MSG)
+    if (hWnd == NULL)
+        goto cleanup;
+    /* Check the exstyle-flags */
+    exstyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
+    ok(exstyle == tp->expectedExStyle,
+       "ExStyle wrong, got 0x%Ix, expected 0x%Ix.\n",
+       exstyle,tp->expectedExStyle);
+    /* Check the style-flags */
+    style = GetWindowLongW(hWnd, GWL_STYLE);
+    ok(style == tp->expectedStyle,
+       "Style wrong, got 0x%Ix, expected 0x%Ix.\n",
+       style,tp->expectedStyle);
+    /* Destroy windows */
+    DestroyWindow(hWnd);
+    hWnd = 0;
+    if (hWndParent != 0)
     {
-        msglist.msgList[msglist.msgCount].DlgProc = TRUE;
-        msglist.msgList[msglist.msgCount].msg     = msg;
-        msglist.msgList[msglist.msgCount].wParam  = wParam;
-        msglist.msgList[msglist.msgCount].lParam  = lParam;
-        msglist.msgList[msglist.msgCount].result  = 0;
-        msglist.msgCount++;
+        DestroyWindow(hWndParent);
+        hWndParent = 0;
     }
-    trace("DlgProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix\n",
-           msg, wParam, lParam);
-    return FALSE;
+    /* Check the messages we received during creation */
+    CmpMsgList(&rcvMsgLst, tp->expectedMsgList);
+cleanup:
+    if (pResCpy != NULL)
+        free(pResCpy);
+    if (hWnd != 0)
+        DestroyWindow(hWnd);
+    if (hWndParent != 0)
+        DestroyWindow(hWndParent);
 }
 
-LRESULT CALLBACK Test_CreateDialogW_WNDPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+START_TEST(CreateDialog)
 {
-    LRESULT res;
-    res = DefDlgProcW(hWnd, msg, wParam, lParam);
+    TestParams tp;
+    WndMsgList ml;
 
-    if (msglist.msgCount < TEST_MAX_MSG)
-    {
-        msglist.msgList[msglist.msgCount].DlgProc = FALSE;
-        msglist.msgList[msglist.msgCount].msg     = msg;
-        msglist.msgList[msglist.msgCount].wParam  = wParam;
-        msglist.msgList[msglist.msgCount].lParam  = lParam;
-        msglist.msgList[msglist.msgCount].result  = res;
-        msglist.msgCount++;
-    }
-    trace("WndProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %Id\n",
-          msg, wParam, lParam, res);
-    return res;
-}
+    if (!Test_CreateWndDlg_Init())
+        return;
 
-void Test_CreateDialogW()
-{
-    HWND hWnd;
-    HMODULE hMod;
-    DWORD exstyle;
-    WNDCLASSW wc;
+    //Test_CreateDialogA();//TODO
 
-    hMod = GetModuleHandle(NULL);
-    ok(hMod != NULL, "\n");
+    memset(&tp,sizeof(tp),0);
+    // A dialog-resource definition without style and exstyle
+    // gets the following default-(init)flags:
+    // STYLE 0x80c80040 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SETFONT;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
 
-    msglist.msgCount = 0;
-    wc.style         = CS_HREDRAW | CS_VREDRAW;
-    wc.lpfnWndProc   = Test_CreateDialogW_WNDPROC;
-    wc.cbClsExtra    = 0;
-    wc.cbWndExtra    = DLGWINDOWEXTRA;
-    wc.hInstance     = hMod;
-    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
-    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
-    wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
-    wc.lpszMenuName  = NULL;
-    wc.lpszClassName = L"TestDialogClass";
+    // STYLE 0x80c008c8 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_CAPTION | DS_CENTER | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
 
-    if (!RegisterClassW(&wc))
-    {
-         ok(FALSE, "Error registering Window-Class\n");
-         return;
-    }
-    hWnd = CreateDialogW(hMod, L"TESTDIALOG", 0, Test_CreateDialogW_DLGPROC);
-    ok(hWnd != NULL, "Error: %lu\n", GetLastError());
-    if (hWnd != NULL)
-    {
-        /* Check the exstyle */
-        exstyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
-        ok(exstyle != 0x50010, "ExStyle wrong, got %#08lX, expected 0x50010.\n", exstyle);
-        /* Check the messages we received during creation */
-        CmpMsgList(&msglist, &t1msgList);
-    }
-}
+    // STYLE 0x80c800c0 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_SETFONT;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
 
-START_TEST(CreateDialog)
-{
-    //Test_CreateDialogA();//TODO
-    Test_CreateDialogW();
+    // STYLE 0x80c800c8 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
+
+    // STYLE 0x80c80048 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SETFONT | DS_FIXEDSYS;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
+
+    // STYLE 0x94c80980 EXSTYLE 0x00010101
+    // FIXME - Fails (hWnd = 0, GetLastError = 0)
+    //         This happens only if no style DS_SETFONT is set! Why?
+    tp.initStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | DS_CENTER | DS_NOIDLEMSG | DS_MODALFRAME
+                   /*HACK - see above */ | DS_SETFONT;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
+
+    // STYLE 0x90c800c8 EXSTYLE 0x00000000
+    tp.initStyle = WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS;
+    tp.expectedStyle = tp.initStyle | WS_CLIPSIBLINGS | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
+
+    // STYLE 0x40000048 EXSTYLE 0x00000000
+    tp.initStyle = WS_CHILD | DS_SETFONT | DS_FIXEDSYS;
+    tp.expectedStyle = tp.initStyle | DS_3DLOOK;
+    tp.initExStyle = 0;
+    tp.expectedExStyle = 0;
+    tp.initWndSize = makeSize(200,200);
+    tp.expectedMsgList = msgListCopy(&tp,&ml,TRUE);
+    Test_CreateDialogW(&tp);
 }
Index: apitests/user32/testlist.c
===================================================================
--- apitests/user32/testlist.c	(Revision 67545)
+++ apitests/user32/testlist.c	(Arbeitskopie)
@@ -6,6 +6,7 @@
 extern void func_AttachThreadInput(void);
 extern void func_CreateDialog(void);
 extern void func_CreateIconFromResourceEx(void);
+extern void func_CreateWindow(void);
 extern void func_DeferWindowPos(void);
 extern void func_DestroyCursorIcon(void);
 extern void func_DrawIconEx(void);
@@ -39,6 +40,7 @@
     { "AttachThreadInput", func_AttachThreadInput },
     { "CreateDialog", func_CreateDialog },
     { "CreateIconFromResourceEx", func_CreateIconFromResourceEx },
+    { "CreateWindow", func_CreateWindow },
     { "DeferWindowPos", func_DeferWindowPos },
     { "DestroyCursorIcon", func_DestroyCursorIcon },
     { "DrawIconEx", func_DrawIconEx },
Index: apitests/user32/user32_apitest.rc
===================================================================
--- apitests/user32/user32_apitest.rc	(Revision 67545)
+++ apitests/user32/user32_apitest.rc	(Arbeitskopie)
@@ -6,7 +6,7 @@
 IDI_TEST ICON "test.ico"
 TESTCURSOR CURSOR "test.cur"
 
-TESTDIALOG DIALOG 0,0, 200,200
+TESTDIALOG DIALOGEX 0,0, 200,200
 CLASS "TestDialogClass"
 CAPTION  "Testdialog"
 FONT 8, "MS Shell Dlg"
