// OcxtestCtl.cpp : Implementation of the COcxtestCtrl ActiveX Control class.
#include "stdafx.h"
#include "ocxtest.h"
#include "OcxtestCtl.h"
#include "OcxtestPpg.h"
#include "Tok.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(COcxtestCtrl, COleControl)
/////////////////////////////////////////////////////////////////////////////
// Message map
BEGIN_MESSAGE_MAP(COcxtestCtrl, COleControl)
//{{AFX_MSG_MAP(COcxtestCtrl)
// NOTE - ClassWizard will add and remove message map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(COcxtestCtrl, COleControl)
//{{AFX_DISPATCH_MAP(COcxtestCtrl)
DISP_FUNCTION(COcxtestCtrl, "testocx", testocx, VT_EMPTY, VTS_NONE)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(COcxtestCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
/////////////////////////////////////////////////////////////////////////////
// Event map
BEGIN_EVENT_MAP(COcxtestCtrl, COleControl)
//{{AFX_EVENT_MAP(COcxtestCtrl)
// NOTE - ClassWizard will add and remove event map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_EVENT_MAP
END_EVENT_MAP()
/////////////////////////////////////////////////////////////////////////////
// Property pages
// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(COcxtestCtrl, 1)
PROPPAGEID(COcxtestPropPage::guid)
END_PROPPAGEIDS(COcxtestCtrl)
/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(COcxtestCtrl, "OCXTEST.OcxtestCtrl.1",
0x4fcae43f, 0x9212, 0x4ece, 0xa8, 0x4, 0xd2, 0x5d, 0x79, 0x2c, 0xce, 0xe1)
/////////////////////////////////////////////////////////////////////////////
// Type library ID and version
IMPLEMENT_OLETYPELIB(COcxtestCtrl, _tlid, _wVerMajor, _wVerMinor)
/////////////////////////////////////////////////////////////////////////////
// Interface IDs
const IID BASED_CODE IID_DOcxtest =
{ 0xc475316b, 0x4c89, 0x41ae, { 0x8e, 0xd0, 0x9b, 0xaa, 0x84, 0x63, 0x3c, 0x7d } };
const IID BASED_CODE IID_DOcxtestEvents =
{ 0xe0918130, 0xfb43, 0x4f1e, { 0xb4, 0x50, 0x63, 0x6c, 0x5f, 0x7b, 0xcf, 0x29 } };
/////////////////////////////////////////////////////////////////////////////
// Control type information
static const DWORD BASED_CODE _dwOcxtestOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(COcxtestCtrl, IDS_OCXTEST, _dwOcxtestOleMisc)
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::COcxtestCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for COcxtestCtrl
BOOL COcxtestCtrl::COcxtestCtrlFactory::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_OCXTEST,
IDB_OCXTEST,
afxRegApartmentThreading,
_dwOcxtestOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::COcxtestCtrl - Constructor
COcxtestCtrl::COcxtestCtrl()
{
InitializeIIDs(&IID_DOcxtest, &IID_DOcxtestEvents);
// TODO: Initialize your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::~COcxtestCtrl - Destructor
COcxtestCtrl::~COcxtestCtrl()
{
// TODO: Cleanup your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::OnDraw - Drawing function
void COcxtestCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
pdc->Ellipse(rcBounds);
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::DoPropExchange - Persistence support
void COcxtestCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::OnResetState - Reset control to default state
void COcxtestCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
// TODO: Reset any other control state here.
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl::AboutBox - Display an "About" box to the user
void COcxtestCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_OCXTEST);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// COcxtestCtrl message handlers
void COcxtestCtrl::testocx()
{
// TODO: Add your dispatch handler code here
CTok test;
test.DoModal ();
}