// CardsCtl.cpp : Implementation of the CCardsCtrl ActiveX Control class.
#include "stdafx.h"
#include "Cards.h"
#include "CardsCtl.h"
#include "CardsPpg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CCardsCtrl, COleControl)
/////////////////////////////////////////////////////////////////////////////
// Message map
BEGIN_MESSAGE_MAP(CCardsCtrl, COleControl)
//{{AFX_MSG_MAP(CCardsCtrl)
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_MENUITEM_ABOUT, OnMenuitemAbout)
ON_UPDATE_COMMAND_UI(ID_MENUITEM_ABOUT, OnUpdateMenuitemAbout)
ON_COMMAND(ID_MENUITEM_HELP, OnMenuitemHelp)
ON_UPDATE_COMMAND_UI(ID_MENUITEM_HELP, OnUpdateMenuitemHelp)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(CCardsCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CCardsCtrl)
DISP_PROPERTY_EX(CCardsCtrl, "value", GetValue, SetValue, VT_I2)
DISP_PROPERTY_EX(CCardsCtrl, "background", GetBackground, SetBackground, VT_BOOL)
DISP_PROPERTY_EX(CCardsCtrl, "backbmp", GetBackbmp, SetBackbmp, VT_I2)
DISP_PROPERTY_EX(CCardsCtrl, "CancelPopup", GetCancelPopup, SetCancelPopup, VT_BOOL)
DISP_PROPERTY_EX(CCardsCtrl, "IsMove", GetIsMove, SetIsMove, VT_BOOL)
DISP_PROPERTY_EX(CCardsCtrl, "IsGoHome", GetIsGoHome, SetIsGoHome, VT_BOOL)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CCardsCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
/////////////////////////////////////////////////////////////////////////////
// Event map
BEGIN_EVENT_MAP(CCardsCtrl, COleControl)
//{{AFX_EVENT_MAP(CCardsCtrl)
EVENT_STOCK_CLICK()
EVENT_STOCK_DBLCLICK()
EVENT_STOCK_MOUSEDOWN()
EVENT_STOCK_MOUSEMOVE()
EVENT_STOCK_MOUSEUP()
//}}AFX_EVENT_MAP
END_EVENT_MAP()
/////////////////////////////////////////////////////////////////////////////
// Property pages
// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(CCardsCtrl, 1)
PROPPAGEID(CCardsPropPage::guid)
END_PROPPAGEIDS(CCardsCtrl)
/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CCardsCtrl, "CARDS.CardsCtrl.1",
0xf968806, 0xd214, 0x11d5, 0x90, 0x22, 0x52, 0x54, 0xab, 0x12, 0x3a, 0x61)
/////////////////////////////////////////////////////////////////////////////
// Type library ID and version
IMPLEMENT_OLETYPELIB(CCardsCtrl, _tlid, _wVerMajor, _wVerMinor)
/////////////////////////////////////////////////////////////////////////////
// Interface IDs
const IID BASED_CODE IID_DCards =
{ 0xf968804, 0xd214, 0x11d5, { 0x90, 0x22, 0x52, 0x54, 0xab, 0x12, 0x3a, 0x61 } };
const IID BASED_CODE IID_DCardsEvents =
{ 0xf968805, 0xd214, 0x11d5, { 0x90, 0x22, 0x52, 0x54, 0xab, 0x12, 0x3a, 0x61 } };
/////////////////////////////////////////////////////////////////////////////
// Control type information
static const DWORD BASED_CODE _dwCardsOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CCardsCtrl, IDS_CARDS, _dwCardsOleMisc)
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::CCardsCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CCardsCtrl
BOOL CCardsCtrl::CCardsCtrlFactory::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_CARDS,
IDB_CARDS,
afxRegApartmentThreading,
_dwCardsOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::CCardsCtrl - Constructor
CCardsCtrl::CCardsCtrl()
{
InitializeIIDs(&IID_DCards, &IID_DCardsEvents);
value=1;backbmp=1;
IsMove=false;m_IsMove=false;IsGoHome=true;
// TODO: Initialize your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::~CCardsCtrl - Destructor
CCardsCtrl::~CCardsCtrl()
{
// TODO: Cleanup your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::OnDraw - Drawing function
void CCardsCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
//让控件里显示扑克牌的图形
CBitmap *pOldBitmap;
CBitmap bitmap;
CRect rect;
GetClientRect(rect);
CDC ppdc;
CClientDC dc(this);
ppdc.CreateCompatibleDC(&dc);
if(background)//背景图案
{
if(backbmp==1)bitmap.LoadBitmap(255);
if(backbmp==2)bitmap.LoadBitmap(256);
}
else//前景图案
bitmap.LoadBitmap(IDB_BITMAP1+value-1);
pOldBitmap=ppdc.SelectObject(&bitmap);
dc.BitBlt(0,0,rect.Width(),rect.Height(),&ppdc,0,0,SRCCOPY);
ppdc.SelectObject(pOldBitmap);
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::DoPropExchange - Persistence support
void CCardsCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::OnResetState - Reset control to default state
void CCardsCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
// TODO: Reset any other control state here.
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl::AboutBox - Display an "About" box to the user
void CCardsCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_CARDS);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCardsCtrl message handlers
short CCardsCtrl::GetValue()
{
// TODO: Add your property handler here
return value;
}
void CCardsCtrl::SetValue(short nNewValue)
{
// TODO: Add your property handler here
value=nNewValue;
SetModifiedFlag();
Invalidate();//立即刷新
}
BOOL CCardsCtrl::GetBackground()
{
// TODO: Add your property handler here
return background;
}
void CCardsCtrl::SetBackground(BOOL bNewValue)
{
// TODO: Add your property handler here
background=bNewValue;
SetModifiedFlag();
Invalidate();
}
short CCardsCtrl::GetBackbmp()
{
// TODO: Add your property handler here
return backbmp;
}
void CCardsCtrl::SetBackbmp(short nNewValue)
{
// TODO: Add your property handler here
backbmp=nNewValue;
SetModifiedFlag();
Invalidate();
}
void CCardsCtrl::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
if(!CancelPopup)
{
CMenu menu1;
menu1.LoadMenu(IDR_MENU1);
menu1.GetSubMenu(0)->TrackPopupMenu(TPM_CENTERALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,point.x,point.y,this);
}
}
void CCardsCtrl::OnMenuitemAbout()
{
// TODO: Add your command handler code here
MessageBox("控件制作:龙浩天\r\nE_mail:cyuyan@sohu.com","54张牌的扑克控件1.0");
}
void CCardsCtrl::OnUpdateMenuitemAbout(CCmdUI* pCmdUI)
{
// TODO: Add your comm
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
cards.zip (76个子文件)
红8.bmp 3KB
CardsCtl.cpp 10KB
÷K.bmp 3KB
Cards.ocx 204KB
方7.bmp 3KB
方2.bmp 3KB
Cards.h 944B
黑J.bmp 3KB
红3.bmp 3KB
Cards.cpp 2KB
方6.bmp 3KB
StdAfx.cpp 204B
CardsPpg.h 1KB
resource.h 4KB
方A.bmp 3KB
÷10.bmp 1KB
黑9.bmp 1KB
CardsPpg.cpp 3KB
红6.bmp 3KB
方K.bmp 3KB
Cards.odl 2KB
Cards.dep 395B
大王.bmp 3KB
Cards.dsw 535B
红9.bmp 3KB
红J.bmp 3KB
Cards.def 218B
黑6.bmp 1KB
黑4.bmp 1KB
÷8.bmp 1KB
方J.bmp 3KB
黑5.bmp 1KB
红10.bmp 3KB
红5.bmp 3KB
红2.bmp 3KB
方Q.bmp 3KB
÷9.bmp 1KB
÷2.bmp 1KB
方5.bmp 3KB
方4.bmp 3KB
背景02.bmp 8KB
黑8.bmp 1KB
小王.bmp 1KB
÷A.bmp 1KB
黑K.bmp 3KB
黑7.bmp 1KB
StdAfx.h 1KB
红7.bmp 3KB
CardsCtl.bmp 238B
黑10.bmp 1KB
CardsCtl.h 3KB
÷5.bmp 1KB
÷6.bmp 1KB
背景01.bmp 20KB
黑A.bmp 1KB
红K.bmp 3KB
方9.bmp 3KB
红A.bmp 3KB
方3.bmp 3KB
红Q.bmp 3KB
红4.bmp 3KB
÷7.bmp 1KB
Cards.mak 13KB
黑3.bmp 1KB
黑Q.bmp 3KB
÷Q.bmp 3KB
Cards.ico 1KB
÷J.bmp 3KB
方10.bmp 3KB
方8.bmp 3KB
黑2.bmp 1KB
Cards.clw 1KB
÷3.bmp 1KB
÷4.bmp 1KB
Cards.dsp 12KB
Cards.rc 9KB
共 76 条
- 1
资源评论
ALong_Yue
- 粉丝: 16
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功