Activex - Own
Activex - Own
In FirstCtl.cpp
#include "stdafx.h"
#include "First.h"
#include "FirstCtl.h"
#include "FirstPpg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CFirstCtrl, COleControl)
// Message map
BEGIN_MESSAGE_MAP(CFirstCtrl, COleControl)
//{{AFX_MSG_MAP(CFirstCtrl)
// 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(CFirstCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CFirstCtrl)
// NOTE - ClassWizard will add and remove dispatch map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CFirstCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox,
VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
// Event map
BEGIN_EVENT_MAP(CFirstCtrl, COleControl)
//{{AFX_EVENT_MAP(CFirstCtrl)
// 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
BEGIN_PROPPAGEIDS(CFirstCtrl, 1)
PROPPAGEID(CFirstPropPage::guid)
END_PROPPAGEIDS(CFirstCtrl)
IMPLEMENT_OLECREATE_EX(CFirstCtrl, "FIRST.FirstCtrl.1",
0xde3cc48a, 0x2239, 0x47a4, 0x93, 0x8d, 0xac, 0xac, 0x10, 0x7c, 0xb2,
0xbf)
// Interface IDs
// CFirstCtrl::CFirstCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CFirstCtrl
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_FIRST,
IDB_FIRST,
afxRegApartmentThreading,
_dwFirstOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
// CFirstCtrl::CFirstCtrl - Constructor
CFirstCtrl::CFirstCtrl()
{
InitializeIIDs(&IID_DFirst, &IID_DFirstEvents);
// CFirstCtrl::~CFirstCtrl - Destructor
CFirstCtrl::~CFirstCtrl()
{ }
void CFirstCtrl::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->Rectangle(rcBounds);
}
void CFirstCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
void CFirstCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_FIRST);
dlgAbout.DoModal();
}
Dialog Design:
In ActiveXCtrlOwnView.cpp
#include "stdafx.h"
#include "ActiveXCtrlOwn.h"
#include "ActiveXCtrlOwnDoc.h"
#include "ActiveXCtrlOwnView.h"
#include "Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CActiveXCtrlOwnView
IMPLEMENT_DYNCREATE(CActiveXCtrlOwnView, CView)
BEGIN_MESSAGE_MAP(CActiveXCtrlOwnView, CView)
//{{AFX_MSG_MAP(CActiveXCtrlOwnView)
// NOTE - the ClassWizard will add and remove mapping macros
here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CActiveXCtrlOwnView construction/destruction
CActiveXCtrlOwnView::CActiveXCtrlOwnView()
{ }
CActiveXCtrlOwnView::~CActiveXCtrlOwnView()
{ }
// CActiveXCtrlOwnView drawing
// CActiveXCtrlOwnView printing
#ifdef _DEBUG
void CActiveXCtrlOwnView::AssertValid() const
{
CView::AssertValid();
}
OUTPUT