[GDI/图象编程] 圆形按钮

[复制链接]
发表于 2022-9-23 23:08:13
前次看到一个贴子,要圆形按钮的代码
偶找到了
贴子原出处及下载源码:
vckbase/english/code/buttonctrl/btn_circular_button.shtml.htm
首要代码:
//MyBtn.cpp:implementationfile
//
#includestdafx.h
#includeMyBtn.h
#includeMemDC.h
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CMyBtn
CMyBtn::CMyBtn()
{
}
CMyBtn::~CMyBtn()
{
}
BEGIN_MESSAGE_MAP(CMyBtn,CButton)
//{{AFX_MSG_MAP(CMyBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyBtnmessagehandlers
voidCMyBtn::SetRound(void)
{
HRGNrgn;
CRectwrect;
GetClientRect(wrect);
SetWindowRgn(NULL,FALSE);
rgn=CreateEllipticRgn(wrect.left,wrect.top,
wrect.right,wrect.bottom);
SetWindowRgn(rgn,TRUE);
}
voidCMyBtn::GradientFill(CDC
pDC,CRect
pRect)
{
CBrush
pBrush;
for(inti=0;inewCBrush(RGB(0,0,255-(i
4)));
}
intnWidth=pRect-gt;Width();
intnHeight=pRect-gt;Height();
CRectrect;
for(i=0;iFillRect(rect,pBrush);
}
for(i=0;ivoidCMyBtn:<imgsrc="biggrin.gif"smilieid="3"border="0"alt=""/>rawItem(LPDRAWITEMSTRUCTlpDrawItemStruct)
{
//TODO:Addyourcodetodrawthespecifieditem
CRectRect=lpDrawItemStruct-gt;rcItem;
CDC
pDC=CDC::FromHandle(lpDrawItemStruct-gt;hDC);
CRgnrgn;
CRectrect;
rect=Rect;
UINTstate=lpDrawItemStruct-gt;itemState;
CMemDC
pMemDC=newCMemDC(pDC,Rect);
CBrushhbr;
hbr.CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
//pDC-gt;FillRect(Rect,hbr);
pMemDC-gt;FillRect(Rect,hbr);
《VisualC++高档编程及其项目使用开发》配套代码\第7章\MyFieldTry\StdAfx.cpp
《VisualC++高档编程及其项目使用开发》配套代码\第7章\MyFieldTry\StdAfx.h

(The last time I saw a post, I wanted the code for the circular button
even found
The original source of the post and the download source code:
vckbase/english/code/buttonctrl/btn_circular_button.shtml.htm
Primary code:
//MyBtn.cpp:implementationfile
//
#includestdafx.h
#includeMyBtn.h
#includeMemDC.h
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE=__FILE__;
#endif
///////////////////////////////////////////// //////////////////////////
//CMyBtn
CMyBtn::CMyBtn()
{
}
CMyBtn::~CMyBtn()
{
}
BEGIN_MESSAGE_MAP(CMyBtn, CButton)
//{{AFX_MSG_MAP(CMyBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////// //////////////////////////
//CMyBtnmessagehandlers
voidCMyBtn::SetRound(void)
{
HRGNrgn;
CRectwrect;
GetClientRect(wrect);
SetWindowRgn(NULL, FALSE);
rgn=CreateEllipticRgn(wrect.left,wrect.top,
wrect.right,wrect.bottom);
SetWindowRgn(rgn,TRUE);
}
voidCMyBtn::GradientFill(CDC
pDC,CRect
pRect)
{
CBrush
pBrush;
for(inti=0;inewCBrush(RGB(0,0,255-(i
4)));
}
intnWidth=pRect-gt;Width();
intnHeight=pRect-gt;Height();
CRectrect;
for(i=0;iFillRect(rect,pBrush);
}
for(i=0;ivoidCMyBtn:<imgsrc="biggrin.gif"smilieid="3"border="0"alt=""/>rawItem(LPDRAWITEMSTRUCTlpDrawItemStruct)
{
//TODO:Addyourcodetodrawthespecifieditem
CRectRect=lpDrawItemStruct-gt;rcItem;
CDC
pDC=CDC::FromHandle(lpDrawItemStruct-gt;hDC);
CRgnrgn;
CRectrect;
rect=Rect;
UINTstate=lpDrawItemStruct-gt;itemState;
CMemDC
pMemDC=newCMemDC(pDC,Rect);
CBrushhbr;
hbr.CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
//pDC-gt;FillRect(Rect,hbr);
pMemDC-gt;FillRect(Rect,hbr);
"Visual C   Advanced Programming and Project Development" Supporting Code\Chapter 7\MyFieldTry\StdAfx.cpp
"Visual C   Advanced Programming and Project Development" Supporting Code\Chapter 7\MyFieldTry\StdAfx.h)

[下载]23081372210.rar




上一篇:C语言教程
下一篇:《用TCP/IP进行网际互联》_Vol2_Vol3_源码

使用道具 举报

Archiver|手机版|小黑屋|吾爱开源 |网站地图

Copyright 2011 - 2012 Lnqq.NET.All Rights Reserved( ICP备案粤ICP备14042591号-1粤ICP14042591号 )

关于本站 - 版权申明 - 侵删联系 - Ln Studio! - 广告联系

本站资源来自互联网,仅供用户测试使用,相关版权归原作者所有

快速回复 返回顶部 返回列表