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
|
#include "StdAfx.h"
#include "T2BitImage.h"
#include "T2DlgItemImage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2DlgItemImage::T2DlgItemImage(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItem(inDoc, inImageObj, inPalette)
{
}
/*virtual*/ int T2DlgItemImage::Create(const char* inName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) {
#pragma var_order(clientRect, image, imageRect)
CRect imageRect;
mValue = -1;
T2BitImage *image = GetObjectImage(imageRect, inName, mValue);
CRect clientRect = inRect;
if (image) {
clientRect.right = clientRect.left + imageRect.Width();
clientRect.bottom = clientRect.top + imageRect.Height();
}
return T2DlgItem::Create(inName, inStyle, clientRect, inParentWnd, inID);
}
/*virtual*/ BOOL T2DlgItemImage::OnT2DlgItemEraseBkgnd(CDC* pDC) {
#pragma var_order(imageRect, clientRect, image)
CRect clientRect;
CRect imageRect;
GetClientRect(clientRect);
T2BitImage *image = GetDrawImage(imageRect);
if (image) {
int save = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
SetStretchBltMode(pDC->m_hDC, COLORONCOLOR);
StretchDIBits(pDC->m_hDC, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), imageRect.left, imageRect.bottom + 1, imageRect.Width(), -imageRect.Height(), image->mData, (BITMAPINFO *) &image->mBitmap, DIB_PAL_COLORS, SRCCOPY);
pDC->RestoreDC(save);
}
return true;
}
void T2DlgItemImage::AdjustSize() {
CRect imageRect;
if (GetDrawImage(imageRect))
SetWindowPos(NULL, 0, 0, imageRect.Width(), imageRect.Height(), SWP_NOMOVE | SWP_NOZORDER);
}
T2BitImage* T2DlgItemImage::GetDrawImage(CRect& outRect) const {
CString text;
GetDescriptor(text);
return GetObjectImage(outRect, text, mValue);
}
|