gps/GPSResources/tcpmp/MusicPlayer/BmpButton.cpp

135 lines
2.6 KiB
C++
Raw Normal View History

2019-05-01 12:32:35 +00:00
// BmpButton.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
//
#include "stdafx.h"
#include "MusicPlayer.h"
#include "BmpButton.h"
// CBmpButton
IMPLEMENT_DYNAMIC(CBmpButton, CButton)
CBmpButton::CBmpButton()
{
m_InitDC = FALSE;
m_NormalDC.CreateCompatibleDC(NULL);
m_DisableDC.CreateCompatibleDC(NULL);
m_DownDC.CreateCompatibleDC(NULL);
m_ButType = BT_NORMAL;
}
CBmpButton::~CBmpButton()
{
m_DisableDC.DeleteDC();
m_DownDC.DeleteDC();
m_NormalDC.DeleteDC();
}
BEGIN_MESSAGE_MAP(CBmpButton, CButton)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CBmpButton <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CBmpButton::LoadBitmaps(UINT nIDBitmapResource, UINT nIDBitmapResourceSel, UINT nIDBitmapResourceDisabled)
{
CBitmap bmp;
bmp.LoadBitmap(nIDBitmapResource);
m_NormalDC.SelectObject(&bmp);
bmp.DeleteObject();
if (nIDBitmapResourceSel != 0)
{
bmp.LoadBitmap(nIDBitmapResourceSel);
m_DownDC.SelectObject(&bmp);
bmp.DeleteObject();
m_ButType |= BT_DOWN;
}
if (nIDBitmapResourceDisabled != 0)
{
bmp.LoadBitmap(nIDBitmapResourceDisabled);
m_DisableDC.SelectObject(&bmp);
bmp.DeleteObject();
m_ButType |= BT_DISABLE;
}
m_InitDC = TRUE;
}
void CBmpButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>
CRect rect;
GetClientRect(&rect);
UINT status = lpDrawItemStruct->itemState;
CClientDC dc(this);
m_Status = BTS_NORMAL;
dc.BitBlt(0,0,rect.Width(),rect.Height(),&m_NormalDC,0,0,SRCCOPY);
if (status & ODS_DISABLED)
{
dc.BitBlt(0,0,rect.Width(),rect.Height(),&m_DisableDC,0,0,SRCCOPY);
m_Status = BTS_DISABLE;
}
else if (status & ODS_SELECTED)
{
m_Status = BTS_DOWN;
dc.BitBlt(0,0,rect.Width(),rect.Height(),&m_DownDC,0,0,SRCCOPY);
}
}
void CBmpButton::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> CButton::OnPaint()
if (m_InitDC)
{
CRect rect;
GetClientRect(&rect);
if (IsWindowEnabled())
{
dc.BitBlt(0,0,rect.Width(),rect.Height(),&m_NormalDC,0,0,SRCCOPY);
}
else
{
dc.BitBlt(0,0,rect.Width(),rect.Height(),&m_DisableDC,0,0,SRCCOPY);
}
}
}
BOOL CBmpButton::OnEraseBkgnd(CDC* pDC)
{
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
return FALSE;
// return CButton::OnEraseBkgnd(pDC);
}
void CBmpButton::PreSubclassWindow()
{
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
// <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>ʽΪ<CABD>Ի水ť
ModifyStyle(0, GetStyle()|BS_OWNERDRAW);
CButton::PreSubclassWindow();
}
void CBmpButton::SetButType(int nType)
{
m_ButType |= nType;
}