如何在鼠标事件上调用绘画? [英] How to call paint even on mouse event?
本文介绍了如何在鼠标事件上调用绘画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何拨打
以下是代码:
私有 Sub VideoPaint( ByVal sender < span class =code-keyword>作为 对象, ByVal e As System.Windows.Forms.PaintEventArgs)句柄 picOriginal.Paint
Dim g As Graphics = e.Graphics
Dim recta As Rectangle = 新矩形(Xx( 1 ),yy( 1 ),hh( 1 ),www( 0 ))
Dim pen As Pe n = 新笔(Color.FromArgb( 128 , 32 , 100 , 200 ), 1 )
Dim b As Brush = 新 SolidBrush(pen.Color)
g.FillRectangle(b,recta)
结束 Sub
此代码事件
私人 Sub picOriginal_MouseUp( ByVal sender 作为 对象, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 温泉n> picOriginal.MouseUp
CALL PAINT EVENT?
Catch ex As 例外
退出 Sub
结束 尝试
En sub
解决方案
试试
引用:调用this.Invalidate()将导致Paint事件触发。
谢谢
这不是办法。您需要通过调用刷新 [ ^ ]。绘图的实际代码应该在 OnPaint方法 [ ^ ]。
How to call
Below is the code:
Private Sub VideoPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picOriginal.Paint
Dim g As Graphics = e.Graphics
Dim recta As Rectangle = New Rectangle(Xx(1), yy(1), hh(1), www(0))
Dim pen As Pen = New Pen(Color.FromArgb(128, 32, 100, 200), 1)
Dim b As Brush = New SolidBrush(pen.Color)
g.FillRectangle(b, recta)
End Sub
on this code event
Private Sub picOriginal_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picOriginal.MouseUp
CALL PAINT EVENT?
Catch ex As Exception
Exit Sub
End Try
En sub
解决方案
Try
Quote:Calling this.Invalidate() will cause the Paint event to fire.
Thank You
That is not the way to do it. You need to tell the form to redraw itself with a call to Refresh[^]. The actual code to do the drawing should be inside an override of the OnPaint method[^].
这篇关于如何在鼠标事件上调用绘画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文