#include <afxcmn.h> #include <afxext.h> #define m_dwRef m_dwRefAtl #define m_pOuterUnknown m_pOuterUnknownAtl #define InternalQueryInterface InternalQueryInterfaceAtl #define InternalAddRef InternalAddRefAtl #define InternalRelease InternalReleaseAtl
class YOURCOMPONENTCLASS; // Forward Decl typedef CWindowImpl < YOURCOMPONENTCLASS, YOURCLASS > MFCWndImpl; typedef CComControl < YOURCOMPONENTCLASS, MFCWndImpl > MFCComCtrl;
public CComControl<CGraph2D>,with
public MFCComCtrl,
CHAIN_MSG_MAP(CComControl<CGraph2D>)with
CHAIN_MSG_MAP( MFCComCtrl );
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // Place your initialisation code here return 0; }And add the corresponing line at the top of message map :
MESSAGE_HANDLER(WM_CREATE, OnCreate)
m_bWindowOnly = TRUE;
STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip) { IOleInPlaceObjectWindowlessImpl< YOURCOMPONENTCLASS >::SetObjectRects(prcPos, prcClip); YOURWNDCLASS::OnMove( prcPos->left, prcPos->top ); YOURWNDCLASS::OnSize( SIZE_RESTORED, prcPos->right - prcPos->left, prcPos->bottom - prcPos->top ); return S_OK; }
static LPCTSTR GetWndClassName() { return NULL; }
Add a method or property for each of the methods and member variables in your CWnd derived class that you wish to export. To do this, select the interface for your control in the class view and right click it, and choose "Add method" or "Add property".
Remember you should only use the data types which are part of the VARIANT structure:
BYTE, USHORT, UINT, ULONG, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE, VARIANT_BOOL, SCODE, CY, DATE, BSTR, IUnknown*, IDispatch*, SAFEARRAY*, VARIANT*, DECIMAL*, _tagBRECORD.
(Other data types which evaluate to one of these are also valid)