|
-
Jun 5th, 2014, 10:17 AM
#1
[RESOLVED] Control.Invalidate(Rectangle) invalidating the whole control?
I might be blind, however it looks to me as if
Code:
With Rectangle
.X = 0
.Y = 0
.Width = 0
.Height = 0
End With
Control.Invalidated(Rectangle)
will Invalidate the whole control. I was expecting it to invalidate only the Rectangle, i.e. nothing in this case.
Can anybody help me on that.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jun 5th, 2014, 10:21 AM
#2
Re: Control.Invalidate(Rectangle) invalidating the whole control?
What is Rectangle, is it the PowerPack rectangle, some kind of custom class, etc. ?
-
Jun 5th, 2014, 10:25 AM
#3
Re: Control.Invalidate(Rectangle) invalidating the whole control?
Sorry, I was lazy, Rectangle is a System.Drawing.Rectangle.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jun 5th, 2014, 10:29 AM
#4
Re: Control.Invalidate(Rectangle) invalidating the whole control?
I would guess it's just a Drawing.Rectangle.
From what little I've seen, that should invalidate only part of a control. However, how did you determine that you are not triggering an invalidation of the entire control invadvertently? For example, do you know that you are getting only one Paint event?
My usual boring signature: Nothing
 
-
Jun 5th, 2014, 10:37 AM
#5
Re: Control.Invalidate(Rectangle) invalidating the whole control?
I did the the obvious test (which I should have done before posting)
In identical situations I have following lines in the mouse_mouse routine.
Code:
picbox.Invalidate(New Rectangle(0,0,0,0))
or
Code:
picbox.Invalidate(New Rectangle(0,0,10,10))
In the first case, the mouse_move will cause a Paint of the whole picbox, in the second one only the Top-Left (10*10) will be painted.
@Shaggy Hiker
If you remember my lst Thread about GameLoop into anothzer thread, I had this weird behaviour when thew picbox got updated by moving the mouse over it. It looks like this is the real reason.
Please don't count the houres of worthless searching!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jun 5th, 2014, 10:41 AM
#6
Re: Control.Invalidate(Rectangle) invalidating the whole control?
One other question on "do you know that you are getting only one Paint event?"
Is there a way to log/trace/whatever all events?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jun 5th, 2014, 10:47 AM
#7
Re: Control.Invalidate(Rectangle) invalidating the whole control?
I did not know that you could invalidate a certain area/region of a control, but that shows my ignorance. I should've looked up the acceptable parameters for the Invalidate method.
What I think might be happening is that because you're setting the values of the rectangle to it's default values(0), it may be ignoring the rectangle all together and invalidating the control as if you only called Control.Invalidate(). That seems logical because think about it, what would be invalidated at (0, 0, 0, 0), sure the location is (0, 0) but the size is also (0, 0).
-
Jun 5th, 2014, 11:20 AM
#8
Re: Control.Invalidate(Rectangle) invalidating the whole control?
Seems pretty straight-forward behaviour, treating a zero-size rectangle as a null rectangle, and responding to that by invalidating the entire container. I mean, if you really wanted to invalidate a rectangle of zero-size, you could have just not called Invalidate(), amirite? In what situation would you end up trying to invalidate a zero-size rectangle anyway?
-
Jun 5th, 2014, 12:17 PM
#9
Re: Control.Invalidate(Rectangle) invalidating the whole control?
 Originally Posted by Evil_Giraffe
Seems pretty straight-forward behaviour, treating a zero-size rectangle as a null rectangle, and responding to that by invalidating the entire container. I mean, if you really wanted to invalidate a rectangle of zero-size, you could have just not called Invalidate(), amirite? In what situation would you end up trying to invalidate a zero-size rectangle anyway?
Absolutely correct!
Code:
Public Sub Invalidate(ByVal rc As Rectangle, ByVal invalidateChildren As Boolean)
If rc.IsEmpty Then
Me.Invalidate(invalidateChildren)
ElseIf Me.IsHandleCreated Then
If invalidateChildren Then
Dim rcUpdate As RECT = RECT.FromXYWH(rc.X, rc.Y, rc.Width, rc.Height)
SafeNativeMethods.RedrawWindow(New HandleRef(Me.window, Me.Handle), rcUpdate, NativeMethods.NullHandleRef, &H85)
Else
Dim rect As RECT = RECT.FromXYWH(rc.X, rc.Y, rc.Width, rc.Height)
Using New MultithreadSafeCallScope
SafeNativeMethods.InvalidateRect(New HandleRef(Me.window, Me.Handle), rect, ((Me.controlStyle And ControlStyles.Opaque) <> ControlStyles.Opaque))
End Using
End If
Me.NotifyInvalidate(rc)
End If
End Sub
-
Jun 5th, 2014, 12:18 PM
#10
Re: Control.Invalidate(Rectangle) invalidating the whole control?
Last edited by TnTinMN; Jun 5th, 2014 at 12:21 PM.
Reason: double post
-
Jun 5th, 2014, 02:46 PM
#11
Re: Control.Invalidate(Rectangle) invalidating the whole control?
Thanks for all the inputs.
Now understand the "weird" behaviour I saw.
On the question, why I would want to .Invalidate a zero size rectangle. I'm was starting of with a zero size rectangle in order to collect rectangles in from different possible (exclusive) situation.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
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
|