How to implement enumerated properties in ATL (181255)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 2.1
- 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++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
This article was previously published under Q181255 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 The Atlenum sample shows how to implement enumerated
properties in ATL.MORE INFORMATIONThe
following files are available for download from the Microsoft Download
Center: Visual C++ 6.0 For more
information about how to download Microsoft support files, click the following
article number to view the article in the Microsoft Knowledge Base: 119591 How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help prevent
any unauthorized changes to the file.
Visual C++ .NET Release Date: June 25,
2002 For more information about how to download Microsoft support
files, click the following article number to view the article in the Microsoft
Knowledge Base: 119591 How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help prevent
any unauthorized changes to the file.
Enumerated properties have a predefined set of possible
values that you can assign to them. For example, when you define an enumerated
property for the days of the week, the only possible values are Monday through
Sunday. You can control this by setting up an enumerated property in the .idl
file:
typedef enum tagDAYSOFWEEK
{
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6,
Sunday = 7
} DAYSOFWEEK;
Visual Basic 5.0 and later versions have a feature called Code
Completion. As you enter code, the editor displays a list of context-sensitive
items that you can use in your code. In the case of an enumerated property,
typing an "=" after the property causes Visual Basic to display a list of
possible values. For example, a list of possible values to complete the
following statement appears when you type:
mycontrol.DayOfWeek =
Enumerated properties also allow you to browse the possible
values for a property in a property browser. Look at the BorderStyle property
for any control in the Visual Basic property browser. Possible values are
displayed in a list box. By default, Visual Basic creates a list in the form of
"1 - Monday," "2 - Tuesday," and so on. If you want to the change the display
string, you need to override some methods in the IPerPropertyBrowsing
interface. The Atlenum sample shows how to override the GetDisplayString(),
GetPredefinedStrings(), and GetPredefinedValue() methods. The sample also
implements a property page for modifying the enumerated property.
Modification Type: | Major | Last Reviewed: | 1/11/2006 |
---|
Keywords: | kbdownload kbcode kbCollectionClass kbCtrl kbfile kbhowto kbSample kbServer KB181255 kbAudDeveloper |
---|
|