1 Attachment(s)
how can i draw a rectangle with my mouse ?
Hello everybody , i'm currently developping an application that draw a rectangle with my mouse , nothing very hard
My qustion : I want( like in paint ) to draw only the perimeter of my rectangle when i move my mouse without filling it with a color
i have attached my project
Can u help me
thank you
Re: how can i draw a rectangle with my mouse ?
This is my version of drawing a rectangle. You were just about there.
VB Code:
Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If trace = True Then
Dim bre As New SolidBrush(Me.BackColor)
'********************************************************
'* This is your original code excluding the fillrectangle
Dim rect As New RectangleF(ancx, ancy, e.X - ancx, e.Y - ancy)
g.DrawRectangle(Pens.Black, ancx, ancy, e.X - ancx, e.Y - ancy)
'g.FillRectangle(bre, rect)
'**********************************************************
'* Here I am creating another rectangle slightly smaller and filling it the
'* same as the form backcolor
Dim r As New RectangleF(ancx + 1, ancy + 1, e.X - ancx, e.Y - ancy)
g.DrawRectangle(Pens.Black, ancx + 1, ancy + 1, e.X - ancx, e.Y - ancy)
g.FillRectangle(bre, r)
End If
End Sub
Hope this helps
Re: how can i draw a rectangle with my mouse ?
thank you my friend , this is what i was looking for