Imports System.Runtime.InteropServices
Public Class Toast
<DllImport("user32.dll", EntryPoint:="AnimateWindow")>
Private Shared Function AnimateWindow(ByVal hWnd As IntPtr, ByVal dwTime As UInteger, ByVal dwFlags As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Functionemo
Private Const AW_HIDE As Integer = &H10000 Private Const AW_BLEND As Integer = &H80000
Private Const AW_VER_POSITIVE As Integer = &H4
Private Const AW_VER_NEGATIVE As Integer = &H8
Private Const AW_SLIDE As Integer = &H40000
'https://www.dreamincode.net/forums/topic/383202-windows-toast-popup/
Public Sub New(ByVal MsgTitle As String, ByVal MsgText As String)
InitializeComponent()
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.Size = New Size(300, 100)
Me.ShowInTaskbar = False
Me.BackColor = Color.SkyBlue
Me.StartPosition = FormStartPosition.Manual
'Me.Location = New Point(Screen.PrimaryScreen.Bounds.Width - Me.Width, 0)
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Do Until x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
x = x - 1
Me.Location = New Point(x, y)
Loop
Me.TopMost = True
Label1.Location = New Point(12, 10)
Label1.ForeColor = Color.White
Label1.Font = New Font("Lucida Sans", 12, FontStyle.Bold Or FontStyle.Underline)
Label1.Text = MsgTitle
Label2.Location = New Point(12, 45)
Label2.ForeColor = Color.White
Label2.Font = New Font("Lucida Sans", 10, FontStyle.Bold)
Label2.Text = MsgText
'Button1.FlatStyle = FlatStyle.Flat
'Button1.FlatAppearance.BorderSize = 0
'Button1.FlatAppearance.MouseOverBackColor = Color.SkyBlue
'Button1.BackColor = Color.SkyBlue
'Button1.ForeColor = Color.White
'Button1.Text = "X"
'Button1.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
'Button1.Size = New Size(25, 25)
'Button1.Location = New Point(Me.Width - Button1.Width, 0)
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles Button1.Click
Me.Close()
End Sub
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
AnimateWindow(Me.Handle, 1000, AW_HIDE Or AW_SLIDE Or AW_VER_POSITIVE)
End Sub
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AnimateWindow(Me.Handle, 1000, AW_SLIDE Or AW_VER_NEGATIVE)
End Sub
'Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' AnimateWindow(Me.Handle, 1000, AW_HIDE Or AW_SLIDE Or AW_VER_NEGATIVE)
'End Sub
'Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' AnimateWindow(Me.Handle, 1000, AW_SLIDE Or AW_VER_POSITIVE)
'End Sub
End Class