📄 rxbutton.cpp
字号:
// RxButton.cpp : implementation file
//
#include "stdafx.h"
#include "NoteBook.h"
#include "RxButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRxButton
CRxButton::CRxButton()
{
}
CRxButton::~CRxButton()
{
}
BEGIN_MESSAGE_MAP(CRxButton, CButton)
//{{AFX_MSG_MAP(CRxButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRxButton message handlers
void CRxButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC* pDC;
pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
UINT state=lpDrawItemStruct->itemState;
CRect rect=lpDrawItemStruct->rcItem;
CBitmap bitDown,bitNomal;
bitNomal.LoadBitmap(m_ResDown);
bitDown.LoadBitmap(m_ResNoNal);
CDC NomalDC,DownDC;
NomalDC.CreateCompatibleDC(pDC);
DownDC.CreateCompatibleDC(pDC);
NomalDC.SelectObject(bitNomal);
DownDC.SelectObject(bitDown);
if(state&ODS_FOCUS)
pDC->SetTextColor(RGB(0,0,255));
else
pDC->SetTextColor(RGB(255,255,255));
if(state&ODS_SELECTED)
{
pDC->BitBlt(0,0,100,100,&DownDC,0,0,SRCCOPY);
pDC->SetTextColor(RGB(0,0,0));
}
else
{
pDC->BitBlt(0,0,100,100,&NomalDC,0,0,SRCCOPY);
}
//写按钮文本
pDC->SetBkMode(TRANSPARENT);
CString sCaption;
this->GetWindowText(sCaption);
pDC->DrawText(sCaption,rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
bitNomal.DeleteObject();
bitDown.DeleteObject();
NomalDC.DeleteDC();
DownDC.DeleteDC();
}
void CRxButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CButton::PreSubclassWindow();
}
void CRxButton::Bitmap(UINT ResNoNal, UINT ResDown)
{
m_ResDown=ResDown;
m_ResNoNal=ResNoNal;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -