my code stock.com

displays a balloon message on taskbar

Snippet options

Download: Download snippet as balloon-messages.vbs.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

Public Result As Boolean
    <StructLayout(LayoutKind.Sequential)> Public Structure NOTIFYICONDATA
        Dim cbSize As Int32
        Dim hwnd As IntPtr
        Dim uID As Int32
        Dim uFlags As Int32
        Dim uCallbackMessage As IntPtr
        Dim hIcon As IntPtr
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Dim szTip As String
        Dim dwState As Int32
        Dim dwStateMask As Int32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Dim szInfo As String
        Dim uVersion As Int32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Dim szInfoTitle As String
        Dim dwInfoFlags As Int32
    End Structure
    Public Const NIF_MESSAGE As Int32 = &H1
    Public Const NIF_ICON As Int32 = &H2
    Public Const NIF_STATE As Int32 = &H8
    Public Const NIF_INFO As Int32 = &H10
    Public Const NIF_TIP As Int32 = &H4
    Public Const NIM_ADD As Int32 = &H0
    Public Const NIM_MODIFY As Int32 = &H1
    Public Const NIM_DELETE As Int32 = &H2
    Public Const NIM_SETVERSION As Int32 = &H4
    Public Const NOTIFYICON_VERSION As Int32 = &H5
    Public Const NIS_HIDDEN = &H1
    Public Const NIS_SHAREDICON = &H2
    Public Const NIIF_ERROR = &H3
    Public Const NIIF_INFO = &H1
    Public Const NIIF_NONE = &H0
    Public Const NIIF_WARNING = &H2
    Public Const NIM_SETFOCUS = &H4
    Public Const NIIF_GUID = &H5
    Public Declare Function Shell_NotifyIcon Lib "shell32.dll" _
    Alias "Shell_NotifyIconA" (ByVal dwMessage As Int32, _
    ByRef lpData As NOTIFYICONDATA) As Boolean
    Public uNIF As NOTIFYICONDATA
    Public WithEvents tmrBallon As New Timer
    SUB ballon(ByVal frm As Form, ByVal mensaje As String, ByVal tipo As Int16, ByVal timer As Timer, ByVal tiempo As Int16)
        With uNIF
            .cbSize = Marshal.SizeOf(uNIF)
            .hwnd = frm.Handle
            .uID = 1
            .dwInfoFlags = NIF_ICON Or NIF_MESSAGE
            .uCallbackMessage = New IntPtr(&H500)
            .uVersion = NOTIFYICON_VERSION
            .hIcon = frm.Icon.Handle
            .uFlags = NIF_INFO
            .uVersion = 2000

            If tipo = 0 Then .szInfoTitle = "Información"
            If tipo = 1 Then .szInfoTitle = "Precaución"
            If tipo = 2 Then .szInfoTitle = "ERROR"
            .szInfo = mensaje

            If tipo = 0 Then .dwInfoFlags = NIIF_INFO
            If tipo = 1 Then .dwInfoFlags = NIIF_WARNING
            If tipo = 2 Then .dwInfoFlags = NIIF_ERROR
        End With
        Result = Shell_NotifyIcon(NIM_ADD, uNIF)
        If tiempo <> 0 Then
            timer.Interval = tiempo
            timer.Enabled = True
        End If
    End Sub
    Private Sub tmrBallon_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrBallon.Tick
        Result = Shell_NotifyIcon(NIM_DELETE, uNIF)
        tmrBallon.Enabled = False
    End Sub

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.