?? colorbutton.cpp
字號:
// ColorButton.cpp : implementation file
//
#include "stdafx.h"
#include "ColorButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorButton
CColorButton::CColorButton()
{
m_clrBkColor = RGB(198, 10, 314);
m_clrTextColor = RGB(200, 211, 10);
}
CColorButton::~CColorButton()
{
}
BEGIN_MESSAGE_MAP(CColorButton, CButton)
//{{AFX_MSG_MAP(CColorButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorButton message handlers
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC dc;
CRect rect;
COLORREF clrOldColor;
dc.Attach(lpDrawItemStruct->hDC);
rect = lpDrawItemStruct->rcItem;
dc.FillSolidRect(rect, m_clrBkColor);
UINT nState = lpDrawItemStruct->itemState;
if((nState & ODS_SELECTED))
{//按下
dc.Draw3dRect(&rect, RGB(128, 128, 128) , RGB(255, 255, 255));
}
else
{
dc.Draw3dRect(&rect, RGB(255, 255, 255), RGB(128, 128, 128));
}
if((nState & ODS_DISABLED))
{
clrOldColor = dc.SetTextColor(RGB(128, 128, 128));
}
else
{
clrOldColor = dc.SetTextColor(m_clrTextColor);
}
dc.SetBkMode(TRANSPARENT);
dc.DrawText(m_szCaption, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
dc.SetTextColor(clrOldColor);
if((nState & ODS_FOCUS))
{
int nChange = 3;
rect.top += nChange;
rect.left += nChange;
rect.right -= nChange;
rect.bottom -= nChange;
dc.DrawFocusRect(rect);
}
dc.Detach();
}
void CColorButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
SetButtonStyle(BS_OWNERDRAW);
GetWindowText(m_szCaption);
CButton::PreSubclassWindow();
}
void CColorButton::SetBtnBkColor(COLORREF clrColor)
{
m_clrBkColor = clrColor;
Invalidate();
}
void CColorButton::SetBtnTextColor(COLORREF clrColor)
{
m_clrTextColor = clrColor;
Invalidate();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -