user32: Delay creation of the 16-bit dialog info structure until the window is created.
This mirrors the behavior of the 32-bit side.
This commit is contained in:
parent
2cd6ac2725
commit
009badeb32
|
@ -292,35 +292,24 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
|
||||||
RECT rect;
|
RECT rect;
|
||||||
POINT pos;
|
POINT pos;
|
||||||
SIZE size;
|
SIZE size;
|
||||||
WND * wndPtr;
|
|
||||||
DLG_TEMPLATE template;
|
DLG_TEMPLATE template;
|
||||||
DIALOGINFO * dlgInfo;
|
DIALOGINFO * dlgInfo;
|
||||||
BOOL ownerEnabled = TRUE;
|
BOOL ownerEnabled = TRUE;
|
||||||
DWORD exStyle = 0;
|
DWORD exStyle = 0;
|
||||||
DWORD units = GetDialogBaseUnits();
|
DWORD units = GetDialogBaseUnits();
|
||||||
|
HMENU16 hMenu = 0;
|
||||||
|
HFONT hUserFont = 0;
|
||||||
|
UINT flags = 0;
|
||||||
|
UINT xBaseUnit = LOWORD(units);
|
||||||
|
UINT yBaseUnit = HIWORD(units);
|
||||||
|
|
||||||
/* Parse dialog template */
|
/* Parse dialog template */
|
||||||
|
|
||||||
dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
|
dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
|
||||||
|
|
||||||
/* Initialise dialog extra data */
|
|
||||||
|
|
||||||
if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
|
|
||||||
dlgInfo->hwndFocus = 0;
|
|
||||||
dlgInfo->hUserFont = 0;
|
|
||||||
dlgInfo->hMenu = 0;
|
|
||||||
dlgInfo->xBaseUnit = LOWORD(units);
|
|
||||||
dlgInfo->yBaseUnit = HIWORD(units);
|
|
||||||
dlgInfo->idResult = 0;
|
|
||||||
dlgInfo->flags = 0;
|
|
||||||
dlgInfo->hDialogHeap = 0;
|
|
||||||
|
|
||||||
/* Load menu */
|
/* Load menu */
|
||||||
|
|
||||||
if (template.menuName)
|
if (template.menuName) hMenu = LoadMenu16( hInst, template.menuName );
|
||||||
{
|
|
||||||
dlgInfo->hMenu = HMENU_32(LoadMenu16( hInst, template.menuName ));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create custom font if needed */
|
/* Create custom font if needed */
|
||||||
|
|
||||||
|
@ -332,32 +321,32 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
|
||||||
int pixels;
|
int pixels;
|
||||||
dc = GetDC(0);
|
dc = GetDC(0);
|
||||||
pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
|
pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
|
||||||
dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
|
hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
|
||||||
FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
|
FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
|
||||||
PROOF_QUALITY, FF_DONTCARE, template.faceName );
|
PROOF_QUALITY, FF_DONTCARE, template.faceName );
|
||||||
if (dlgInfo->hUserFont)
|
if (hUserFont)
|
||||||
{
|
{
|
||||||
SIZE charSize;
|
SIZE charSize;
|
||||||
HFONT hOldFont = SelectObject( dc, dlgInfo->hUserFont );
|
HFONT hOldFont = SelectObject( dc, hUserFont );
|
||||||
charSize.cx = GdiGetCharDimensions( dc, NULL, &charSize.cy );
|
charSize.cx = GdiGetCharDimensions( dc, NULL, &charSize.cy );
|
||||||
if (charSize.cx)
|
if (charSize.cx)
|
||||||
{
|
{
|
||||||
dlgInfo->xBaseUnit = charSize.cx;
|
xBaseUnit = charSize.cx;
|
||||||
dlgInfo->yBaseUnit = charSize.cy;
|
yBaseUnit = charSize.cy;
|
||||||
}
|
}
|
||||||
SelectObject( dc, hOldFont );
|
SelectObject( dc, hOldFont );
|
||||||
}
|
}
|
||||||
ReleaseDC(0, dc);
|
ReleaseDC(0, dc);
|
||||||
TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
|
TRACE("units = %d,%d\n", xBaseUnit, yBaseUnit );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create dialog main window */
|
/* Create dialog main window */
|
||||||
|
|
||||||
rect.left = rect.top = 0;
|
rect.left = rect.top = 0;
|
||||||
rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
|
rect.right = MulDiv(template.cx, xBaseUnit, 4);
|
||||||
rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
|
rect.bottom = MulDiv(template.cy, yBaseUnit, 8);
|
||||||
if (template.style & DS_MODALFRAME) exStyle |= WS_EX_DLGMODALFRAME;
|
if (template.style & DS_MODALFRAME) exStyle |= WS_EX_DLGMODALFRAME;
|
||||||
AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), exStyle );
|
AdjustWindowRectEx( &rect, template.style, (hMenu != 0), exStyle );
|
||||||
pos.x = rect.left;
|
pos.x = rect.left;
|
||||||
pos.y = rect.top;
|
pos.y = rect.top;
|
||||||
size.cx = rect.right - rect.left;
|
size.cx = rect.right - rect.left;
|
||||||
|
@ -388,8 +377,8 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos.x += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
|
pos.x += MulDiv(template.x, xBaseUnit, 4);
|
||||||
pos.y += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
|
pos.y += MulDiv(template.y, yBaseUnit, 8);
|
||||||
if (!(template.style & (WS_CHILD|DS_ABSALIGN))) ClientToScreen( owner, &pos );
|
if (!(template.style & (WS_CHILD|DS_ABSALIGN))) ClientToScreen( owner, &pos );
|
||||||
}
|
}
|
||||||
if ( !(template.style & WS_CHILD) )
|
if ( !(template.style & WS_CHILD) )
|
||||||
|
@ -416,31 +405,33 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
|
||||||
if (modal)
|
if (modal)
|
||||||
{
|
{
|
||||||
ownerEnabled = DIALOG_DisableOwner( owner );
|
ownerEnabled = DIALOG_DisableOwner( owner );
|
||||||
if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
|
if (ownerEnabled) flags |= DF_OWNERENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwnd = WIN_Handle32( CreateWindowEx16(exStyle, template.className,
|
hwnd = WIN_Handle32( CreateWindowEx16(exStyle, template.className,
|
||||||
template.caption, template.style & ~WS_VISIBLE,
|
template.caption, template.style & ~WS_VISIBLE,
|
||||||
pos.x, pos.y, size.cx, size.cy,
|
pos.x, pos.y, size.cx, size.cy,
|
||||||
HWND_16(owner), HMENU_16(dlgInfo->hMenu),
|
HWND_16(owner), hMenu, hInst, NULL ));
|
||||||
hInst, NULL ));
|
|
||||||
if (!hwnd)
|
if (!hwnd)
|
||||||
{
|
{
|
||||||
if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
|
if (hUserFont) DeleteObject( hUserFont );
|
||||||
if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
|
if (hMenu) DestroyMenu16( hMenu );
|
||||||
if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
|
if (modal && (flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
|
||||||
HeapFree( GetProcessHeap(), 0, dlgInfo );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
wndPtr = WIN_GetPtr( hwnd );
|
dlgInfo = DIALOG_get_info( hwnd, TRUE );
|
||||||
wndPtr->flags |= WIN_ISDIALOG;
|
dlgInfo->hwndFocus = 0;
|
||||||
wndPtr->dlgInfo = dlgInfo;
|
dlgInfo->hUserFont = hUserFont;
|
||||||
WIN_ReleasePtr( wndPtr );
|
dlgInfo->hMenu = HMENU_32( hMenu );
|
||||||
|
dlgInfo->xBaseUnit = xBaseUnit;
|
||||||
|
dlgInfo->yBaseUnit = yBaseUnit;
|
||||||
|
dlgInfo->idResult = IDOK;
|
||||||
|
dlgInfo->flags = flags;
|
||||||
|
|
||||||
SetWindowLong16( HWND_16(hwnd), DWLP_DLGPROC, (LONG)dlgProc );
|
SetWindowLong16( HWND_16(hwnd), DWLP_DLGPROC, (LONG)dlgProc );
|
||||||
|
|
||||||
if (dlgInfo->hUserFont)
|
if (hUserFont)
|
||||||
SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
|
SendMessageA( hwnd, WM_SETFONT, (WPARAM)hUserFont, 0 );
|
||||||
|
|
||||||
/* Create controls */
|
/* Create controls */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue