Home > Software engineering >  VB.NET How to make a slide in / out application form (program) in visual studio?
VB.NET How to make a slide in / out application form (program) in visual studio?

Time:10-22

Trying to find how to make a slide in / out application form (program) in visual studio or how do I even google it? I mean all I can find is a form that has a slideable panel, but what I am trying to make is much like windows notifications panel that slides out from outside the screen on the right, but in my case, it would slide from the top.

Could someone, please help with my question?

CodePudding user response:

You can try this to see if it fits your needs.

Create a new project, then in Form1 put a button and double click the button and write inside:

FormNotif.LoadForm ("some parameter to pass thru")

Create a new winform called FormNotif resize to a smaller size(205 x 145) and set the StartPosition to Manual. Add a timer to the FormNotif (Timer1 with interval: 5). Then just copy and paste this code to FormNotif:

Public Class FormNotif

Dim psTimerFunc As String
Dim piCount As Integer

Sub LoadForm(MessageDescription As String)
    Me.Top = -Me.Height
    Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width - 10
    Me.TopMost = True
    Me.BringToFront()
    Me.Show()
    psTimerFunc = "DOWN"
    Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

    Select Case psTimerFunc
        Case "DOWN"
            Me.Top = Me.Top   5
            If Me.Top >= 50 Then
                piCount = 0
                psTimerFunc = "WAIT"
            End If
        Case "WAIT"
            piCount  = 1
            
            If piCount = 600 Then
                psTimerFunc = "UP"
            End If
        Case "UP"
            Me.Top = Me.Top - 5
            If Me.Top   Me.Height < 0 Then
                Timer1.Enabled = False
               
                Me.Close()
            End If
    End Select
End Sub
End Class

You can use the MessageDescription to send some information that you need to display in FormNotif and then use a label or something that fit you needs. After a few secound the message will go up and be closed.

  • Related