使用GDI +模拟移动矩形 [英] Simulating a moving rectangle using GDI+

查看:78
本文介绍了使用GDI +模拟移动矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试模拟一个矩形,该矩形以V的速度从A点移动到B点.通过覆盖Form的OnPaint方法,通过绘制的线将两个点连接起来.

对我来说似乎是一个挑战,那就是如何设置何时更新矩形的位置.我需要一个计时器吗?或...


任何想法表示赞赏!

预先感谢

Hi guys, I''m trying to simulate a rectangle that moves with a velocity of V from point A to point B. The two points are connected through a line that I draw by overriding the OnPaint method of a Form.

The thing that looks like a challenge to me is how to set when the location of the rectangle should be updated. Am I going to need a timer? or ...


Any idea is appreciated!

Thanks in advance

推荐答案

您需要计时器,并在刻度事件中使用该计时器,设置矩形的坐标并验证表单.
You need timer, and use that in tick event, set the co-ordinates of the rectangle and validate the form.


您可以使用计时器,并在滴答事件中设置矩形的坐标并使表格无效以刷新它.
You can use timer and in tick event set the coordinates of rectangle and invalidate the form to refresh it.


这篇关于使用GDI +模拟移动矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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