From c40265799ed2dd422b06cce9560b7b855304cbf1 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 15 Jun 2016 14:57:10 +0800
Subject: user32: Do not initialize dialog info for every window passed to
 DefDlgProc.

The tests in the last patch in the series use
DefDlgProcA(parent, DM_GETDEFID, 0, 0);
as a simple dialog detector, and that call leads to dialog info being
created for a not dialog window, which later makes this window being
treated as a dialog.

DIALOG_CreateControls32() gets called after the dialog info creation
has been forced, so passing TRUE to DIALOG_get_info() is redundant there.
---
 dlls/user32/defdlg.c | 4 ++--
 dlls/user32/dialog.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c
index 00a73c6..258c3a9 100644
--- a/dlls/user32/defdlg.c
+++ b/dlls/user32/defdlg.c
@@ -364,7 +364,7 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
     LRESULT result = 0;
 
     /* Perform DIALOGINFO initialization if not done */
-    if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
+    if (!(dlgInfo = DIALOG_get_info( hwnd, msg == WM_NCCREATE ))) return 0;
 
     SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
 
@@ -422,7 +422,7 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
     LRESULT result = 0;
 
     /* Perform DIALOGINFO initialization if not done */
-    if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
+    if (!(dlgInfo = DIALOG_get_info( hwnd, msg == WM_NCCREATE ))) return 0;
 
     SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
 
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index 9cb4b8d..b84784f 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -216,7 +216,7 @@ static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
 static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate,
                                      HINSTANCE hInst, BOOL unicode )
 {
-    DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd, TRUE );
+    DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd, FALSE );
     DLG_CONTROL_INFO info;
     HWND hwndCtrl, hwndDefButton = 0;
     INT items = dlgTemplate->nbItems;
-- 
2.8.0

