Jul 11th, 2007, 02:54 PM
#1
Thread Starter
Member
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
Attached Files
Jul 11th, 2007, 04:59 PM
#2
Fanatic Member
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
Jul 12th, 2007, 03:09 AM
#3
Thread Starter
Member
Re: how can i draw a rectangle with my mouse ?
thank you my friend , this is what i was looking for
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