You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
#pragma once
|
|
#include "stdafx.h"
|
|
|
|
#ifndef BACK_COLOR
|
|
//COLORREF DrawerBackColor = RGB(192, 192, 192);
|
|
|
|
#define BACK_COLOR
|
|
#endif // !BACK_COLOR
|
|
class DCHelp
|
|
{
|
|
public:
|
|
//static COLORREF DrawerBackColor;// = RGB(192, 192, 192);
|
|
// 清空画布
|
|
static bool ClearDC(CDC* pCdc, COLORREF clrBack)
|
|
{
|
|
//if (symbolFlag)
|
|
//{
|
|
// clrBack = RGB(192, 192, 192);
|
|
//}
|
|
//else
|
|
//{
|
|
// clrBack = RGB(255, 255, 255);
|
|
//}
|
|
//
|
|
CRect clip;
|
|
pCdc->GetClipBox(clip);
|
|
|
|
//if (pCdc->GetDeviceCaps(RASTERCAPS)&RC_BITBLT)
|
|
//{
|
|
// CBrush br(clrBack);
|
|
// CBrush* pOldBrush = pCdc->SelectObject(&br);
|
|
// pCdc->PatBlt(clip.left, clip.top, clip.Width(), clip.Height(), PATCOPY);//并不是所有设备支持此函数
|
|
// pCdc->SelectObject(pOldBrush);
|
|
//}
|
|
//else
|
|
pCdc->FillSolidRect(clip, clrBack);
|
|
|
|
return true;
|
|
}
|
|
// 清空画布
|
|
static bool ClearDCNull(CDC* pCdc, COLORREF clrBack)
|
|
{
|
|
CRect clip;
|
|
pCdc->GetClipBox(clip);
|
|
|
|
if (pCdc->GetDeviceCaps(RASTERCAPS)&RC_BITBLT)
|
|
{
|
|
CBrush* pBrush= CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
|
|
CBrush* pOldBrush = pCdc->SelectObject(pBrush);
|
|
pCdc->PatBlt(clip.left, clip.top, clip.Width(), clip.Height(), PATCOPY);//并不是所有设备支持此函数
|
|
pCdc->SelectObject(pOldBrush);
|
|
}
|
|
else {
|
|
|
|
CBrush *pBrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
|
|
//FromHandle一个画刷句柄转化为一个画刷对象
|
|
//GetStockObject(NULL) 获取一个透明画刷句柄
|
|
CBrush *pOldBrush = pCdc->SelectObject(pBrush);// 把画刷加载到设备表述表
|
|
pCdc->Rectangle(clip);
|
|
pCdc->SelectObject(pOldBrush);
|
|
|
|
//pCdc->FillSolidRect(clip, clrBack);
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
|
|
|