benny5609的专栏

人生,到世上走一遭,只不过是单纯的体验与学习认识,当我们在临死的时候,可以光荣地对自己说:"我已领略过"便不枉此生。...

用双缓存绘制方法减少绘图时的闪屏

CClientDC dc(this);

CRect rClient;
GetClientRect(&rClient);

CBitmap MemBmp;
MemBmp.CreateCompatibleBitmap(&dc, rClient.Width(), rClient.Height());

CDC MemDC;
MemDC.CreateCompatibleDC(NULL);
CBitmap* pOldMemBmp = MemDC.SelectObject(&MemBmp);

CDC bmpDC;
bmpDC.CreateCompatibleDC(&dc);

CBitmap* pOldBitmap = bmpDC.SelectObject(CBitmap::FromHandle(m_hBgBmp));
MemDC.BitBlt(rClient.left, rClient.top, m_SizeBg.cx, m_SizeBg.cy, &bmpDC, 0, 0, SRCCOPY);
bmpDC.SelectObject(pOldBitmap);
pOldBitmap = NULL;

CString sText = "……";
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 14;
lf.lfWeight = FW_BOLD;
strcpy_s(lf.lfFaceName, LF_FACESIZE, "宋体");
font.CreateFontIndirect(&lf);
CFont* pOldFont = MemDC.SelectObject(&font);
MemDC.SetBkMode(TRANSPARENT);
MemDC.SetTextColor(RGB(255, 255, 255));
MemDC.TextOut(12, 8, sText);
MemDC.SelectObject(pOldFont);
font.DeleteObject();
DeleteDC(bmpDC);

dc.BitBlt(rClient.left, rClient.top, rClient.Width(), rClient.Height(), &MemDC, 0, 0, SRCCOPY);

MemDC.SelectObject(pOldMemBmp);
MemDC.DeleteDC();
MemBmp.DeleteObject(); 

 
阅读更多
文章标签: null
个人分类: Graphic
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

用双缓存绘制方法减少绘图时的闪屏

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭