Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ActiveX Properties (Drop-down List)

Posted on 1998-04-20
6
Medium Priority
?
210 Views
Last Modified: 2010-04-10
I am using Microsoft Visual C++ 5.0 Professional Edition.  I have created an ActiveX control to display shadowed, curved, blocked, and other styles of text.  One property for the control is the 'Style' property.  Right now, the style property is just a 'short' that, if you enter a value which is out of range, will display a message box to notify you of what the range is and what each number does.  Now, when I look at Visual Basic OCX controls (also known as ActiveX controls) I have noticed that properties like 'MousePointer' display a drop-down list that the user is then able to select a number from, instead of typing it in themselves.

I would like to know how to invoke one of these drop-down lists in the property box and I would appreciate the sample code needed to do this.  The property I am dealing with is called, simply, 'Style', and the variable attached to it is 'm_style'.

Thanks in advance...
0
Comment
Question by:Egore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:guruprasad031298
ID: 1162401
The answer to your requirement is to use 'Property pages'. It is explained in good detail in MSVC 5.0 online help.

Browse 'Developer Products' -> 'Visual C++' -> 'Visual C++ tutorials' -> 'Circle : ActiveX Control' -> 'Modifying the default property page'.

The tutorial explains everything in an understandable language and is easy to implement.

As a short suggestion, do this, Place a drop-down combo in your default propety page. Display valid short values of m_Style in the list box of the combo and link m_Style to this combo and you should be on your way.

FYI, Microsoft requires all UI based ActiveX control to have property pages.
0
 
LVL 3

Author Comment

by:Egore
ID: 1162402
I already know how to create property pages, and I have created them.  What I want is for, when I open up Visual Basic, if I DO NOT use click on 'Custom', I still want the property to have a drop-down list.  This is rather hard to understand, but, if you have VB, just look at the 'MousePointer' property, and you will see what I mean.
0
 

Accepted Solution

by:
bleibold earned 200 total points
ID: 1162403


Egore,

Create an enumeration called TEXTStyles in the ODL as shown below.

typedef [v1_enum] enum
{      
      STYLE_SHADOW      = 0x1,
      STYLE_CURVED      = 0x2,
      STYLE_BLOCKED      = 0x4      
} TEXTStyles;

[id(2)] TEXTStyles Style;

Change the property's data type from long to TEXTStyles in the interface:

This then should show up as a property list in VB.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:Egore
ID: 1162404
If this works, I will still need to be able to display text as well in this list.  Like I said, look at the MousePointer property in VB, it has a number, a hyphen (-) and then some text.  I need to be able to do this kind of thing.  If you can show me how to add text to this, then I will give you the points.
0
 

Expert Comment

by:bleibold
ID: 1162405
Egore,

The actual named enumeration STYLE_SHADOW with ID of 0x1 will show up in the VB property browser as 1 - STYLE_SHADOW and so forth for other named enumerations using the technique above.  You can modify the enumeration name to something more readable to the user.

Bill
0
 
LVL 3

Author Comment

by:Egore
ID: 1162406
I tried putting these lines of code in my .ODL file and I got a compiler error.  However, it wouldn't tell me where the error occurred, so I'm going to need a little more specific information.

1.)  Will you tell me what lines of code to insert your code between?
2.)  Will I have to use the ClassWizard to chage the variable type or will I have to do that directly in code?
3.)  Will I have to change any existing code to make it compatible with this new typedef?

If I have to change anything, please tell me what I need to change.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question