Solved

ActiveX Properties (Drop-down List)

Posted on 1998-04-20
6
200 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
  • 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 100 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now