Commit 218c478d authored by Alexandre Julliard's avatar Alexandre Julliard

Allocate the dialog info in DIALOG_CreateIndirect if this wasn't

already done by the dialog procedure.
parent 5288361f
......@@ -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 );
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment