Results 1 to 2 of 2

Thread: Sizable panel help needed

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    Sizable panel help needed

    I sometimes try to find an out of the question answer to things and here is today's question.

    We have Form1, on form one there is Panel1 set at a size of 72, 56 with a diffrent colored background to see the effects. Now, take the code below and walah.... something pretty nifty happens.

    My question is this: how can a minimum and maximum size be set for the Panel? The code works great but you can expand the Panel as far as your form can reach and you can also shrink the Panel till it dissapears away completely. It needs to have some limits set so it won't go on forever and a day and so that you can't cause it to evaporate into nothing.

    Great minds are encouraged to throw thoughts or examples my way cause I need help more than I have been able to get so far. ROFLMAO

    Code:
    
    Private Sub Panel1_MouseMove(ByVal sender As Object, _
          ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
    
    
    
            If _mouseDown = True Then
                Panel1.Width = e.X
            Else
    
                If e.X >= Panel1.Width - 3 Then
                    Panel1.Cursor = Cursors.VSplit
                Else
                    Panel1.Cursor = Me.Cursor
                End If
    
            End If
    
        End Sub
    
        Private Sub Panel1_MouseDown(ByVal sender As Object, _
          ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
    
            _mouseDown = True
            Panel1.Cursor = Cursors.VSplit
        End Sub
    
        Private Sub Panel1_MouseUp(ByVal sender As Object, _
          ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
    
            _mouseDown = False
            Panel1.Cursor = Me.Cursor
        End Sub

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    I would create a custom panel control - and then define the resize event of it - not allowing it to go past whatever size you want (Me.parent.size....). This way, it is all in a single event handler, and you don't have to do that crazy mouse event stuff.

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