Click to See Complete Forum and Search --> : Mouse Input Headache, pleeeeease help


bufer24
10-09-2006, 02:39 PM
I really donīt understand the following problem:
I am trying to draw a single rectangle on a form using GDI+ It is really simple. I put the drawing commands into this procedure:

Protected Overrides Sub OnPaint(byval e as.....blah blah)
....drawing code...
//x and y are still zero even if they were assigned a value in the formīs MouseMove event
End sub

Now I want to move the rectangle using a mouse. (center of rectangle=mouse coordinates), so I declare two public variables x and y and in the form mousemove event I assign the mouse position to them. The I call the Formīs Paint event using Me.Validate().
But when I try to use the variables x and y in the "Protected Overrides Sub OnPaint..." procedure, they donīt seem to have a value. They are still zero.
What is wrong? The values are good in other procedures - why not in the OnPaint sub?

bufer24
10-09-2006, 03:33 PM
while I was waiting for a reply, I could solve this problem.
Instead to use Me.Validate() to call the paint event, I used Me.Refresh.
And Thatīs it. It works.