How to set the initial default size of an Active Template Library (ATL) control in Visual C++ (176552)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 2.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ 2005 Express Edition
- The Microsoft Active Template Library (ATL) 2.1, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ 2005 Express Edition
- The Microsoft Active Template Library (ATL) 3.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- 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;
}
Modification Type: | Major | Last Reviewed: | 12/30/2005 |
---|
Keywords: | kbCtrlCreate kbhowto KB176552 kbAudDeveloper |
---|
|