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
Solved

ActiveX Properties (Drop-down List)

Posted on 1998-04-20
6
205 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

839 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