Results 1 to 3 of 3

Thread: how can i draw a rectangle with my mouse ?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2007
    Posts
    60

    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 Attached Files

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    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:
    1. Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    2.         If trace = True Then
    3.             Dim bre As New SolidBrush(Me.BackColor)
    4.  
    5.             '********************************************************
    6.             '*  This is your original code excluding the fillrectangle
    7.             Dim rect As New RectangleF(ancx, ancy, e.X - ancx, e.Y - ancy)
    8.             g.DrawRectangle(Pens.Black, ancx, ancy, e.X - ancx, e.Y - ancy)
    9.             'g.FillRectangle(bre, rect)
    10.  
    11.             '**********************************************************
    12.             '* Here I am creating another rectangle slightly smaller and filling it the
    13.             '* same as the form backcolor
    14.             Dim r As New RectangleF(ancx + 1, ancy + 1, e.X - ancx, e.Y - ancy)
    15.             g.DrawRectangle(Pens.Black, ancx + 1, ancy + 1, e.X - ancx, e.Y - ancy)
    16.             g.FillRectangle(bre, r)
    17.         End If
    18.     End Sub

    Hope this helps


    Things I do when I am bored: DotNetable

  3. #3

    Thread Starter
    Member
    Join Date
    May 2007
    Posts
    60

    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
  •  



Click Here to Expand Forum to Full Width