I like the idea of programming by components. After reading on the topic of COM
Categories I started to thing about a possible way to make kind of plugins for my
applications. The first idea came at home when I was thinking about my job. We
do fingerprint identification and use multiple hardware to capture
a fingerprint picture. So I generalized fingerprint scanners as
hardware pieces that delivers fingerprint pictures. Then I built
an interface that is generic to all scanners. This allow us now
to choose the scanner we would like to use at run time.
You may get more information in the articles from Len Holgate:
Writing extensible applications,
Component Category Manager wrapper classes.
The ComboBox is built according to an CATID (UUID) representing the COM Category.
It searches the registry all COM objects implementing that Category using ICatInformation.
Then it add them in the list box of the ComboBox. It also sets the 32-bit value associated
with the specified item in the combo box to be
a CString's pointer containing the interface identifier (IID). This
will permit to create the COM object according to user choice at
runtime. To optimize the speed of displaying, the ComboBox search
the registry only if a user click on the dropdown. It also cache
in the registry the latest value selected for creation speed.
To use this WTL control, place a ComboBox on your dialog. Add a member variable to your dialog implementation file:
OnInitDialog() event handler, add the following line:
LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& )
m_catCombo.SubclassWindow( GetDlgItem(IDC_COMBO_CAT) );
Add the following reflection macro to your main message map:
Use this to initialize the
CCOMCategoriesComboBox in the dialog constructor:
CString(_T("IE Browser Band")) )
To get user's selected COM object, you have two solutions:
Read the value written in the registry at HKLM\SOFTWARE\Tech Head\COMCategoryComboBox\IE Browser BandIID
CComboBox::GetItemDataPtr to retrieves the application-supplied 32-bit value associated with the specified combo box item that is a pointer to a
CString containing the interface identifier (IID).
None (at the moment ;-).
October 4, 2001|
. Added comments to the source code.
. Updated the article on Tech Head web site.
. Submited the article to Codeproject web site.
October 3, 2001|
. Added the article on Tech Head web site.