找回密码
 立即注册
LPDRAWITEMSTRUCTCMyBtnrectwrect | GDI/图象编程 2022-09-23 131 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
前次看到一个贴子,要圆形按钮的代码
偶找到了
贴子原出处及下载源码:
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_源码