资源简介
CSDN上原有此类资源,但却使用了全局函数,本人稍微修改封装成了一个独立的类。
代码片段和文件信息
// RoundButton.cpp : implementation file
//
// Round Buttons!
//
// Written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au)
// Copyright (c) 19971998.
//
// Modified: 2 Feb 1998 - Fix vis problem CRgn resource leak
// button reposition code redone. CJM.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent and
// providing that this notice and the authors name is included. If
// the source code in this file is used in any commercial application
// then a simple email would be nice.
//
// This file is provided “as is“ with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer causes your pet cat to fall ill increases baldness or
// makes you car start emitting strange noises when you start it up.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
//
/////////////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include
#include “RoundButton.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRoundButton
CRoundButton::CRoundButton()
{
m_bDrawDashedFocusCircle = TRUE;
}
CRoundButton::~CRoundButton()
{
m_rgn.Deleteobject();
}
BEGIN_MESSAGE_MAP(CRoundButton CButton)
//{{AFX_MSG_MAP(CRoundButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRoundButton message handlers
void CRoundButton::PreSubclassWindow()
{
CButton::PreSubclassWindow();
Modifystyle(0 BS_OWNERDRAW);
CRect rect;
GetClientRect(rect);
// Resize the window to make it square
rect.bottom = rect.right = min(rect.bottomrect.right);
// Get the vital statistics of the window
m_ptCentre = rect.CenterPoint();
m_nRadius = rect.bottom/2-1;
// Set the window region so mouse clicks only activate the round section
// of the button
m_rgn.Deleteobject();
SetWindowRgn(NULL FALSE);
m_rgn.CreateEllipticRgnIndirect(rect);
SetWindowRgn(m_rgn TRUE);
// Convert client coords to the parents client coords
ClientToScreen(rect);
CWnd* pParent = GetParent();
if (pParent) pParent->ScreenToClient(rect);
// Resize the window
MoveWindow(rect.left rect.top rect.Width() rect.Height() TRUE);
}
void CRoundButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(lpDrawItemStruct != NULL);
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rect = lpDrawItemStruct->rcItem;
UINT state = lpDrawItemStruct->itemState;
UINT nstyle = Getstyle();
int
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9310 2009-12-13 21:35 RoundButtons\RoundButton.cpp
文件 2620 2009-12-13 21:30 RoundButtons\RoundButton.h
目录 0 2009-12-13 20:04 RoundButtons
----------- --------- ---------- ----- ----
11930 3
- 上一篇:C语言课程设计实习报告
- 下一篇:CodeSys最好的中文教程
相关资源
- mfc 串口数据绘曲线图
- MFC编程自己的简单记事本教学视频和
- Devc++5.11
- MFCApplication1.zip
- MFC实现获取Edit控件内容写入本地TXT文
- 利用mfc实现的udp通信,包括,客户端
- 车牌识别系统源代码
- VC++6.0绿色版和番茄助手
- vc++ 条形码 二维码 识别
- 非常完整的ffmpeg+mfc播放器
- MFC 编写的文本编辑器
- 北邮程序实践--基于VS2010MFC的简单聊天
- 基于mfc和opengl的6R机械臂仿真程序
- MFC 美化界面代码
- 制作带MFC界面的DLL以及调用
- 基于mfc十段均衡器的设计
- 深入浅出MFC简体中文版侯俊杰
- MFC快速实现对话框等比例的放大缩小
- vs2010 MFC+ADO方式连接sql server实现商品
- MFC-MCI简单音乐播放器源码
- MFC对话框中从文件中插入图片VS2010
- 《C++游戏开发》笔记十一 平滑动画
- 《MFC游戏开发》笔记十 碰撞检测 配套
- 《MFC游戏开发》笔记三 透明贴图 配套
- 《MFC游戏开发》笔记八 粒子系统 配套
- MFC实现实时曲线显示
- MFC CSerialPort类串口通信
- mfc+opencv读取摄像头视频并实现抓图
- PCL与MFC配合编译
- [MFC]很好用的图片浏览器
评论
共有 条评论