避免窗口中的文字闪烁 [英] avoid flickering of text in window

查看:70
本文介绍了避免窗口中的文字闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我有显示在窗口上的文本数据.现在,我想避免该数据闪烁.即使无法避免闪烁,我还是尝试了使用存储设备上下文.这是我的示例代码.如果有人可以找到解决方案,请帮助我.

Sir,

I had text data which I display on the window. Now I want to avoid the flickering of that data. I tried with the memory device context even though I am not able to avoid the flickering. Here is my sample code for it. If anyone can find a solution, please help me.

CDC m_pDC;
m_bitmap.SetBitmapBits(R2_WHITE,RGB(0,0,0));
GetClientRect(&rect);
m_pDC.CreateCompatibleDC(&dc);
m_bitmap.CreateBitmap (rect.Width(), rect.Height(),0,0,NULL);
m_pDC.SelectObject(&m_bitmap);
m_pDc.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
m_bitmap.DeleteObject();
    dc.BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&m_pDC,rect.left,rect.top,SRCCOPY);
::ReleaseDC(m_hWnd, m_pDC.GetSafeHdc());


谢谢
sarfaraz


Thank you,
sarfaraz

推荐答案

有帮助吗?
http://cboard.cprogramming.com/game-programming/49608-textout-flickering.html [^ ]
Does this help?
http://cboard.cprogramming.com/game-programming/49608-textout-flickering.html[^]


,您需要使 WM_ERASEBKGND [ ^ ]消息,只需返回FALSE.

这会覆盖所有内容,这是导致闪烁的原因.
然后,您实际上需要擦除WM_PAINT中的背景(或控件的等效消息),作为内存DC的一部分. (这就是 FillRect() [
you need to silence the WM_ERASEBKGND[^] message by handling it and simply returning FALSE.

This paints over everything, which is the cause of your flickering.

Then you need to actually erase the background in your WM_PAINT (or equivalent message for your control) as part of the memory DC. (This would simply be FillRect()[^] with a brush of white or whatever colour (perhaps COLOR_BTNFACE))


这篇关于避免窗口中的文字闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆