单击按钮时如何画线 [英] how do i draw a line when i click a button

查看:87
本文介绍了单击按钮时如何画线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击不同的按钮时,我想画一条直线或椭圆.
谢谢您的帮助!

I want draw a line or circle,ellipse when i click different buttons.
Thank your help!

推荐答案

请查看以下链接:

http://www.java2s.com/Tutorial/VB/0300__2D-Graphics/DrawLine.htm [^ ]



http://www.daniweb.com/software-development/vbnet/threads/24617 [ ^ ]
Please see links below:

http://www.java2s.com/Tutorial/VB/0300__2D-Graphics/DrawLine.htm[^]

and

http://www.daniweb.com/software-development/vbnet/threads/24617[^]


您需要处理事件Paint或重写您在其中进行绘制的某些控件(可能是窗体)的方法OnPaint. OnPaint的处理程序将使用事件参数parameter调用,该参数提供用于绘制的Graphics的实例.

这将创建一些静态渲染.如何在某些事件(如按钮单击)上更改它?

根据某些数据进行渲染,例如,这些数据可以是表单的成员.您的click事件可以修改数据,因此,下次呈现控件时,它将显示一些不同的图片.例如,单击前无行,单击后无行.但是更改数据本身并不意味着重新绘制,对吗?如何触发更新.您需要将Windows消息WM_PAINT分配给控件.要触发它,请在更改数据后立即调用Control.Invalidate.为了提高性能,可以使用参数(RegionRectangle)调用Invalidate,以仅使一部分场景无效.将相同的技术用于渲染图片的动画.建议对控件进行双重缓冲以避免闪烁.


—SA
You need to handle the event Paint or override the method OnPaint of some control (could be a form) where you paint. You handler of OnPaint will be called with event arguments parameter which provides the instance of Graphics you use for drawing.

That will create some static rendering. How to change it on some event like button click?

Make your rendering depending on some data, which can be a member(s) of you form, for example. Your click event can modify the data, so next time your control is rendered it will show some different picture. For example, no line before click, a line after click. But changing data itself does not mean re-drawing, right? How to trigger the update. You need to case the Windows message WM_PAINT to be dispatched to a control. Do trigger it, you call Control.Invalidate right after you changed the data. For performance gain, you can call Invalidate with a parameter (Region or Rectangle) to invalidate only a part of the scene. The same technique is used for animation of the rendered picture. Double buffering of the control is recommended to avoid flicker.


—SA


在您的应用程序中,通过使用Graphic对象处理OnButtonClick事件,在其上的所需位置绘制空格.
In your application, handel the OnButtonClick Event in that using Graphic object draw the space in required position on from.


这篇关于单击按钮时如何画线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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