Results 1 to 2 of 2

Thread: [02/03] Drawing a Rectangle

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    116

    [02/03] Drawing a Rectangle

    Dear Friends
    Can any body tell me how to draw a rectangle on a picture box using mouse .


    Regards
    kishore

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [02/03] Drawing a Rectangle

    VB Code:
    1. Private FirstClick As Boolean
    2.     Private P1 As Point
    3.     Private P2 As Point
    4.     Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    5.         FirstClick = Not FirstClick
    6.         If FirstClick Then
    7.             P1 = New Point(e.X, e.Y)
    8.         Else
    9.             P2 = New Point(e.X, e.Y)
    10.             Pic1.CreateGraphics.DrawRectangle(Pens.Black, P1.X, P1.Y, P2.X, P2.Y)
    11.         End If
    12.     End Sub
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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