|
-
Nov 2nd, 2012, 09:42 PM
#1
Thread Starter
Lively Member
Slide panel out of form
Hey!
Is it possible to slide a panel out of the actual form? Like you press a button then the panel slides all the way left and then out ? Then it should be able to come back too ?
Is this possible? Any ideas?
-
Nov 2nd, 2012, 11:24 PM
#2
Re: Slide panel out of form
Do you mean into the form, a la the Toolbox and other windows in VS, or do you out of the form?
-
Nov 2nd, 2012, 11:28 PM
#3
Re: Slide panel out of form
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 3rd, 2012, 03:02 PM
#4
Thread Starter
Lively Member
Re: Slide panel out of form
That one worked Paul, it's also exactly what i'm looking for. But I have no idea how its working or even how to call it.
I suspect this is a custom panel control? Could you help me out a bit?
-
Nov 3rd, 2012, 03:21 PM
#5
Re: Slide panel out of form
it is a custom panel control.
you need to add slideOutPanel.vb to your project, then after rebuilding you'll find slideOutPanel at the top of your toolbox + you add it just as any control.
to add controls to it at design time, resize it by dragging the border, + after resize it back to closedWidth.
when you run your project it should work as in my demo project
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 3rd, 2012, 03:24 PM
#6
Thread Starter
Lively Member
Re: Slide panel out of form
Is there any way to make it slide smoother? Thanks by the way.
-
Nov 3rd, 2012, 03:42 PM
#7
Re: Slide panel out of form
try changing the timer interval + the line that sets the width values in tmr_tick
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 3rd, 2012, 04:50 PM
#8
Thread Starter
Lively Member
Re: Slide panel out of form
Okay I managed to modify the interval and the positions so it becomes smooth and nice. However I got another problem.
I put a button in the panel by dragging a button from the toolbox and putting it inside the panel on the designer. I highlighted the panel with my mouse, and the panel slided nice and smooth and the button showed up. However when i highlight the button inside the panel, the panel is closing :/
-
Nov 3rd, 2012, 06:27 PM
#9
Re: Slide panel out of form
I also have a slide out panel example in the codebank, I have it set up in my signature.
-
Nov 3rd, 2012, 07:11 PM
#10
Re: Slide panel out of form
 Originally Posted by Crystalii
Okay I managed to modify the interval and the positions so it becomes smooth and nice. However I got another problem.
I put a button in the panel by dragging a button from the toolbox and putting it inside the panel on the designer. I highlighted the panel with my mouse, and the panel slided nice and smooth and the button showed up. However when i highlight the button inside the panel, the panel is closing :/
ok. try this:
vb.net Code:
Imports System.Drawing.Drawing2D Public Class slideOutPanel Inherits Panel Dim polygon() As Point Dim closedWidth As Integer Dim maxWidth As Integer = 200 Dim caption As String = "Slide Out Panel" Dim closing As Boolean = False Private WithEvents tmr As New Timer Public Sub New() Me.Dock = DockStyle.Right Dim s As SizeF = Me.CreateGraphics.MeasureString(caption, Me.Font) Dim gp As New GraphicsPath polygon = New Point() {New Point(0, 0), New Point(300, 0), New Point(300, 300), New Point(CInt(s.Height), 300), New Point(CInt(s.Height), CInt(s.Width)), New Point(0, CInt(s.Width)), New Point(0, 0)} gp.AddPolygon(polygon) Me.Region = New Region(gp) closedWidth = CInt(s.Height) Me.Width = CInt(s.Height) polygon(2).X -= 1 polygon(3).Y -= 1 polygon(4).Y -= 1 polygon(5).Y -= 1 tmr.Interval = 100 add_handlers(Me) End Sub Private Sub add_handlers(ByVal c As Control) For Each ctrl As Control In c.Controls AddHandler c.MouseEnter, AddressOf handler If ctrl.Controls.Count > 0 Then add_handlers(ctrl) End If Next End Sub Private Sub handler(ByVal sender As Object, ByVal e As EventArgs) OnMouseEnter(e) End Sub Private Sub slideOutPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawPolygon(Pens.Black, polygon) e.Graphics.TranslateTransform(closedWidth, 0) e.Graphics.RotateTransform(90) e.Graphics.DrawString(caption, Me.Font, Brushes.Black, 0, 0) e.Graphics.ResetTransform() End Sub Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) closing = False tmr.Enabled = True MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) closing = True tmr.Enabled = True MyBase.OnMouseLeave(e) End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick If closing Then Me.Width -= Math.Min(50, Me.Width - closedWidth) Else Me.Width += Math.Min(50, maxWidth - Me.Width) End If tmr.Enabled = If(Me.Width = closedWidth Or Me.Width = maxWidth, False, True) End Sub End Class
Last edited by .paul.; Nov 3rd, 2012 at 08:26 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 4th, 2012, 07:34 AM
#11
Thread Starter
Lively Member
Re: Slide panel out of form
The same problem exists unfortunately Paul :/
I will take a look at yours soon dday9.
Thanks.
-
Nov 5th, 2012, 04:56 PM
#12
Thread Starter
Lively Member
Re: Slide panel out of form
I liked your sliding control too dday9. It got no problems. However it is starting opened. Is there any way you can make it start closed?
-
Nov 5th, 2012, 05:14 PM
#13
Re: Slide panel out of form
i fixed the bugs in mine. sorry i couldn't help much earlier... been busy:
vb.net Code:
Imports System.Drawing.Drawing2D Public Class slideOutPanel Inherits Panel Dim polygon() As Point Dim closedWidth As Integer Dim captionHeight As Integer Dim maxWidth As Integer = 200 Dim caption As String = "Slide Out Panel" Dim closing As Boolean = False Private WithEvents tmr As New Timer Public Sub New() Me.Dock = DockStyle.Right Dim s As SizeF = Me.CreateGraphics.MeasureString(caption, Me.Font) Dim gp As New GraphicsPath polygon = New Point() {New Point(0, 0), New Point(300, 0), New Point(300, 300), New Point(CInt(s.Height), 300), New Point(CInt(s.Height), CInt(s.Width)), New Point(0, CInt(s.Width)), New Point(0, 0)} gp.AddPolygon(polygon) Me.Region = New Region(gp) closedWidth = CInt(s.Height) captionHeight = CInt(s.Width) Me.Width = CInt(s.Height) polygon(2).X -= 1 polygon(3).Y -= 1 polygon(4).Y -= 1 polygon(5).Y -= 1 tmr.Interval = 100 End Sub Private Sub slideOutPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.DrawPolygon(Pens.Black, polygon) e.Graphics.RotateTransform(270) e.Graphics.DrawString(caption, Me.Font, Brushes.Black, -captionHeight, 0) e.Graphics.ResetTransform() End Sub Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) closing = False tmr.Enabled = True MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) Dim p As Point = Me.PointToClient(Cursor.Position) If Not Me.Region.IsVisible(p) Then closing = True tmr.Enabled = True End If MyBase.OnMouseLeave(e) End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick If closing Then Me.Width -= Math.Min(50, Me.Width - closedWidth) Else Me.Width += Math.Min(50, maxWidth - Me.Width) End If tmr.Enabled = If(Me.Width = closedWidth Or Me.Width = maxWidth, False, True) End Sub End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 6th, 2012, 11:33 AM
#14
Thread Starter
Lively Member
Re: Slide panel out of form
Thank you, that solved all the bugs
-
May 14th, 2014, 05:06 PM
#15
Lively Member
Re: Slide panel out of form
I know this thread is quite old, but is it possible to make it slide from the left instead of the right?
Thanks
LB
-
May 14th, 2014, 05:13 PM
#16
Re: Slide panel out of form
Start a new thread!
Take a look at this contribution I made: http://www.vbforums.com/showthread.p...ols&highlight=
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
|