【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-ExCtl.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// ExCtl.cpp : Implementation of the CExCtrl ActiveX Control class.
#include "stdafx.h"
#include "ex.h"
#include "ExCtl.h"
#include "ExPpg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CExCtrl, COleControl)
/////////////////////////////////////////////////////////////////////////////
// Message map
BEGIN_MESSAGE_MAP(CExCtrl, COleControl)
//{{AFX_MSG_MAP(CExCtrl)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(CExCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CExCtrl)
DISP_PROPERTY_NOTIFY(CExCtrl, "ColorIn", m_colorIn, OnColorInChanged, VT_COLOR)
DISP_PROPERTY_NOTIFY(CExCtrl, "ColorOut", m_colorOut, OnColorOutChanged, VT_COLOR)
DISP_PROPERTY_EX(CExCtrl, "Radius", GetRadius, SetRadius, VT_I4)
DISP_FUNCTION(CExCtrl, "DrawCircle", DrawCircle, VT_EMPTY, VTS_I4 VTS_I4)
DISP_FUNCTION(CExCtrl, "PtInCircle", PtInCircle, VT_BOOL, VTS_I4 VTS_I4)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CExCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
/////////////////////////////////////////////////////////////////////////////
// Event map
BEGIN_EVENT_MAP(CExCtrl, COleControl)
//{{AFX_EVENT_MAP(CExCtrl)
EVENT_CUSTOM("ClickIn", FireClickIn, VTS_XPOS_PIXELS VTS_YPOS_PIXELS)
EVENT_CUSTOM("ClickOut", FireClickOut, VTS_XPOS_PIXELS VTS_YPOS_PIXELS)
//}}AFX_EVENT_MAP
END_EVENT_MAP()
/////////////////////////////////////////////////////////////////////////////
// Property pages
// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(CExCtrl, 2)
PROPPAGEID(CExPropPage::guid)
PROPPAGEID(CLSID_CColorPropPage)
END_PROPPAGEIDS(CExCtrl)
/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CExCtrl, "EX.ExCtrl.1",
0x17fe8139, 0xda1f, 0x4854, 0xbc, 0xea, 0xdb, 0xa4, 0x38, 0x3e, 0x17, 0xb0)
/////////////////////////////////////////////////////////////////////////////
// Type library ID and version
IMPLEMENT_OLETYPELIB(CExCtrl, _tlid, _wVerMajor, _wVerMinor)
/////////////////////////////////////////////////////////////////////////////
// Interface IDs
const IID BASED_CODE IID_DEx =
{ 0x956955c4, 0x7936, 0x4402, { 0xa5, 0x74, 0x42, 0x3a, 0x7b, 0x69, 0xcb, 0x1c } };
const IID BASED_CODE IID_DExEvents =
{ 0xe0925b12, 0xeba1, 0x49da, { 0xae, 0x6a, 0x5b, 0x32, 0x5, 0x39, 0x59, 0xe5 } };
/////////////////////////////////////////////////////////////////////////////
// Control type information
static const DWORD BASED_CODE _dwExOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CExCtrl, IDS_EX, _dwExOleMisc)
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::CExCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CExCtrl
BOOL CExCtrl::CExCtrlFactory::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_EX,
IDB_EX,
afxRegApartmentThreading,
_dwExOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::CExCtrl - Constructor
CExCtrl::CExCtrl()
{
InitializeIIDs(&IID_DEx, &IID_DExEvents);
// TODO: Initialize your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::~CExCtrl - Destructor
CExCtrl::~CExCtrl()
{
// TODO: Cleanup your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::OnDraw - Drawing function
void CExCtrl::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);
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::DoPropExchange - Persistence support
void CExCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
PX_Long(pPX,_T("Radius"),m_rd,2);
PX_Long(pPX,_T("ColorIn"),(long &)m_colorIn,RGB(255,0,0));
PX_Long(pPX,_T("ColorOut"),(long &)m_colorOut,RGB(0,255,0));
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::OnResetState - Reset control to default state
void CExCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
// TODO: Reset any other control state here.
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl::AboutBox - Display an "About" box to the user
void CExCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_EX);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CExCtrl message handlers
void CExCtrl::OnColorInChanged()
{
// TODO: Add notification handler code
InvalidateControl();
SetModifiedFlag();
}
void CExCtrl::OnColorOutChanged()
{
// TODO: Add notification handler code
InvalidateControl();
SetModifiedFlag();
}
long CExCtrl::GetRadius()
{
// TODO: Add your property handler here
return m_rd;
}
void CExCtrl::SetRadius(long nNewValue)
{
// TODO: Add your property handler here
m_rd=nNewValue;
SetModifiedFlag();
}
void CExCtrl::DrawCircle(long x, long y)
{
// TODO: Add your dispatch handler code here
CDC* pDC;
pDC=GetDC();
CBrush *pOldBrush;
CBrush *p
上一篇:
EXCHANGECOLOR.cpp
下一篇:
打造自主高品质轻卡 江铃凯运再出强劲版