CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2001
    Posts
    60

    creating a selecting area with the nouse

    I want to add in my program a selecting square area (like in paint or in vb when you want to select multiples controls at the same time). How can I do that ???
    thanks for help

    Make it with rocker style \w/

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: creating a selecting area with the nouse

    Put a Shape control on Form1 and try this code:

    option Explicit
    Dim sTopStart as Single
    Dim sLeftStart as Single

    private Sub Form_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
    If Button = vbLeftButton then
    Shape1.Top = Y
    Shape1.Left = X
    sTopStart = Y
    sLeftStart = X
    Shape1.Height = 0
    Shape1.Width = 0
    Shape1.Visible = true
    End If
    End Sub

    private Sub Form_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)

    If Button = vbLeftButton then
    If Y > sTopStart then
    Shape1.Height = Y - sTopStart
    else
    Shape1.Top = Y
    Shape1.Height = sTopStart - Y
    End If

    If X > sLeftStart then
    Shape1.Width = X - sLeftStart
    else
    Shape1.Left = X
    Shape1.Width = sLeftStart - X
    End If
    End If
    End Sub

    private Sub Form_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
    Shape1.Visible = false
    MsgBox "Whever code to process selection..."
    End Sub





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

Featured