#include "GlobalFunc.h" #include "T2BitImage.h" #include "T2DlgItemIButton.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif T2DlgItemIButton::T2DlgItemIButton(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItemButtonBase(inDoc, inImageObj, inPalette) { } /*virtual*/ BOOL T2DlgItemIButton::OnT2DlgItemEraseBkgnd(CDC* pDC) { #pragma var_order(imageRect, rect30, clientRect, newDC, image, save3, save2, text, save, rect74, brush, bitmap, hbitmap) CRect clientRect; GetClientRect(clientRect); int save = pDC->SaveDC(); pDC->SelectPalette(mPalette, false); pDC->RealizePalette(); DrawButtonBase(pDC, clientRect, GetPattern() == 100); CString text; GetWindowText(text); CRect imageRect; T2BitImage *image = GetObjectImage(imageRect, text); CRect rect30; rect30.left = (clientRect.Width() - imageRect.Width()) / 2; rect30.top = (clientRect.Height() - imageRect.Height()) / 2; rect30.right = rect30.left + imageRect.Width(); rect30.bottom = rect30.top + imageRect.Height(); int save2 = pDC->SaveDC(); CRect rect74 = imageRect; OffsetRect(&rect74, -rect74.left, -rect74.top); CDC newDC; newDC.CreateCompatibleDC(pDC); int save3 = newDC.SaveDC(); newDC.SelectPalette(mPalette, false); newDC.RealizePalette(); HBITMAP hbitmap = Create256DIBitmap(newDC.m_hDC, rect74.right, rect74.bottom); SelectObject(newDC.m_hDC, hbitmap); CBitmap bitmap; CBrush brush; image->CopyImage(&newDC, imageRect, rect74); if (!IsWindowEnabled()) { bitmap.LoadBitmap(170); brush.CreatePatternBrush(&bitmap); pDC->SelectObject(brush); pDC->BitBlt(rect30.left, rect30.top, rect30.Width(), rect30.Height(), &newDC, 0, 0, /*DPSDxax*/ 0xCA0749); } else { if (GetPattern() == 100) rect30.OffsetRect(1, 1); pDC->BitBlt(rect30.left, rect30.top, rect30.Width(), rect30.Height(), &newDC, 0, 0, SRCCOPY); } newDC.RestoreDC(save3); newDC.DeleteDC(); DeleteObject(hbitmap); pDC->RestoreDC(save2); pDC->RestoreDC(save); return true; }