Windows窗体上的CPU利用率更高调整大小 [英] Higher CPU Utilization on Windows form resize

查看:74
本文介绍了Windows窗体上的CPU利用率更高调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Windows应用程序,其中表单需要在MouseMove事件上调整大小
。 Windows调整大小功能需要大量的CPU周期。并且当在MouseMove上调用resize函数时,

表单在一秒钟内调整大约30-100次。这导致了很高的CPU利用率和所有其他应用程序来到一个支架

仍然。


表格没有任何控件即按钮,文本框等。

完全为空。它的不透明度大约在10%左右。


现在有什么方法可以减少所有CPU占用的数量

通过调整大小的形式?


或者我可以在MouseMove事件上减少表单调整大小调用。即某种方式

所有鼠标移动事件都不会导致形式调整大小。


请帮我解决这个问题。

I have created a windows application in which the form needs to be
resized on the MouseMove event. The windows resize function takes a lot
of CPU cycles. And as the resize function is called on the MouseMove,
the form is resized around a 30-100 times in one second. This leads to
a high CPU utilization and all other application comes to a stand
still.

The form does not have any controls i.e. buttons, text boxes etc. It is
completely empty. Its opacity in around 10%.

Now is there any way by which we can reduce all the amount of CPU taken
by the form on resize??

Or can I reduce the form resize calls on MouseMove event. i.e. some way
by which all the mouse move event don''t lead to form resize.

Please help me out with this.

推荐答案

你可以部分阻止表格的绘画。


请注意这可以给出一个弹性效果,如果你不做简短的

步骤。


Cor


" Ajith梅农" < ko ******** @ gmail.comschreef在bericht

新闻:11 ********************* @ f16g2000cwb.googlegro ups.com ...
You can block the painting of the form partially.

Be aware that this can give an elastic effect if you don''t do it in short
steps.

Cor

"Ajith Menon" <ko********@gmail.comschreef in bericht
news:11*********************@f16g2000cwb.googlegro ups.com...

>我创建了一个Windows应用程序,其中表单需要

调整大小MouseMove事件。 Windows调整大小功能需要大量的CPU周期。并且当在MouseMove上调用resize函数时,

表单在一秒钟内调整大约30-100次。这导致了很高的CPU利用率和所有其他应用程序来到一个支架

仍然。


表格没有任何控件即按钮,文本框等。

完全为空。它的不透明度大约在10%左右。


现在有什么方法可以减少所有CPU占用的数量

通过调整大小的形式?


或者我可以在MouseMove事件上减少表单调整大小调用。即某种方式

所有鼠标移动事件都不会导致形式调整大小。


请帮我解决这个问题。
>I have created a windows application in which the form needs to be
resized on the MouseMove event. The windows resize function takes a lot
of CPU cycles. And as the resize function is called on the MouseMove,
the form is resized around a 30-100 times in one second. This leads to
a high CPU utilization and all other application comes to a stand
still.

The form does not have any controls i.e. buttons, text boxes etc. It is
completely empty. Its opacity in around 10%.

Now is there any way by which we can reduce all the amount of CPU taken
by the form on resize??

Or can I reduce the form resize calls on MouseMove event. i.e. some way
by which all the mouse move event don''t lead to form resize.

Please help me out with this.



" Ajith Menon" < ko ******** @ gmail.com写信息

新闻:11 ********************* @ f16g2000cwb.googlegro ups.com ...
"Ajith Menon" <ko********@gmail.comwrote in message
news:11*********************@f16g2000cwb.googlegro ups.com...

[...]

现在有什么方法可以减少所有通过调整大小的形式获取的CPU数量

??


或者我可以减少鼠标移动事件上的表单调整大小调用。即某种方式

所有鼠标移动事件都不会导致形式调整大小。
[...]
Now is there any way by which we can reduce all the amount of CPU taken
by the form on resize??

Or can I reduce the form resize calls on MouseMove event. i.e. some way
by which all the mouse move event don''t lead to form resize.



你不想这样做。毕竟,如果用户正在将表单拖动到

调整它的大小,忽略一些鼠标移动将导致用户没有
能够调整到任何大小他们想要。


然而,就实际问题而言......每次重新调整大小时,CPU消耗来自

重绘表单。在

调整大小期间将表单设置为不绘制,并且CPU使用率将下降(它不能被消除,因为

将始终是一些反馈给关于调整大小的用户。


如果你真的认为这是必要的,你可以禁用重新调整重绘,但是

然后自己处理调整大小事件每隔一段时间显式地重绘(使

形式无效),以减少重绘事件。


Pete

You don''t want to do that. After all, if the user is dragging the form to
resize it, ignoring some of the mouse moves will result in the user not
being able to resize to exactly whatever size they want.

However, as far as the actual problem goes...the CPU consumption is from
redrawing the form every time it''s resized. Set the form to not draw during
resizing, and the CPU use will go down (it can''t be eliminated, since there
will always be some feedback to the user about the resizing).

If you really think it''s necessary, you can disable resize redrawing, but
then handle the resize events yourself and explicitly redraw (invalidate the
form) every so often, as a way of reducing the redraw events.

Pete


感谢您的immdiate响应。
Thanks for your immdiate response.

但是,就实际问题而言...... CPU消耗来自

每次重新调整表单时都会重新绘制表单。在

调整大小期间将表单设置为不绘制,并且CPU使用率将下降(它不能被消除,因为

将始终是一些反馈给用户关于调整大小)。
However, as far as the actual problem goes...the CPU consumption is from
redrawing the form every time it''s resized. Set the form to not draw during
resizing, and the CPU use will go down (it can''t be eliminated, since there
will always be some feedback to the user about the resizing).



如何在调整大小期间设置不重绘的形式?

另外我知道更高的处理器是由于不透明度= 10% 。

前景重绘以及背景重绘。如果

opacticy是100%,则不调用背景重绘。

How to set the form not to redraw during resize?
Also I got to know the higher processor is due to opacity=10%. The
foreground repaint as well as background repaintis called. In case if
opacticy is 100% background repaint is not called.


>您可以部分阻止对表单的绘制。

请注意,如果你不采取短暂的步骤,这可以产生弹性效果。
>You can block the painting of the form partially.

Be aware that this can give an elastic effect if you don''t do it in short
steps.



什么阻止了这幅画?


谢谢,

Ajith

And what is blocking the painting partially???

Thanks,
Ajith


这篇关于Windows窗体上的CPU利用率更高调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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