滚动文本显示不闪烁 - 可能在C#中? [英] A scrolling text display that does't flash - possible in C#?

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

问题描述

你好,


我知道我听起来像是一个单注的约翰尼,但我仍在寻找一个

的解决方案。我需要显示来自串口或

套接字的字符。我还需要能够自己在显示器中输入字符 -

但这不是目前的主要问题。我已经尝试了滚动多行

文本框但是一旦原始可视区域填满并开始滚动

整个区域的闪烁让我疯狂。垂直滚动条可以看到上下弹跳,因为控件显然用它包含的每个字符串更新显示

,包括那些甚至不在视野中的字符串。我已经

将我的字符串数组限制在几百个字符串中,因此它会更新,但是这似乎并不重要。我已经尝试在表单上设置

双缓冲属性,但什么也没做。我已经

尝试甚至没有使用控件,只是直接写在表格上,但是我还没有真正完成任何事情。



我和其他几位C#程序员谈过这个问题。这里关于闪烁和他们显然知道的事情很少,因为他们都告诉我他们有同样的问题并没有找到解决方案(他们只是保留)一个好的供应

头痛药丸)。我见过其他应用程序,如TeraTerm,

HyperTerm,以及其他没有这个问题但我想完成

同样的事情在C#中如果可能的话。一个示例应用程序,只需添加

字符到一个不闪烁的显示器将是值得赞赏,因为我不是很了解b
知道如何挖掘个人角色xy

坐标和字体大小级别,仅对单个字符无效,

看起来似乎不应该是必要的(但也许是这样?)。


总是如此,谢谢,

Ray

Hello,

I know I sound like a one-note Johnny on this but I''m still looking for a
solution. I need to display characters coming in from a serial port or a
socket. I also need to be able to type characters into the display myself -
but that''s not the main issue at this time. I''ve tried a scrolling multiline
text box but once the original viewable area fills up and it starts scrolling
the flashing of the entire area drives me nuts. The vertical scroll bar can
be seen to bounce up and down as the control apparently updates the display
with every string it has including those that are not even in view. I''ve
limited my string array to just a few hundred strings just so it will have
less to update but that doesn''t seem to matter. I''ve tried setting the
double-buffering property on the form, which accomplishes nothing. I''ve also
tried not even using a control and merely writing directly onto a form but I
haven''t really accomplished much there either.

I''ve talked to several other C# "programmers" here about the flashing and
they obviously know about as little as I do since they all tell me they have
the same problem and have not found a solution (they just keep a good supply
of headache pills on hand). I''ve seen other applications such as TeraTerm,
HyperTerm, and others that don''t have this problem but I''d like to accomplish
the same thing in C# if possible. A sample application for just adding
characters to a non-flashing display would be appreciated since I''m not very
knowledgeable regarding digging down to the individual character x-y
coordinate and font size level, invalidating only over a single character,
It doesn''t seem like that should be necessary anyway (but maybe it is?).

As Always, Thanks,
Ray

推荐答案




" Ray Mitchell"写道:


"Ray Mitchell" wrote:

您好,


我知道我听起来像是一个单音注释Johnny但我还是寻找一个

的解决方案。我需要显示来自串口或

套接字的字符。我还需要能够自己在显示器中输入字符 -

但这不是目前的主要问题。我已经尝试了滚动多行

文本框但是一旦原始可视区域填满并开始滚动

整个区域的闪烁让我疯狂。垂直滚动条可以看到上下弹跳,因为控件显然用它包含的每个字符串更新显示

,包括那些甚至不在视野中的字符串。我已经

将我的字符串数组限制在几百个字符串中,因此它会更新,但是这似乎并不重要。我已经尝试在表单上设置

双缓冲属性,但什么也没做。我已经

尝试甚至没有使用控件,只是直接写在表格上,但是我还没有真正完成任何事情。



我和其他几位C#程序员谈过这个问题。这里关于闪烁和他们显然知道的事情很少,因为他们都告诉我他们有同样的问题并没有找到解决方案(他们只是保留)一个好的供应

头痛药丸)。我见过其他应用程序,如TeraTerm,

HyperTerm,以及其他没有这个问题但我想完成

同样的事情在C#中如果可能的话。一个示例应用程序,只需添加

字符到一个不闪烁的显示器将是值得赞赏,因为我不是很了解b
知道如何挖掘个人角色xy

坐标和字体大小级别,仅对单个字符无效,

看起来似乎不应该是必要的(但也许是这样?)。


总是如此,谢谢,


Hello,

I know I sound like a one-note Johnny on this but I''m still looking for a
solution. I need to display characters coming in from a serial port or a
socket. I also need to be able to type characters into the display myself -
but that''s not the main issue at this time. I''ve tried a scrolling multiline
text box but once the original viewable area fills up and it starts scrolling
the flashing of the entire area drives me nuts. The vertical scroll bar can
be seen to bounce up and down as the control apparently updates the display
with every string it has including those that are not even in view. I''ve
limited my string array to just a few hundred strings just so it will have
less to update but that doesn''t seem to matter. I''ve tried setting the
double-buffering property on the form, which accomplishes nothing. I''ve also
tried not even using a control and merely writing directly onto a form but I
haven''t really accomplished much there either.

I''ve talked to several other C# "programmers" here about the flashing and
they obviously know about as little as I do since they all tell me they have
the same problem and have not found a solution (they just keep a good supply
of headache pills on hand). I''ve seen other applications such as TeraTerm,
HyperTerm, and others that don''t have this problem but I''d like to accomplish
the same thing in C# if possible. A sample application for just adding
characters to a non-flashing display would be appreciated since I''m not very
knowledgeable regarding digging down to the individual character x-y
coordinate and font size level, invalidating only over a single character,
It doesn''t seem like that should be necessary anyway (but maybe it is?).

As Always, Thanks,
Ray



我刚刚发现了一些新东西。也许它会给某人一个暗示

正在发生什么。如果我给一些其他形式的焦点完全重写

并刷新显示控件中的所有内容并且

垂直滚动条的弹跳停止并且无法忍受的闪烁停止。相反,在某些线路上只有一点点闪烁,虽然它最好不要有,但至少可以读取。一旦我重新回到焦点,

它再次开始闪烁。任何想法?

谢谢,Ray


I just discovered something new. Maybe it will give someone a hint as to
what''s going on. If I give some other form the focus the complete rewriting
and refreshing of everything in the display control and the bouncing of the
vertical scroll bar stops and the unbearable flashing stops. Instead, there
is just a slight flicker on some of the lines which, although it would be
better not to have, is at least readable. As soon as I give the focus back,
it starts flashing again. Any ideas?
Thanks, Ray


Ray Mitchell写道:
Ray Mitchell wrote:

[ ...]

我和其他几个C#程序员谈过这个问题。这里关于闪烁和他们显然知道的事情很少,因为他们都告诉我他们有同样的问题并没有找到解决方案(他们只是保留)一个好的供应

头痛药丸)。
[...]
I''ve talked to several other C# "programmers" here about the flashing and
they obviously know about as little as I do since they all tell me they have
the same problem and have not found a solution (they just keep a good supply
of headache pills on hand).



我以为我们已经覆盖了这个。


一般来说:


对于单个

更新,多次重绘控件时会发生闪烁。最常见的情况是控件不是双缓冲的b $ b bb,导致背景在屏幕上被删除,然后是实际绘制新数据的



但这不是唯一的情况。任何导致图形在屏幕上更改然后立即再次更改的内容都会导致

闪烁。这可以简单到清除

控件的Text属性,然后将其设置为其他东西,或任意数量的其他

的东西。


要做的第一件事是确保你的控件是双缓冲的。

然后你可以看看还有什么可能导致闪烁,如果那个

无法修复它。

I thought we''d covered this.

Generally:

Flashing occurs when an control is redrawn multiple times for a single
update. The most common scenario is when the control is not
double-buffered, resulting in the background being erased on-screen,
followed by the actual drawing of the new data.

It''s not the only scenario though. Anything that causes the graphics
on-screen to change and then change again immediately after will cause
flashing. This can be as simple as clearing the Text property of a
control and then setting it to something else, or any number of other
things.

The first thing to do is make sure your control is double-buffered.
Then you can look at what else might be causing the flashing, if that
doesn''t fix it.


我见过其他应用程序,如TeraTerm,

HyperTerm,以及其他应用程序没有这个问题,但如果可能的话,我想在C#中完成同样的事情。
I''ve seen other applications such as TeraTerm,
HyperTerm, and others that don''t have this problem but I''d like to accomplish
the same thing in C# if possible.



我很确定我之前提到的,你的应用程序是
谈论不使用标准,现成的控件显示

他们的文字。他们无疑拥有自定义控件,因此他们可以完全控制绘图的完成方式。您可以轻松地执行相同的操作。

As I''m pretty sure I have mentioned before, the applications you are
talking about don''t use a standard, off-the-shelf control to display
their text. They undoubtedly have a custom control so that they have
complete control over how the drawing is done. You can easily do the same.


只需将

字符添加到非闪烁显示的示例应用程序,我将不胜感激对于挖掘个人角色xy

坐标和字体大小水平,只对一个角色有效,

看起来似乎不应该是必要的(但可能是这样吗?)。
A sample application for just adding
characters to a non-flashing display would be appreciated since I''m not very
knowledgeable regarding digging down to the individual character x-y
coordinate and font size level, invalidating only over a single character,
It doesn''t seem like that should be necessary anyway (but maybe it is?).



为了最好地控制图纸,它可能是。也许如果我找到一些

的时间,我会编写一个样本。


与此同时,你需要做的一件事是理解为什么你的当前

代码闪烁。如果不是缺少双缓冲,它必须是其他的东西。还有什么?你是如何使用控件的?

你实际上是在清理文本吗?如果没有,也许控件在你改变它的内容的时候做了一些内部的事情。


你可能尝试的一件事就是当你改变它时抑制绘图

控件的值。这将需要子类化控件,

启用双缓冲,覆盖OnPaint()方法,然后

在更改控件内容时设置标志。当

你完成更新控制后,再次清除标志并使整个控件无效

以便重绘。


在OnPaint()方法中,如果你的标志没有设置,只调用base.OnPaint()。


最后,你会发现如果你得到最好的帮助汇总一个简洁但完整的代码示例,说明您的代码如何工作现在是
,什么对你不起作用。如果没有这样的样本,我们所能做的就是猜测,并且无法保证任何其他人可能提供的示例代码将成功地集成到您的b $ b中。您现有的

申请表。现在知道你的立场会有很长的路要走。

确保这些建议能够帮助你。


Pete

For best control over the drawing, it may be. Perhaps if I find some
time, I''ll code up a sample.

In the meantime, one thing you need to do is understand why your current
code flashes. If it''s not the lack of double-buffering, it must be
something else. What else is that? How are you using the control? Are
you in fact clearing the text? If not, maybe the control does something
like that internally when you change its contents.

One thing you might try is suppressing drawing when you are changing the
value of the control. This will require subclassing the control,
enabling double-buffering, overriding the OnPaint() method, and then
setting a flag while you change the contents of the control. When
you''re done updating the control, clear the flag again and invalidate
the entire control so that it redraws.

In the OnPaint() method, only call base.OnPaint() if your flag isn''t set.

Finally, you will find that you get the best help if you put together a
concise-but-complete sample of code that illustrates how your code works
now, and what doesn''t work for you. Absent such a sample, all we can do
is guess, and there''s no guarantee that any sample code someone else
might provide will be successfully integrated by you into your existing
application. Knowing where you stand now would go a long way to helping
make sure the advice is to the point and helpful to you.

Pete





" Peter Duniho"写道:


"Peter Duniho" wrote:

Ray Mitchell写道:
Ray Mitchell wrote:

[...]

我和其他几个C#程序员谈过了这里关于闪烁和他们显然知道的事情很少,因为他们都告诉我他们有同样的问题并没有找到解决方案(他们只是保留)一个好的供应

头痛药丸)。
[...]
I''ve talked to several other C# "programmers" here about the flashing and
they obviously know about as little as I do since they all tell me they have
the same problem and have not found a solution (they just keep a good supply
of headache pills on hand).



我以为我们已经覆盖了这个。


一般来说:


对于单个

更新,多次重绘控件时会发生闪烁。最常见的情况是控件不是双缓冲的b $ b bb,导致背景在屏幕上被删除,然后是实际绘制新数据的



但这不是唯一的情况。任何导致图形在屏幕上更改然后立即再次更改的内容都会导致

闪烁。这可以简单到清除

控件的Text属性,然后将其设置为其他东西,或任意数量的其他

的东西。


要做的第一件事是确保你的控件是双缓冲的。

然后你可以看看还有什么可能导致闪烁,如果那个

无法修复它。


I thought we''d covered this.

Generally:

Flashing occurs when an control is redrawn multiple times for a single
update. The most common scenario is when the control is not
double-buffered, resulting in the background being erased on-screen,
followed by the actual drawing of the new data.

It''s not the only scenario though. Anything that causes the graphics
on-screen to change and then change again immediately after will cause
flashing. This can be as simple as clearing the Text property of a
control and then setting it to something else, or any number of other
things.

The first thing to do is make sure your control is double-buffered.
Then you can look at what else might be causing the flashing, if that
doesn''t fix it.


我见过其他应用程序,如TeraTerm,

HyperTerm,以及其他应用程序没有这个问题,但如果可能的话,我想在C#中完成同样的事情。
I''ve seen other applications such as TeraTerm,
HyperTerm, and others that don''t have this problem but I''d like to accomplish
the same thing in C# if possible.



我很确定我之前提到的,你的申请是什么?b $ b谈论不使用标准,现成的控件显示

他们的文字。他们无疑拥有自定义控件,因此他们可以完全控制绘图的完成方式。您可以轻松地执行相同的操作。


As I''m pretty sure I have mentioned before, the applications you are
talking about don''t use a standard, off-the-shelf control to display
their text. They undoubtedly have a custom control so that they have
complete control over how the drawing is done. You can easily do the same.


只需将

字符添加到非闪烁显示的示例应用程序,我将不胜感激对于挖掘个人角色xy

坐标和字体大小水平,只对一个角色有效,

看起来似乎不应该是必要的(但可能是这样吗?)。
A sample application for just adding
characters to a non-flashing display would be appreciated since I''m not very
knowledgeable regarding digging down to the individual character x-y
coordinate and font size level, invalidating only over a single character,
It doesn''t seem like that should be necessary anyway (but maybe it is?).



为了最好地控制图纸,它可能是。也许如果我找到一些

的时间,我会编写一个样本。


与此同时,你需要做的一件事是理解为什么你的当前

代码闪烁。如果不是缺少双缓冲,它必须是其他的东西。还有什么?你是如何使用控件的?

你实际上是在清理文本吗?如果没有,也许控件在你改变它的内容的时候做了一些内部的事情。


你可能尝试的一件事就是当你改变它时抑制绘图

控件的值。这将需要子类化控件,

启用双缓冲,覆盖OnPaint()方法,然后

在更改控件内容时设置标志。当

你完成更新控制后,再次清除标志并使整个控件无效

以便重绘。


在OnPaint()方法中,如果你的标志没有设置,只调用base.OnPaint()。


最后,你会发现如果你得到最好的帮助汇总一个简洁但完整的代码示例,说明您的代码如何工作现在是
,什么对你不起作用。如果没有这样的样本,我们所能做的就是猜测,并且无法保证任何其他人可能提供的示例代码将成功地集成到您的b $ b中。您现有的

申请表。现在知道你的立场会有很长的路要走。

确保这些建议能够帮助你。


Pete


For best control over the drawing, it may be. Perhaps if I find some
time, I''ll code up a sample.

In the meantime, one thing you need to do is understand why your current
code flashes. If it''s not the lack of double-buffering, it must be
something else. What else is that? How are you using the control? Are
you in fact clearing the text? If not, maybe the control does something
like that internally when you change its contents.

One thing you might try is suppressing drawing when you are changing the
value of the control. This will require subclassing the control,
enabling double-buffering, overriding the OnPaint() method, and then
setting a flag while you change the contents of the control. When
you''re done updating the control, clear the flag again and invalidate
the entire control so that it redraws.

In the OnPaint() method, only call base.OnPaint() if your flag isn''t set.

Finally, you will find that you get the best help if you put together a
concise-but-complete sample of code that illustrates how your code works
now, and what doesn''t work for you. Absent such a sample, all we can do
is guess, and there''s no guarantee that any sample code someone else
might provide will be successfully integrated by you into your existing
application. Knowing where you stand now would go a long way to helping
make sure the advice is to the point and helpful to you.

Pete



嗨皮特,


是的,你们之前肯定已经涵盖了很多,我很感激你的

忍耐。我的问题是我对所有这些GUI内容的体验非常简单。我主要编写命令行C / C ++应用程序,我花费了大部分时间在实际算法上,而不是图形用户

界面。所以当然我知道我需要打一遍关于所有

这本书,但我只是想找一个简单的解决方案,对我来说似乎会是什么意思

很常见应用。我希望能够重复使用已经完成并放在那里供公众使用的东西

而不是

在详细信息中对它进行详细的教育。然而,没什么大不了的。

虽然我很欣赏这种情绪,但是你没有必要花费额外的时间来编写一些我应该花时间去做的事情。主人

我自己。


谢谢,



Hi Pete,

Yes, you certainly have covered much of this before and I do appreciate your
patience. My problem is that my experience with all this GUI stuff is very
minimal. I primarily code command line C/C++ applications where I spend most
of my time on the actual algorithm rather than on the graphical user
interface. So of course I know that I need to hit the books regarding all
this but I was simply looking for an easy solution to what seemed to me would
be a pretty common application. My hope was to be able to reuse something
that had already been done and placed out there for public use rather than
make it a detailed education in the details of it all. No big deal, however.
Although I appreciate the sentiment, there''s no need for you to spend
additional time coding up something that I should take the time to master
myself.

Thanks,
Ray


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

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