Solved

ActiveX - VB Property Categories

Posted on 1998-10-12
9
276 Views
Last Modified: 2013-11-20
I create an ActiveX control with MFC

I add a property say "Caption".  No problem...I don't need help with the code.

However I do need help with this:
My ActiveX control lists it's Caption property under "Misc" when it's inserted in a VB Form (property window in VB for the controls).  However I want it to appear under "Appearance" category in VB like the standard static control.

Question is -
1. how do I fix this
2. how does VB decide what categories to sort the control's properties into (e.g. What goes into Misc, what goes into Appearance, etc.)

Thanks
0
Comment
Question by:Answers2000
  • 6
  • 2
9 Comments
 
LVL 8

Author Comment

by:Answers2000
ID: 1323223
BTW : i'm fairly clued up on Windows / MFC.  I even know a bit of OCX/ActiveX stuff, so I don't need tonnes of background info, unless it's immediately relevant to the question at hand.


0
 
LVL 8

Author Comment

by:Answers2000
ID: 1323224
BTW : i'm fairly clued up on Windows / MFC.  I even know a bit of OCX/ActiveX stuff, so I don't need tonnes of background info, unless it's immediately relevant to the question at hand.


0
 
LVL 8

Author Comment

by:Answers2000
ID: 1323225
Increased pts
0
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.

 
LVL 8

Author Comment

by:Answers2000
ID: 1323226
Has anybody got any help - or even read this ?
0
 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 1323227
yes i read this. i have no answer but i'm confused.
till now i was thinking that the right way is to build the ActiveX in VB and use them in C++, and not the other way around.
0
 
LVL 8

Author Comment

by:Answers2000
ID: 1323228
AnswerTheMan - The host app, and the control can both be in more or less any language (including C/C++, VB, Delphi and probably a few more too).  Mix and match to your preferences..

I'm doing high performance graphics - hence the C++ for the control
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
ID: 1323229
Nice Question
I found this at http://www.vcdj.com/vcdj/aug98/atl1.asp

3. How do I support property categories?

The OCX96 specification defines the ICategorizeProperties interface to categorize different properties in the container's property browser. Microsoft Visual Basic supports this categorization for its Property Inspector and obtains this interface through QueryInterface(). So, to support this feature, the control writer must implement the ICategorizeProperties interface.

ICategorizePriorities supports two methods, declared as follows:



MapPropertyToCategory( [in] DISPID, [out] PROPCAT*)
GetCategoryName( [in] PROPCAT, [in] LCID, [out] BSTR*)


The first returns the category ID for the property whose dispid is passed in. The second method returns the text name of the category requested. This latter method need not be supported unless the control has specific categories of its own. It also should not be called for any standard category IDs of which the container already should be aware. The following standard category IDs are documented in the specification:

#define PROPCAT_Nil-1#define PROPCAT_Misc-2#define PROPCAT_Font-3#define PROPCAT_Position-4#define PROPCAT_Appearance-5#define PROPCAT_Behavior-6#define PROPCAT_Data-7#define PROPCAT_List-8#define PROPCAT_Text-9#define PROPCAT_Scale-10#define PROPCAT_DDE-11

The following steps show how to implement the ICategorizeProperties interface in your ATL control:

1. Declare the ICategorizeProperties:



const IID IID_ICategorizeProperties =
    {0x4D07FC10,0xF931,0x11CE,{0xB0,0x01,0x00,0xAA,0x00,0x68,0x84,0xE5}};

typedef int PROPCAT;

interface ICategorizeProperties : public IUnknown
{

STDMETHOD(MapPropertyToCategory)(/*[in]*/ DISPID dispid,
                  /*[out]*/ PROPCAT* ppropcat) = 0 ;

STDMETHOD(GetCategoryName)(/*[in]*/ PROPCAT propcat,
                  /*[in]*/ LCID lcid,
                  /*[out]*/ BSTR* pbstrName) = 0 ;

};


2. Include the interface in the control class's base class list:



class ATL_NO_VTABLE CXXX :
                  public CComObjectRootEx<CComSingleThreadModel>,
                  public CComCoClass<CXXX, &CLSID_XXX>,
                  public CComControl<CXXX>,
                  …
                  …
                  public ICategorizeProperties

{


3. To enable the QueryInterface() for ICategorizeProperties add the corresponding COM_INTERFACE_ENTRY macro:



BEGIN_COM_MAP (CXXX)
      ...
      ...
      COM_INTERFACE_ENTRY(ICategorizeProperties)
END_COM_MAP ()


4. Implement the methods of ICategorizeProperties:



STDMETHOD(MapPropertyToCategory)(   /*[in]*/ DISPID dispid,
                  /*[out]*/ PROPCAT* ppropcat
                  )
{
      if(dispid >=1000 && dispid <=1005)
      {
         *ppropcat = 1;      
         return S_OK;       
      }
      return E_FAIL;
}

STDMETHOD(GetCategoryName)(      /*[in]*/ PROPCAT propcat,
                  /*[in]*/ LCID lcid,
                  /*[out]*/ BSTR* pbstrName
                  )
{
      if(propcat == 1)
      {
            *pbstrName = ::SysAllocString(L"Instrument");
            return S_OK;
      }
      return E_FAIL;
}
0
 
LVL 8

Author Comment

by:Answers2000
ID: 1323230
I'll try this and let you know
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1323231
I works pretty cool.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
Shell script to login to remote m/c and execute commands 10 78
Detect file exist or not 3 181
how to split multiple lines delimiter : 8 112
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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