Results 1 to 2 of 2

Thread: Dragging A Scrollable Panel?

  1. #1

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166

    Dragging A Scrollable Panel?

    Ok, I have a panel that the scrollable option is = true. I want the user to be able to left click and drag the panel and the scroll bars move accordingly. I am fairly new to c#.


    Here is code in VB6 that would allow me to do that if that helps at all. Thanks.

    [code]


    Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) Then
    Screen.MousePointer = 5
    OldX = X
    OldY = Y
    End If
    End Sub

    Private Sub frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim ScrollVert As Single, ScrollHoriz As Single
    Dim NewLeft As Long, NewTop As Long
    Dim DeltaX As Long, DeltaY As Long
    If (Button = 1) Then

    NewLeft = Frame1.Left + X - OldX
    NewTop = Frame1.Top + Y - OldY
    DeltaX = X - OldX
    DeltaY = Y - OldY

    If (Frame2.Height < Frame1.Height) Then
    ScrollVert = 100 * (-NewTop / (Frame1.Height - Frame2.Height))
    Else
    ScrollVert = 100 * (-NewTop / Frame1.Height)
    End If

    If (ScrollVert > 100) Then
    ScrollVert = 100
    NewTop = Frame1.Top
    DeltaY = 0
    ElseIf (ScrollVert < 0) Then
    ScrollVert = 0
    NewTop = Frame1.Top
    DeltaY = 0
    End If

    If (Frame2.Width < Frame1.Width) Then
    ScrollHoriz = 100 * (-NewLeft / (Frame1.Width - Frame2.Width))
    Else
    ScrollHoriz = 100 * (-NewLeft / Frame1.Width)
    End If

    If (ScrollHoriz > 100) Then
    ScrollHoriz = 100
    NewLeft = Frame1.Left
    DeltaX = 0
    ElseIf (ScrollHoriz < 0) Then
    ScrollHoriz = 0
    NewLeft = Frame1.Left
    DeltaX = 0
    End If

    VScroll1.Value = ScrollVert
    HScroll1.Value = ScrollHoriz
    Frame1.Left = NewLeft
    Frame1.Top = NewTop
    FrameX.Left = FrameX.Left + DeltaX
    FrameY.Top = FrameY.Top + DeltaY

    End If
    End Sub

    [\code]

  2. #2

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Anyone? I want the user to be able to mouse down and be able to drag the panel instead of using the scroll bars. Any ideas?

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