Solved

ActiveX - VB Property Categories

Posted on 1998-10-12
9
268 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
Comment Utility
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
Comment Utility
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
Comment Utility
Increased pts
0
 
LVL 8

Author Comment

by:Answers2000
Comment Utility
Has anybody got any help - or even read this ?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:AnswerTheMan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I'll try this and let you know
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
I works pretty cool.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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