DO NOT DEAL WITH THIS MEMBER
Jan 24, 2016 12:25 PM
(This post was last modified: Jan 24, 2016 03:16 PM by Dangerous Beef.)
I'm working on the Job system which is a Table Layout Panel but I'm working on a panel for testing. I've figured out how to scroll but to hide the scroll bars is a whole other thing.
Since the default scroll bars doesn't match the color theme of my game i can't let them be visible.
Here's the code to scroll within a control:
Quote: Private Sensitivity As Integer = 20
Private Sub panel1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Panel1.MouseWheel
If Panel1.Bounds.Contains(e.Location) Then
Dim vScrollPosition As Integer = Panel1.VerticalScroll.Value
vScrollPosition -= Math.Sign(e.Delta) * Sensitivity
vScrollPosition = Math.Max(0, vScrollPosition)
vScrollPosition = Math.Min(vScrollPosition, Me.VerticalScroll.Maximum)
Panel1.AutoScrollPosition = New Point(Panel1.AutoScrollPosition.X,
vScrollPosition)
Panel1.Invalidate()
End If
End Sub
Been searching around on google and found nothing that worked.
Edit:
Solution(Though not elegant):
Quote: pnl_HideScrollBar.Location = New Point(tlp_Jobs.Location.X + tlp_Jobs.Width - 20, tlp_Jobs.Location.Y)
pnl_HideScrollBar.BackColor = Me.BackColor
tlp_Jobs.MaximumSize = New Point(tlp_Jobs.MaximumSize.Width, Me.Height - tlp_Jobs.Location.Y - 62)
pnl_HideScrollBar.Height = tlp_Jobs.Height
Have you tried setting autoscroll on the panel to false?
DO NOT DEAL WITH THIS MEMBER
(Jan 24, 2016 12:39 PM)6e756c6c Wrote: Have you tried setting autoscroll on the panel to false?
Of course :)
Setting it to false disables my ability to scroll with the mouse wheel.
Jan 24, 2016 12:46 PM
(This post was last modified: Jan 24, 2016 12:50 PM by AnonCensored.)
If this what you looking for ?
PHP Code
<?php For Each ctrl As Control In Panel1.Controls Panel1.AutoScroll = False Next
DO NOT DEAL WITH THIS MEMBER
(Jan 24, 2016 12:46 PM)AnonCensored Wrote:
If this what you looking for ?
![[Image: fbd08bf11f83e9fe839dfd6a75e3b537.gif]](https://i.gyazo.com/fbd08bf11f83e9fe839dfd6a75e3b537.gif)
PHP Code
<?php For Each ctrl As Control In Panel1.Controls Panel1.AutoScroll = False Next
Like I've said in my previous post disabling AutScroll disables my ability to scroll. Thanks though.
You can use the ShowScrollBar function (Windows API, available in Vista and later). Just call it when your form is shown and call it in the MouseWheel event of the Panel. Admittedly though, there is probably a better solution and I haven't done any kind of performance testing. It's something though.
Code <DllImport("user32.dll", EntryPoint:="ShowScrollBar")> _
Public Shared Function ShowScrollBar( _
ByVal handle As IntPtr, _
ByVal scrollbar As Integer, _
ByVal visible As Boolean) As Boolean
End Function
Private Sub Panel1_MouseWheel(sender As Object, e As MouseEventArgs) Handles Panel1.MouseWheel
ShowScrollBar(Panel1.Handle, 3, False)
End Sub
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
ShowScrollBar(Panel1.Handle, 3, False)
End Sub
Jan 24, 2016 12:52 PM
(This post was last modified: Jan 24, 2016 12:53 PM by AnonCensored.)
(Jan 24, 2016 12:51 PM)Dangerous Beef Wrote: Like I've said in my previous post disabling AutScroll disables my ability to scroll. Thanks though.
Oh sorry got confused.. So you want to still be able to scroll but have the visible off right ?
Nvm seems like aerohack has this
Jan 24, 2016 12:54 PM
(This post was last modified: Jan 24, 2016 12:59 PM by 6e756c6c.)
Actually after testing a little more it appears the solution I provided fails if you activate a control in the panel. Let us know if you get it working though!
Edit 2:
Appears to work, with some flickering, if you also ShowScrollBar in the Panel's child control(s) MouseCaptureChanged events.
DO NOT DEAL WITH THIS MEMBER
(Jan 24, 2016 12:54 PM)6e756c6c Wrote: Actually after testing a little more it appears the solution I provided fails if you activate a control in the panel. Let us know if you get it working though!
Edit 2:
Appears to work, with some flickering, if you also ShowScrollBar in the Panel's child control(s) MouseCaptureChanged events.
Ehm, where should i put "<DllImport("user32.dll", EntryPoint:="ShowScrollBar")>" ?
Jan 24, 2016 01:10 PM
(This post was last modified: Jan 24, 2016 01:12 PM by AnonCensored.)
(Jan 24, 2016 01:01 PM)Dangerous Beef Wrote: Ehm, where should i put "<DllImport("user32.dll", EntryPoint:="ShowScrollBar")>" ?
![[Image: 7AgvBZb.png]](https://i.imgur.com/7AgvBZb.png)
Underneath you're form class
DO NOT DEAL WITH THIS MEMBER
Jan 24, 2016 01:17 PM
(This post was last modified: Jan 24, 2016 01:17 PM by Dangerous Beef.)
(Jan 24, 2016 01:10 PM)AnonCensored Wrote: Underneath you're form class
Omg it works, thanks and to you AeonHack.
@AeonHack, Are you sure it won't work for Windows XP users ? Would really like the XP if i could.
Jan 24, 2016 01:24 PM
(This post was last modified: Jan 24, 2016 01:24 PM by 6e756c6c.)
MSDN for ShowScrollBar says "Minimum supported client: Windows Vista [desktop apps only]". So if you want to support XP (which you honestly shouldn't, it's dead) you'll need to find another method.
DO NOT DEAL WITH THIS MEMBER
(Jan 24, 2016 01:24 PM)6e756c6c Wrote: MSDN (https://msdn.microsoft.com/en-us/library...85%29.aspx) says "Minimum supported client: Windows Vista [desktop apps only]". So if you want to support XP (which you honestly shouldn't, it's dead) you'll need to find another method.
Haha, the scrolling got all messed up and the scroll bar is flickering on/off the visibility state. I guess I'll just cover the scroll bar up with another panel :/.
https://i.imgur.com/iB7oibz.gifv
Thanks for your help though.
DO NOT DEAL WITH THIS MEMBER
(Jan 24, 2016 01:26 PM)Dangerous Beef Wrote: Haha, the scrolling got all messed up and the scroll bar is flickering on/off the visibility state. I guess I'll just cover the scroll bar up with another panel :/.
https://i.imgur.com/iB7oibz.gifv
Thanks for your help though.
You can also capture the scrollevent and programmatically change the child controls in the panel. So when a user scrolls instead of actually scrolling you just make the correct child controls visible and the rest invisible or something.
Don't have time to look into it for you, and am not sure how the scrollbars work inside of the Panel component exactly, but if they work like most other controls then the scrollbar is actually just another control embedded inside of the Panel itself. Knowing this you can assign the scrollbar to a NativeWindow and subclass the WndProc. Having control over this will allow you to effectively hide the scrollbar without disabling (thus keeping scroll functionality), or you can just override the painting of the scrollbar and choose to not draw anything. Hope this can shed some light.
Need a custom software? Check out my freelance service here! 6+ years and counting, never a complaint :)
STOP STEALING CODE.
FREE NATHAN
People who report posts are lamers.
|