-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImageCtrl.cpp
73 lines (49 loc) · 1.28 KB
/
ImageCtrl.cpp
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
// ImageCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "CPUBench2004.h"
#include "ImageCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImageCtrl
CImageCtrl::CImageCtrl()
{
bLoaded=false;
}
CImageCtrl::~CImageCtrl()
{
bmp.DeleteObject();
}
void CImageCtrl::LoadImage(CString str) {
if(!bLoaded) {
bmp.LoadBitmap(str);
bLoaded=true;
}
}
BEGIN_MESSAGE_MAP(CImageCtrl, CStatic)
//{{AFX_MSG_MAP(CImageCtrl)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImageCtrl message handlers
void CImageCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetWindowRect(&rect);
dc.DrawState(CPoint(0,0),CSize(rect.Width(),rect.Height()),&bmp,DST_BITMAP);
CPen p(PS_SOLID,1,RGB(128,128,141));
CGdiObject *pOb=dc.SelectObject(&p);
dc.MoveTo(0,0);
dc.LineTo(rect.Width(),0);
dc.LineTo(rect.Width(),rect.Height());
dc.LineTo(0,rect.Height());
dc.LineTo(0,0);
dc.SelectObject(pOb);
// Do not call CStatic::OnPaint() for painting messages
}