?? liubutton.cpp
字號:
// MyButton.cpp : implementation file
//
#include "stdafx.h"
#include "cradle.h"
#include "LiuButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLiuButton
CLiuButton::CLiuButton()
{
m_LSymbol=0;
m_text=_T("");
}
CLiuButton::~CLiuButton()
{
}
BEGIN_MESSAGE_MAP(CLiuButton, CButton)
//{{AFX_MSG_MAP(CLiuButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLiuButton message handlers
void CLiuButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
//畫按鈕邊線flag=0凸=1凹
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rect(lpDrawItemStruct->rcItem);
rect.right--;
rect.bottom--;
CPen *oldpen;
UINT color1,color2;
if(m_LSymbol==0)
{//兩種狀態(tài)的顏色處理
color1=COLOR_BTNHILIGHT;//按鈕高度顏色
color2=COLOR_BTNSHADOW; //按鈕陰影顏色
}
else
{
color1=COLOR_BTNSHADOW;
color2=COLOR_BTNHILIGHT;
// dc.SetBkColor(COLORREF(RGB(0,0,0)));
}
CPen pen1(PS_SOLID,1,::GetSysColor(color1));
CPen pen2(PS_SOLID,1,::GetSysColor(color2));
dc.SelectStockObject(NULL_BRUSH);
oldpen=dc.SelectObject(&pen1);
/* dc.MoveTo(rect.right,rect.top);//畫按鈕邊亮線
dc.LineTo(rect.left,rect.top);
dc.LineTo(rect.left,rect.bottom);
dc.SelectObject(&pen2); //畫按鈕邊暗線
dc.MoveTo(rect.right,rect.top);
dc.LineTo(rect.right,rect.bottom);
dc.LineTo(rect.left,rect.bottom);
*/
if(m_LSymbol==1)
{
dc.SelectStockObject(BLACK_PEN);//畫按鈕邊黑線
::DrawEdge(dc.GetSafeHdc(),&rect,EDGE_SUNKEN,BF_RECT);
}
else
{
CBrush brush(COLORREF(RGB(215,215,215)));
::FillRect(dc.GetSafeHdc(),&rect,(HBRUSH)(brush.GetSafeHandle()));
::DrawEdge(dc.GetSafeHdc(),&rect,EDGE_ETCHED,BF_RECT);
}
::DrawText(dc.GetSafeHdc(),m_text,m_text.GetLength(),&rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
dc.SelectObject(oldpen);
DeleteObject(pen1);
DeleteObject(pen2);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -