Results 1 to 40 of 115

Thread: Animated Window Effects with "Toast" popup demo

Threaded View

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Animated Window Effects with "Toast" popup demo

    C# version here.

    FormAnimator class - A helper class that you can add an instance of to a form to provide animation when the form is shown, hidden or closed. Supported animations are Roll (form is unrolled and rolled up from one edge to the opposite), Centre (form unrolls from the centre out and rolls up from all edges in), Slide (form slides in and out from one edge to the opposite) and Blend (form fades in and out). Roll and Slide animations can be up, down, left, right or diagonal. To use this class just add a single line of code similar to this to your form:
    VB Code:
    1. Private myAnimator As New FormAnimator(Me, FormAnimator.AnimationMethod.Slide, FormAnimator.AnimationDirection.Up, 400)

    ToastForm class - An inherited Form class that uses the FormAnimator class to produce the same "toast" effect used by MSN Messenger and other apps, where the form slides up from the system tray and then slides back again after a period of time. To use this class just add code like this:
    VB Code:
    1. Dim myToastForm As New ToastForm(5000, "This is a ""toast"" popup demo.")
    2.  
    3. myToastForm.Show()

    Edit: 30/09/2005
    I've updated the ToastForm class so that it now will not receive focus when it is displayed. It will still receive focus if you click on it though.

    Edit: 30/09/2005
    I've updated the ToastForm class so that existing windows will move up the screen to make way for new ones so that they are not covered.

    Edit: 30/09/2005
    I've updated the ToastForm class so that it stacks properly if the Height is changed and/or multiple forms are opened with different lifetimes.

    Try putting the following code in a form and pressing the button several times in succession to see this in action:
    VB Code:
    1. Dim myRandom As New Random
    2.     Dim formNumber As Integer = 1
    3.  
    4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5.         Dim toast As New ToastForm(myRandom.Next(5000, 10000), "This is form number " & Me.formNumber.ToString())
    6.  
    7.         toast.Height = myRandom.Next(150, 300)
    8.         toast.Show()
    9.         Me.formNumber += 1
    10.     End Sub
    Edit: 01/10/2005
    I don't know if it will help, but for those who have been having issues getting this to work I've attached a full project (VS.NET 2003) that was working for me, so hopefully for you too.

    Edit: 07/10/2005
    It appears that the issues that some have been having are due to a bug in the Framework that was fixed in SP1, so apply SP1 for the .NET Framework 1.1 and all should be well.

    Edit: 21-Nov-2005
    I've removed the original attachments and added new ones. The attached solution was rewritten in VB 2005 with a few changes. The attached class file is from that solution if you just want animation without the toast feature.

    Edit: 27-Nov-2008
    Set the TopMost property of the ToastForm class to True to ensure notification windows were not hidden behind other windows if the caller is not currently active.
    Attached Files Attached Files
    Last edited by jmcilhinney; Nov 26th, 2008 at 10:38 PM. Reason: Remove original and replace with better code
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width