滚动不闪烁的文本 [英] Scrolling text that doesn't flicker

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

问题描述



我已经看到了很多不同的方法来做到这一点,但是所有人似乎都会产生相同的结果 - 文本在没有闪烁的时候它正在慢慢地移动



有没有人知道最好的方式来制作文字滚动...


例如

覆盖OnPain和OnPaintBackground


覆盖WndProc


使用GDI


使用API​​


或者我需要在c ++中创建一些奇怪的控件吗?!


提前谢谢,

James

Hi,
I have seen loads of different ways to do this, but the all seem to
yield the same result - text that doesn''t flicker when it''s moving too
slowly!
Does anyone know ''the best way'' to make text scroll...

eg
Override OnPain and OnPaintBackground

Override WndProc

Use GDI

Use API

Or do i need to create some weird control in c++?!

Thanks in advance,
James

推荐答案

" pigeonrandle" < pi ********** @ hotmail.comwrote in message

news:11 ******************** *@i42g2000cwa.googlegro ups.com ...
"pigeonrandle" <pi**********@hotmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...



我已经看到很多不同的方法来做到这一点,但是所有似乎都会产生相同的结果 - 当它移动太慢时不会闪烁的文字


Hi,
I have seen loads of different ways to do this, but the all seem to
yield the same result - text that doesn''t flicker when it''s moving too
slowly!



" Flicker"通常是由一个问题引起的,无论你是什么?b $ b b:在绘制新图像之前擦除屏幕上的上一个图像。


通常情况下,使用屏幕外缓冲区实现绘制

图像,然后将图像直接复制到屏幕而不删除之前的任何

。你需要首先擦除的原因是

摆脱以前的任何东西,但如果你总是复制一个

全新的位图(或者部分一个位图)在需要更改的

显示的每个部分的顶部,然后不需要擦除,并且没有闪烁




在.NET中,我被告知可以启用双缓冲功能。解决这个问题。

术语双缓冲是不正确的,恕我直言(它更正确地指的是

a相关但不同的想法,其中整个屏幕缓冲区被切换

来回),但知道这一点这是一些.NET用户可以使用的短语

帮助您在.NET文档中找到该技术。我自己也没用过它,所以我不能告诉你具体细节。


Pete

"Flicker" is generally caused by a single problem, regardless of what you''re
drawing: erasing the previous image on-screen before drawing the new image.

Typically, this is addressed using an off-screen buffer to actually draw the
image, which is then copied directly to the screen without erasing whatever
was there previously. The reason you need to erase in the first place is to
get rid of whatever was there previously, but if you are always copying a
whole new bitmap (or portion of a bitmap) on top of every part of the
display that needs changing, then no erasing is necessary, and no flicker
occurs.

In .NET, I''ve been told one can enable "double-buffering" to address this.
The term "double-buffering" isn''t correct, IMHO (it more correctly refers to
a related but different idea in which the entire screen buffer is switched
back and forth), but knowing that that''s the phrase some .NET people use may
help you find the technique in the .NET documentation. I haven''t used it
myself, so I can''t tell you the specifics.

Pete


嗨James,


正如彼得所说,双缓冲是一种减少闪烁的选择(

只有一个我知道(以及)。在从Control(包括Form类)派生

的类的构造函数中,您可以使用以下代码

为该控件启用双缓冲(1. *应用程序) ):


this.SetStyle(ControlStyles.DoubleBuffer

| ControlStyles.AllPaintingInWmPaint

| ControlStyles.UserPaint,true);


在2.0应用程序中,只需将Control.DoubleBuffered属性设置为true(它在内部使用

新的ControlStyles.OptimizedDoubleBuffer标志)。


-

Dave Sexton


" pigeonrandle" < pi ********** @ hotmail.comwrote in message

news:11 ******************** *@i42g2000cwa.googlegro ups.com ...
Hi James,

As Peter suggested, double buffering is an option to reduce flickering (the
only one I''m aware of as well). In the constructor of a class that derives
from Control (including the Form class) you can use the following code to
enable double buffering for that control (1.* applications):

this.SetStyle(ControlStyles.DoubleBuffer
| ControlStyles.AllPaintingInWmPaint
| ControlStyles.UserPaint, true);

In 2.0 apps, just set the Control.DoubleBuffered property to true (it uses the
new ControlStyles.OptimizedDoubleBuffer flag internally).

--
Dave Sexton

"pigeonrandle" <pi**********@hotmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...



我已经看到很多不同的方法来做到这一点,但是好像

产生相同的结果 - 当它移动时不会闪烁的文字

慢慢来!

有没有人知道''最佳方式''使文字滚动...


例如

覆盖OnPain和OnPaintBackground


覆盖WndProc


使用GDI


使用API​​


或者我是否需要创建在c ++中有一些奇怪的控制?!


提前致谢,

James
Hi,
I have seen loads of different ways to do this, but the all seem to
yield the same result - text that doesn''t flicker when it''s moving too
slowly!
Does anyone know ''the best way'' to make text scroll...

eg
Override OnPain and OnPaintBackground

Override WndProc

Use GDI

Use API

Or do i need to create some weird control in c++?!

Thanks in advance,
James



" Dave Sexton" < dave @jwa [remove.this] online.comwrote in message

news:up ************** @ TK2MSFTNGP03.phx.gbl ...
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:up**************@TK2MSFTNGP03.phx.gbl...

嗨James,


正如彼得所说,双缓冲是一种减少闪烁的选择

(我唯一也知道的)。
Hi James,

As Peter suggested, double buffering is an option to reduce flickering
(the only one I''m aware of as well).



另一种选择是只绘制一次。如果你正在做一些事情

就像一个棋盘这很容易,只需将每个方块画在屏幕上。如果

棋盘上有棋子你可以使用区域来绘制棋子然后

画出围绕它们的方块。不幸的是,对于文字我不认为这是可能的b $ b。你必须使用双缓冲,因为它不可能用背景绘制

文本,并且无法找到该文本周围的区域

。这也适用于GDI +的许多功能,例如

抗锯齿和透明度,它不再可以一次性绘制

所以双缓冲是这几天几乎是强制性的。


Michael

The other option is to just draw everything once. If you are doing something
like a chessboard this is easy, just draw each square onto the screen. If
the chessboard has pieces you could use regions to draw the pieces and then
draw the square around them. Unfortunately for text I don''t think this is
possible. You have to use double buffering because it''s not possible to draw
text with a background and it is not possible to find the region surrounding
this text. This also applies to many of the features of GDI+ such as
anti-aliasing and transparencies, it''s no longer possible to draw in one go
so double buffering is almost mandatory these days.

Michael


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

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