1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#if !defined(AFX_MYBUTTON_H__0EFA9690_5DE5_4E5F_B0ED_F2AEF9E652F5__INCLUDED_)
#define AFX_MYBUTTON_H__0EFA9690_5DE5_4E5F_B0ED_F2AEF9E652F5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Mybutton.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMybutton window
class CMybutton : public CButton
{
// Construction
public:
CMybutton();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMybutton)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMybutton();
// Generated message map functions
protected:
//{{AFX_MSG(CMybutton)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYBUTTON_H__0EFA9690_5DE5_4E5F_B0ED_F2AEF9E652F5__INCLUDED_)
// .cpp
#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)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMybutton message handlers
void CMybutton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
ASSERT(lpDrawItemStruct != NULL);
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
//UINT nState = lpDrawItemStruct->itemState;
CRect itemRect = lpDrawItemStruct->rcItem;
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&MemDC,itemRect.Width(),itemRect.Height());
CBitmap *pOldBitmap =MemDC.SelectObject (&bmp);
MemDC.PatBlt(0,0,itemRect.Width(),itemRect.Height(),WHITENESS);
MemDC.MoveTo(10,10);
MemDC.LineTo(20,20);
pDC->BitBlt(0,0,itemRect.Width(),itemRect.Height(),&MemDC,0,0,SRCCOPY);
MemDC.SelectObject (pOldBitmap);
}
void CMybutton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
// Switch to owner-draw
ModifyStyle(SS_TYPEMASK, BS_OWNERDRAW, SWP_FRAMECHANGED);
CButton::PreSubclassWindow();
} |
Partager