AceInfinity

Senior Member
Microsoft MVP
Joined
Aug 12, 2011
Messages
161
Here's a cool module I created a while ago. I got the idea with some cool fading effects... Maybe you'll find use for this too :)

If you want something fancy, try this Module I came up with:
Code:
Imports System.Threading

Module FormSwitcher
    <System.Runtime.CompilerServices.Extension()> _
    Public Sub SwitchForm(OriginalForm As Form, NewForm As Form)
        NewForm.Opacity = 0
        NewForm.Show()
        NewForm.Location = OriginalForm.Location

        OriginalForm.MatchSize(NewForm.Size)
        For d As Double = 1.0 To 0.0 Step -0.25
            OriginalForm.Opacity = d
            NewForm.Opacity = 1 - d
            Thread.Sleep(100)
        Next

        OriginalForm.Hide()
        OriginalForm.Opacity = 1
    End Sub

    <System.Runtime.CompilerServices.Extension()> _
    Private Sub MatchSize(OriginalForm As Form, NewSize As Size)
        Dim S As Size = OriginalForm.Size
        Dim Stepper As Integer = 0
        If S.Width <> NewSize.Width Then Stepper = If(S.Width < NewSize.Width, 1, -1)
        If Stepper <> 0 Then
            For i As Integer = S.Width To NewSize.Width Step Stepper
                OriginalForm.Width = i
            Next
        End If

        If S.Height <> NewSize.Height Then Stepper = If(S.Height < NewSize.Height, 1, -1)
        If Stepper <> 0 Then
            For i As Integer = S.Height To NewSize.Height Step Stepper
                OriginalForm.Height = i
            Next
        End If
    End Sub
End Module

Usage:
Code:
Me.SwitchForm(Form2)

PevMs.gif
 


Solution
It looks like you've shared a custom module in VB.NET for implementing a form switching functionality with fading effects. This module allows you to smoothly transition between forms by adjusting their opacity and size gradually.
The provided code seems well-structured and offers a creative way to enhance the user interface of your applications with elegant transitions.
If you have any specific questions or need assistance with this module, feel free to ask!
It looks like you've shared a custom module in VB.NET for implementing a form switching functionality with fading effects. This module allows you to smoothly transition between forms by adjusting their opacity and size gradually.
The provided code seems well-structured and offers a creative way to enhance the user interface of your applications with elegant transitions.
If you have any specific questions or need assistance with this module, feel free to ask!
 


Solution
Back
Top