home *** CD-ROM | disk | FTP | other *** search
- // SimpleCtl.cpp : Implementation of the CSimpleCtrl ActiveX Control class.
-
- #include "stdafx.h"
- #include "Simple.h"
- #include "SimpleCtl.h"
- #include "SimplePpg.h"
-
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
-
- IMPLEMENT_DYNCREATE(CSimpleCtrl, COleControl)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Message map
-
- BEGIN_MESSAGE_MAP(CSimpleCtrl, COleControl)
- //{{AFX_MSG_MAP(CSimpleCtrl)
- //}}AFX_MSG_MAP
- ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Dispatch map
-
- BEGIN_DISPATCH_MAP(CSimpleCtrl, COleControl)
- //{{AFX_DISPATCH_MAP(CSimpleCtrl)
- DISP_PROPERTY_EX(CSimpleCtrl, "P1", GetP1, SetP1, VT_I4)
- DISP_FUNCTION(CSimpleCtrl, "M1", M1, VT_EMPTY, VTS_NONE)
- //}}AFX_DISPATCH_MAP
- END_DISPATCH_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Event map
-
- BEGIN_EVENT_MAP(CSimpleCtrl, COleControl)
- //{{AFX_EVENT_MAP(CSimpleCtrl)
- EVENT_CUSTOM("E1", FireE1, VTS_NONE)
- //}}AFX_EVENT_MAP
- END_EVENT_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Property pages
-
- BEGIN_PROPPAGEIDS(CSimpleCtrl, 1)
- PROPPAGEID(CSimplePropPage::guid)
- END_PROPPAGEIDS(CSimpleCtrl)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Initialize class factory and guid
-
- IMPLEMENT_OLECREATE_EX(CSimpleCtrl, "SIMPLE.SimpleCtrl.1",
- 0xc48a81e3, 0x4384, 0x11d0, 0x9c, 0x9d, 0, 0, 0, 0, 0, 0)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Type library ID and version
-
- IMPLEMENT_OLETYPELIB(CSimpleCtrl, _tlid, _wVerMajor, _wVerMinor)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Interface IDs
-
- const IID BASED_CODE IID_DSimple =
- { 0xc48a81e1, 0x4384, 0x11d0, { 0x9c, 0x9d, 0, 0, 0, 0, 0, 0 } };
- const IID BASED_CODE IID_DSimpleEvents =
- { 0xc48a81e2, 0x4384, 0x11d0, { 0x9c, 0x9d, 0, 0, 0, 0, 0, 0 } };
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Control type information
-
- static const DWORD BASED_CODE _dwSimpleOleMisc =
- OLEMISC_ACTIVATEWHENVISIBLE |
- OLEMISC_SETCLIENTSITEFIRST |
- OLEMISC_INSIDEOUT |
- OLEMISC_CANTLINKINSIDE |
- OLEMISC_RECOMPOSEONRESIZE;
-
- IMPLEMENT_OLECTLTYPE(CSimpleCtrl, IDS_SIMPLE, _dwSimpleOleMisc)
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::CSimpleCtrlFactory::UpdateRegistry -
- // Adds or removes system registry entries for CSimpleCtrl
-
- BOOL CSimpleCtrl::CSimpleCtrlFactory::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
- // afxRegApartmentThreading to 0.
-
- if (bRegister)
- return AfxOleRegisterControlClass(
- AfxGetInstanceHandle(),
- m_clsid,
- m_lpszProgID,
- IDS_SIMPLE,
- IDB_SIMPLE,
- afxRegApartmentThreading,
- _dwSimpleOleMisc,
- _tlid,
- _wVerMajor,
- _wVerMinor);
- else
- return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::CSimpleCtrl - Constructor
-
- CSimpleCtrl::CSimpleCtrl()
- {
- InitializeIIDs(&IID_DSimple, &IID_DSimpleEvents);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::~CSimpleCtrl - Destructor
-
- CSimpleCtrl::~CSimpleCtrl()
- {
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::OnDraw - Drawing function
-
- void CSimpleCtrl::OnDraw(
- CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
- {
- pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
- pdc->Ellipse(rcBounds);
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::DoPropExchange - Persistence support
-
- void CSimpleCtrl::DoPropExchange(CPropExchange* pPX)
- {
- ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
- COleControl::DoPropExchange(pPX);
-
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl::OnResetState - Reset control to default state
-
- void CSimpleCtrl::OnResetState()
- {
- COleControl::OnResetState(); // Resets defaults found in DoPropExchange
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSimpleCtrl message handlers
- void CSimpleCtrl::M1()
- {
- MessageBeep(-1);
- }
-
- long CSimpleCtrl::GetP1()
- {
- return m_p1;
- }
-
- void CSimpleCtrl::SetP1(long nNewValue)
- {
- m_p1 = nNewValue;
- SetModifiedFlag();
- }
-
- BEGIN_INTERFACE_MAP(CSimpleCtrl, COleControl)
- INTERFACE_PART(CSimpleCtrl, DIID__DSimple, Dispatch )
- INTERFACE_PART(CSimpleCtrl, IID__DSimpleDual, Nested )
- END_INTERFACE_MAP()
-
- DELEGATE_DUAL_INTERFACE(CSimpleCtrl, Nested)
-
- STDMETHODIMP CSimpleCtrl::XNested::put_P1(long newval)
- {
- METHOD_PROLOGUE(CSimpleCtrl, Nested)
-
- pThis->SetP1(newval);
- return NOERROR;
- }
-
- STDMETHODIMP CSimpleCtrl::XNested::get_P1(long * retval)
- {
- METHOD_PROLOGUE(CSimpleCtrl, Nested)
-
- *retval = pThis->GetP1();
- return NOERROR;
- }
-
- STDMETHODIMP CSimpleCtrl::XNested::M1()
- {
- METHOD_PROLOGUE(CSimpleCtrl, Nested)
-
- pThis->M1();
- return NOERROR;
- }
-