Registers the control class with the Windows registration database.
BOOL AFXAPI AfxOleRegisterControlClass( HINSTANCE hInstance, REFCLSID clsid, LPCTSTR pszProgID, UINT idTypeName, UINT idBitmap, int nRegFlags, DWORD dwMiscStatus, REFGUID tlid, WORD wVerMajor, WORD wVerMinor );
Nonzero if the control class was registered; otherwise 0.
This allows the control to be used by containers that are OLE-control aware. AfxOleRegisterControlClass updates the registry with the control's name and location on the system and also sets the threading model that the control supports in the registry. For more information, see Technical Note 64, "Apartment-Model Threading in OLE Controls," and About Processes and Threads in the Windows SDK.
// Member function implementation of class COleObjectFactory::UpdateRegistry // BOOL CMyAxCtrl::CMyAxCtrlFactory::UpdateRegistry(BOOL bRegister) { // TODO: Verify that your control follows apartment-model threading rules. // Refer to MFC TechNote 64 for more information. // If your control does not conform to the apartment-model rules, then // you must modify the code below, changing the 6th parameter from // afxRegInsertable | afxRegApartmentThreading to afxRegInsertable. if (bRegister) return AfxOleRegisterControlClass( AfxGetInstanceHandle(), m_clsid, m_lpszProgID, IDS_NVC_MFCAXCTL, IDB_NVC_MFCAXCTL, afxRegInsertable | afxRegApartmentThreading, _dwMyOleMisc, _tlid, _wVerMajor, _wVerMinor); else return AfxOleUnregisterClass(m_clsid, m_lpszProgID); }
The above example demonstrates how AfxOleRegisterControlClass is called with the flag for insertable and the flag for apartment model ORed together to create the sixth parameter:
afxRegInsertable | afxRegApartmentThreading,
The control will show up in the Insert Object dialog box for enabled containers, and it will be apartment model-aware. Apartment model-aware controls must ensure that static class data is protected by locks, so that while a control in one apartment is accessing the static data, it isn't disabled by the scheduler before it is finished, and another instance of the same class starts using the same static data. Any accesses to the static data will be surrounded by critical section code.
Header: <afxctl.h>
Note