Solved

ActiveX - VB Property Categories

Posted on 1998-10-12
9
278 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 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