|
-
Jul 9th, 2004, 07:16 AM
#1
Thread Starter
Addicted Member
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]
-
Jul 13th, 2004, 02:32 PM
#2
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|