i'm learning using the Graphics object. i understand the steps for use it and how make it persistence(using paint event).
but why i can't combine the mouse with graphic persistence?
- that 2 mouse variables is for save the mouse coordenates(but i only recive 0):(;
- then i must combine the variable Graphics with Pain event using the 'e' parameter;
- then i clear the parent area with it backcolor;
- then i draw the rectangule with mouse coordenates(but i recive the same value\result\position);
- then i must clear the graphic object.
the actual results is that it's drawing the rectangule in same positon and i don't understand what it's wrong with MouseMove event. can anyone tell me what i'm doing wrong?
(i did these sample, for learn, but imagine click on mouse button for do lines(with mouse move)... i don't understand why these 'bug':()
but why i can't combine the mouse with graphic persistence?
Code:
Public Class Form1
Dim mousex As Long
Dim mousey As Long
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
mousex = e.X
mousey = e.Y
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim s As Graphics
s = e.Graphics
s.Clear(Me.BackColor)
Debug.Print(mousey & " " & mousex)
s.DrawRectangle(Pens.Aqua, mousex, mousey, 100, 100)
s.Dispose()
End Sub
End Class- then i must combine the variable Graphics with Pain event using the 'e' parameter;
- then i clear the parent area with it backcolor;
- then i draw the rectangule with mouse coordenates(but i recive the same value\result\position);
- then i must clear the graphic object.
the actual results is that it's drawing the rectangule in same positon and i don't understand what it's wrong with MouseMove event. can anyone tell me what i'm doing wrong?
(i did these sample, for learn, but imagine click on mouse button for do lines(with mouse move)... i don't understand why these 'bug':()