资源简介
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的TCP调试助手源码95706
- 基于mfc的多线程文件传输
- VC++ 多线程文件读写操作
- 移木块游戏,可以自编自玩,vc6.0编写
- MFC数字钟(基于VC6.0)
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC++实现CMD命令执行与获得返回信息
- ChartCtrl控件库(可在VS2019中使用)
- 商品库存管理系统 C++ MFC
- mfc 调用redis
- MFC视频播放器源码(支持avi/wma/mp3等格
- VC++基于OpenGL模拟的一个3维空间模型
- mfc绘图大全(画直线、矩形、椭圆)
- MFC控件重绘
- hook,捕获所有案件,查找所有窗口,
- (学习)VS2010之MFC入门到精通教程
- 基于VC++的SolidWorks二次开发SolidWorks
- MFC文档_视图_框架_模板结构体系深入
- 简单员工管理系统(适合初学MFC)
- 派克变换VC++源码(附文档)
- VC++ 串口
- MFC五子棋游戏
- VC++ 大富翁4_大富翁游戏源码
- MFC UDP编程
- MFC的异步网络通讯应用程序
- VC++ 摄像头视频采集与回放源程序
- C++MFC模块讲解,黑发程序员课程整理
- 转 VC++ 实现电子邮件(Email)发送
- 一个简单而强大的基于MFC的web server源
- 基于MFC的VC++仿QQ浏览器源码(雏形)
评论
共有 条评论