SAMPLE: Using Enumerated Properties in an OLE ControlID: Q137354
|
This is the Visual C++ 1.5x and 2.x version of this sample. There is an
equivalent Visual C++ 4.x 32-bit sample available under the name ENPROP32.
The Enumprop sample illustrates using enumerated properties in an OLE
control.
The following file is available for download from the Microsoft Software Library:
Enprop.exeFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online ServicesAfter downloading Enprop.exe, run it in an empty directory using the -d switch (as follows) to automatically create subdirectories to hold the many files it contains:
ENPROP.EXE -d
The ENUMPROP sample illustrates how to use enumerated properties in an OLE
control. An enumerated property is one that has a specific set of possible
values. For example, an OLE control might support a property named
FillPattern, which it uses to determine the type of brush to use when
drawing the control and limit the values the FillPattern property could be
set to. Accepted values for a FillPattern property might be cross-hatched,
vertical lines, horizontal lines, and so on.
...
typedef enum
{
[helpstring("Solid")] Solid = 0,
[helpstring("Dash")] Dash = 1,
[helpstring("Dot")] Dot = 2,
[helpstring("Dash-Dot")] DashDot = 3,
[helpstring("Dash-Dot-Dot")] DashDotDot = 4,
} enumLineStyle;
...
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CEnumCtrl)
[id(1)] enumLineStyle LineStyle;
//}}AFX_ODL_PROP
...
Another method involves overriding the COleControl methods
OnGetPredefinedStrings, OnGetPredefinedValue, and OnGetDisplayString.
Enum.odl - Shows declaring the enum type for the LineStyle property.
Enumctl.cpp - Illustrates overriding the COleControl members
OnGetPredefinedStrings, OnGetPredefinedValue, and
OnGetDisplayString.
NOTE: When building the sample, the MKTYPLIB utility will generate the
following warning when compiling the .odl file:
MKTYPLIB is issuing the warning because the enumLineStyle type is not one of the predefined types supported by IDispatch::Invoke. You can ignore the warning because the actual value of the LineStyle property is a short, which is a type supported by IDispatch::Invoke.warning M0002: Warning near line 35 column 35: specified type is not supported by IDispatch::Invoke
Additional query words: enprop32 kbole kbfile
Keywords : kbole kbsample kbCtrl kbMFC
Version : 1.50 1.51 1.52 | 2.00 2.10 2.20
Platform : NT WINDOWS
Issue type :
Last Reviewed: August 8, 1999