How to set the initial default size of an Active Template Library (ATL) control in Visual C++
Article ID: 176552
Article Last Modified on 12/30/2005
APPLIES TO
- Microsoft ActiveX Template Library 2.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft Visual C++ 2005 Express Edition
- Microsoft ActiveX Template Library 2.1, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft Visual C++ 2005 Express Edition
- Microsoft ActiveX Template Library 3.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft Visual C++ 2005 Express Edition
This article was previously published under Q176552
Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed
code model that is provided by the Microsoft .NET Framework and the unmanaged
native Microsoft Windows code model.
SUMMARY
This article shows how to set the default size of an Active
Template Library (ATL) control when it is first inserted into a container. The
default width and height of an ATL control is stored in a variable that is
named
m_sizeExtent. This variable is normally initialized to 5080x5080 himetric
units in the constructor for CComControlBase from which CComControl is derived.
You can set any default size in the constructor of your control, as follows:
CTestControl()
{
// width = 100 pixels, height = 25 pixels
SIZE sz = { 100, 25 };
// convert pixels to himetric
AtlPixelToHiMetric (&sz, &m_sizeExtent);
// store natural extent
m_sizeNatural = m_sizeExtent;
}
Additional query words: kbVC500 kbVC600 kbATL200 kbATL210 kbATL300
kbctrl
Keywords: kbhowto kbctrlcreate KB176552