|
-
Jul 30th, 2003, 01:52 PM
#1
Thread Starter
Frenzied Member
What does exactly 'Invalidate' method of controls do?
Try the following code:
VB Code:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
Static Dim secondclick As Boolean
Static mousepos1, mousepos2 As Point
If e.Button = MouseButtons.Left Then
Dim g As Graphics = Me.CreateGraphics
If secondclick = False Then
Me.Refresh() ' comment this line and try the next line to note the difference.
' Me.Invalidate()
mousepos1 = New Point(e.X, e.Y)
secondclick = True
Else
mousepos2 = New Point(e.X, e.Y)
secondclick = False
g.DrawLine(New Pen(Color.Black, 1), mousepos1.X, mousepos1.Y, mousepos2.X, mousepos2.Y)
End If
g.DrawLine(New Pen(Color.Black, 1), e.X, e.Y - 5, e.X, e.Y + 5)
g.DrawLine(New Pen(Color.Black, 1), e.X - 5, e.Y, e.X + 5, e.Y)
g.Dispose()
End If
End Sub
How can you describe this difference between Refresh and Invalidate? Doesn't Refresh call Invalidate?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 30th, 2003, 02:07 PM
#2
Me.Invalidate() forces a Re-Paint
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 30th, 2003, 02:34 PM
#3
Thread Starter
Frenzied Member
Originally posted by dynamic_sysop
Me.Invalidate() forces a Re-Paint
Refresh: Forces the control to invalidate its client area and immediately redraw itself and any child controls.
Invalidate: Invalidates a specific region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation) and causes a paint message to be sent to the control.
I think i am getting close to the difference but it is not still clear.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|