From 218c478d249ab3c8bb49884df756a96b6dd73508 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 14 Jul 2004 00:49:40 +0000 Subject: [PATCH] Allocate the dialog info in DIALOG_CreateIndirect if this wasn't already done by the dialog procedure. --- dlls/user/controls.h | 6 +----- dlls/user/dialog16.c | 2 +- windows/defdlg.c | 23 ++++++++++++----------- windows/dialog.c | 10 +++++----- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/dlls/user/controls.h b/dlls/user/controls.h index 50fd297a094..e681d318a21 100644 --- a/dlls/user/controls.h +++ b/dlls/user/controls.h @@ -134,11 +134,7 @@ typedef struct /* offset of DIALOGINFO ptr in dialog extra bytes */ #define DWL_WINE_DIALOGINFO (DWL_USER+sizeof(ULONG_PTR)) -inline static DIALOGINFO *DIALOG_get_info( HWND hwnd ) -{ - return (DIALOGINFO *)GetWindowLongW( hwnd, DWL_WINE_DIALOGINFO ); -} - +extern DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ); extern BOOL DIALOG_GetCharSize( HDC hdc, HFONT hFont, SIZE * pSize ); extern void DIALOG_EnableOwner( HWND hOwner ); extern BOOL DIALOG_DisableOwner( HWND hOwner ); diff --git a/dlls/user/dialog16.c b/dlls/user/dialog16.c index 2d745f3cc20..ced0e61d981 100644 --- a/dlls/user/dialog16.c +++ b/dlls/user/dialog16.c @@ -139,7 +139,7 @@ static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info ) static BOOL DIALOG_CreateControls16( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate, HINSTANCE16 hInst ) { - DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd ); + DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd, TRUE ); DLG_CONTROL_INFO info; HWND hwndCtrl, hwndDefButton = 0; INT items = dlgTemplate->nbItems; diff --git a/windows/defdlg.c b/windows/defdlg.c index 79301ac89db..0d9f1f0440b 100644 --- a/windows/defdlg.c +++ b/windows/defdlg.c @@ -81,7 +81,7 @@ static void DEFDLG_SaveFocus( HWND hwnd ) HWND hwndFocus = GetFocus(); if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return; - if (!(infoPtr = DIALOG_get_info( hwnd ))) return; + if (!(infoPtr = DIALOG_get_info( hwnd, FALSE ))) return; infoPtr->hwndFocus = hwndFocus; /* Remove default button */ } @@ -95,7 +95,7 @@ static void DEFDLG_RestoreFocus( HWND hwnd ) DIALOGINFO *infoPtr; if (IsIconic( hwnd )) return; - if (!(infoPtr = DIALOG_get_info( hwnd ))) return; + if (!(infoPtr = DIALOG_get_info( hwnd, FALSE ))) return; if (!IsWindow( infoPtr->hwndFocus )) return; /* Don't set the focus back to controls if EndDialog is already called.*/ if (!(infoPtr->flags & DF_END)) @@ -284,16 +284,17 @@ static LRESULT DEFDLG_Epilog(HWND hwnd, UINT msg, BOOL fResult) } /*********************************************************************** -* DEFDLG_InitDlgInfo +* DIALOG_get_info * -* Allocate memory for DIALOGINFO structure and store in DWL_DIALOGINFO -* structure. Also flag the window as a dialog type. +* Get the DIALOGINFO structure of a window, allocating it if needed +* and 'create' is TRUE. */ -static DIALOGINFO* DEFDLG_InitDlgInfo(HWND hwnd) +DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) { WND* wndPtr; - DIALOGINFO* dlgInfo = DIALOG_get_info( hwnd ); - if(!dlgInfo) + DIALOGINFO* dlgInfo = (DIALOGINFO *)GetWindowLongW( hwnd, DWL_WINE_DIALOGINFO ); + + if(!dlgInfo && create) { if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return NULL; dlgInfo->hwndFocus = 0; @@ -332,7 +333,7 @@ LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, BOOL result = FALSE; /* Perform DIALOGINFO intialization if not done */ - if(!(dlgInfo = DEFDLG_InitDlgInfo(hwnd32))) return -1; + if(!(dlgInfo = DIALOG_get_info(hwnd32, TRUE))) return -1; SetWindowLongW( hwnd32, DWL_MSGRESULT, 0 ); @@ -389,7 +390,7 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) BOOL result = FALSE; /* Perform DIALOGINFO initialization if not done */ - if(!(dlgInfo = DEFDLG_InitDlgInfo(hwnd))) return -1; + if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return -1; SetWindowLongW( hwnd, DWL_MSGRESULT, 0 ); @@ -446,7 +447,7 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) WNDPROC dlgproc; /* Perform DIALOGINFO intialization if not done */ - if(!(dlgInfo = DEFDLG_InitDlgInfo(hwnd))) return -1; + if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return -1; SetWindowLongW( hwnd, DWL_MSGRESULT, 0 ); diff --git a/windows/dialog.c b/windows/dialog.c index e567222ccbe..08b7e89090f 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -288,7 +288,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 ); + DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd, TRUE ); DLG_CONTROL_INFO info; HWND hwndCtrl, hwndDefButton = 0; INT items = dlgTemplate->nbItems; @@ -633,7 +633,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, /* moved this from the top of the method to here as DIALOGINFO structure will be valid only after WM_CREATE message has been handled in DefDlgProc All the members of the structure get filled here using temp variables */ - dlgInfo = DIALOG_get_info(hwnd); + dlgInfo = DIALOG_get_info( hwnd, TRUE ); dlgInfo->hwndFocus = 0; dlgInfo->hUserFont = hUserFont; dlgInfo->hMenu = hMenu; @@ -764,7 +764,7 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) INT retval; HWND ownerMsg = GetAncestor( owner, GA_ROOT ); - if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1; + if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) return -1; if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */ { @@ -876,7 +876,7 @@ BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval ) TRACE("%p %d\n", hwnd, retval ); - if (!(dlgInfo = DIALOG_get_info( hwnd ))) + if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) { ERR("got invalid window handle (%p); buggy app !?\n", hwnd); return FALSE; @@ -1455,7 +1455,7 @@ DWORD WINAPI GetDialogBaseUnits(void) BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect ) { DIALOGINFO * dlgInfo; - if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE; + if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) return FALSE; rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4); rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4); rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);