MyButton.cpp
上传用户:hydatong
上传日期:2022-08-07
资源大小:219k
文件大小:1k
- // MyButton.cpp : implementation file
- //
- #include "stdafx.h"
- #include "fighter.h"
- #include "MyButton.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyButton
- CMyButton::CMyButton()
- {
- }
- CMyButton::~CMyButton()
- {
- }
- BEGIN_MESSAGE_MAP(CMyButton, CButton)
- //{{AFX_MSG_MAP(CMyButton)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyButton message handlers
- void CMyButton::SetMyBitmap(UINT nID)
- {
- m_bmp.LoadBitmap(nID);
- }
- void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
- // TODO: Add your code to draw the specified item
- CDC dc;
- dc.Attach( lpDrawItemStruct->hDC );
- CRect rc;
- GetClientRect(rc);
- CDC m_dc;
- m_dc.CreateCompatibleDC(&dc);
- m_dc.SelectObject(&m_bmp);
- if(lpDrawItemStruct->itemState & ODS_SELECTED)
- {
- dc.BitBlt(1, 1, 60, 25, &m_dc, 0, 0, SRCCOPY);
- }
- else
- {
- dc.BitBlt(0, 0, 60, 25, &m_dc, 0, 0, SRCCOPY);
- }
- }