CDateTimeCtrl::GetIdealSize

Returns the ideal size of the date and time picker control that is required to display the current date or time.

BOOL GetIdealSize(
     LPSIZE psize
) const;

Parameters

Parameter

Description

[out] psize

Pointer to a SIZE structure that contains the ideal size for the control.

Return Value

The return value is always true.

Remarks

This method sends the DTM_GETIDEALSIZE message, which is described in the Windows SDK.

Requirements

Header: afxdtctl.h

This method is supported in Windows Vista and later.

Example

The following code example defines the variable, m_dateTimeCtrl, that is used to programmatically access the date and time picker control. This variable is used in the next example.

    // Variable to access date-time control.
    CDateTimeCtrl m_dateTimeCtrl;
    // Variable to access the splitbutton control
    CSplitButton m_splitbutton;

The following code example retrieves the ideal size to display the date and time picker control.

    // Add extra initialization here

    // Associate a menu with the splitbutton control.
    m_splitbutton.SetDropDownMenu(IDR_MENU1, 0);

    // Resize the date-time picker control.
    SIZE sz;
    m_dateTimeCtrl.GetIdealSize( &sz );
    if ((sz.cx != 0) && (sz.cy != 0)) {
        m_dateTimeCtrl.SetWindowPos(
            this, 
            0, 0, sz.cx, sz.cy,
            (SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE));
    }

    // End of extra initialization

See Also

Reference

CDateTimeCtrl Class

Hierarchy Chart

DTM_GETIDEALSIZE

SIZE

Other Resources

CDateTimeCtrl Members