gdi闪烁 [英] gdi flickering

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

问题描述

我使用全局GraphicsPath

变量为我的c ++类创建了一个绘图程序。在onpaint方法中,用鼠标绘制用户绘制的线条。简单。唯一的问题是,当我使面板无效时,为了看到线条而无法使用
,它会闪烁,即使是双缓冲也是如此。

如果我只使一个矩形无效在鼠标周围,如果用户将鼠标鼠标移得过快,那么该行不会在某些时间间隔内被绘制,因为油漆

事件无法激活足够多次。我怎样才能消除闪烁或

使panle的一部分无效,以便在

抽奖时间显示整行。 (如果我在面板前带任何东西或最小化

程序,windows重绘方法显示图形)


i也尝试使用Graphics变量来在mousedown

事件的表面上绘制,但是如果你最小化程序或在图形前面带来任何东西,你就会失去你画的东西。我怎么能发生这种情况呢?


哪个问题更容易回答,如果有的话,会有所帮助。我已经花了几周时间研究这个,但我似乎无法找到答案,谢谢

-

-iwdu15

i created a paint program for my c++ class using a global GraphicsPath
variable. i the, in the onpaint method, draw the line the users draws with
the mouse. simple. the only problem is that when i invalidate the panel im
drawing on in order to see the line, it flickers, even with double buffering.
if i only invalidate a rectangle around teh mouse, if the user mouse the
mouse too fast the line wont be drawn in certain intervals because the paint
event cant fire enough times. how can i either eliminate the flickering or
invalidate a part of the panle enough that it will show the entire line at
draw time. (if i bring anything in front of the panel or minimize the
program, the windows repaint method shows the graphics)

i also tried using a Graphics variable to draw on a surface on a mousedown
event, but then if you minimized the program or brought anything in front of
the graphics, youd lose what you drew. how can i sto this from happeneing?

which ever question is easier to answer, if any, would be helpful. ive been
researching this for weeks but i cant seem to find an answer, thanks
--
-iwdu15

推荐答案

iwdu15写道:
iwdu15 wrote:
我使用全局GraphicsPath
变量为我的c ++类创建了一个绘图程序。在onpaint方法中,绘制用户使用鼠标绘制的线条。简单。唯一的问题是,当我为了看到线条而无法使用面板时,它会闪烁,即使是双缓冲也是如此。
如果我只是使鼠标周围的矩形无效,如果是用户鼠标鼠标太快,线条不能在一定的时间间隔内绘制,因为油漆事件不能激发足够的时间。我怎样才能消除闪烁或
使一部分panle无效,以便在绘制时间显示整行。 (如果我在面板前带任何东西或最小化
程序,windows重绘方法显示图形)

我也尝试使用Graphics变量在mousedown上绘制一个表面
事件,但如果你最小化程序或在图形前带来任何东西,你就会失去你所画的东西。我怎么能发生这种情况呢?

哪个问题更容易回答,如果有的话,会有所帮助。我已经好好研究了几个星期,但我似乎无法找到答案,谢谢
i created a paint program for my c++ class using a global GraphicsPath
variable. i the, in the onpaint method, draw the line the users draws with
the mouse. simple. the only problem is that when i invalidate the panel im
drawing on in order to see the line, it flickers, even with double buffering.
if i only invalidate a rectangle around teh mouse, if the user mouse the
mouse too fast the line wont be drawn in certain intervals because the paint
event cant fire enough times. how can i either eliminate the flickering or
invalidate a part of the panle enough that it will show the entire line at
draw time. (if i bring anything in front of the panel or minimize the
program, the windows repaint method shows the graphics)

i also tried using a Graphics variable to draw on a surface on a mousedown
event, but then if you minimized the program or brought anything in front of
the graphics, youd lose what you drew. how can i sto this from happeneing?

which ever question is easier to answer, if any, would be helpful. ive been
researching this for weeks but i cant seem to find an answer, thanks




iwdu15:


您可能需要对WM_ERASEBKGND消息执行某些操作。通常做的是
通常从处理程序返回TRUE并在OnPaint()中绘制所有内容,包括背景的



HTH,

David Wilkinson



iwdu15:

You probably need to do something with the WM_ERASEBKGND message. What I
usually do is return TRUE from the handler and draw everything,
including the backround, in OnPaint().

HTH,

David Wilkinson


我该怎么做?什么是WM_ERASEBKGND消息...感谢

你的帮助

-

-iwdu15

how would i do that? and what is "the WM_ERASEBKGND message"...thanks for
your help
--
-iwdu15


iwdu15写道:
iwdu15 wrote:
我该怎么做?什么是WM_ERASEBKGND消息...感谢您的帮助
how would i do that? and what is "the WM_ERASEBKGND message"...thanks for
your help




iwdu15:


如果这是一个Win32或MFC应用程序,这是一个Windows消息,如任何

其他。对于MFC,您可以通过在ClassView中选择相应的

类并选择Properties->事件来添加消息处理程序。


如果这是一个.NET应用程序然后我的建议可能不相关。

您需要请别人帮助您。


David Wilkinson



iwdu15:

If this is a Win32 or MFC application this is a Windows message like any
other. For MFC you can add message handlers by going to the appropriate
class in ClassView and Selecting Properties->Events.

If this is a .NET application then my suggestion may not be relevant.
You will need to ask someone else to help you.

David Wilkinson


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

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