資源簡介
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最好的中文教程
評論
共有 條評論