Create Balloon Tips in SysTray

You may wondering how to create balloon tips in Visual Basic put in systray.

Allright then, this is how!

Option Explicit
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End TypePrivate sysTray As NOTIFYICONDATA

'Constants
Private Const NOTIFYICON_VERSION = 3
Private Const NOTIFYICON_OLDVERSION = 0

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2

Private Const NIM_SETFOCUS = &H3
Private Const NIM_SETVERSION = &H4

Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const NIF_STATE = &H8
Private Const NIF_INFO = &H10

Private Const NIS_HIDDEN = &H1
Private Const NIS_SHAREDICON = &H2

Private Const NIIF_NONE = &H0
Private Const NIIF_WARNING = &H2
Private Const NIIF_ERROR = &H3
Private Const NIIF_INFO = &H1
Private Const NIIF_GUID = &H4

Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206

' API Declaration
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Private Sub Command1_Click()

With sysTray
.cbSize = Len(sysTray)
.hWnd = Me.Picture1.hWnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_INFO Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Picture1.Picture
.szTip = " Here placing toolTip " & vbNullChar
.dwState = 0
.dwStateMask = 0
End With

Shell_NotifyIcon NIM_ADD, sysTray

End Sub

Private Sub Command2_Click()
With sysTray
.cbSize = Len(sysTray)
.hWnd = Picture1.hWnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_INFO Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Picture1
.szTip = " Here placing toolTip " & vbNullChar
.dwState = 0
.dwStateMask = 0
.szInfo = Text2 & Chr(0)
.szInfoTitle = Text1 & Chr(0)
.dwInfoFlags = NIIF_INFO
.uTimeout = 100
End With

Shell_NotifyIcon NIM_MODIFY, sysTray
End Sub

Private Sub Command3_Click()
Shell_NotifyIcon NIM_DELETE, sysTray
End Sub

Private Sub Form_Load()
Command1.Caption = " Report on Systray "
Command2.Caption = " Show Balloon dialogue "
Command3.Caption = " Remove from systray "
Text1 = App.EXEName
Text2 = " Welcome to STMIK Banjarbaru zone! "
End Sub

2 Responses to Create Balloon Tips in SysTray

  1. Abhi says:

    hello friend,
    this is nice one, its working like a charm.
    i want to know can we use this in C++ Console program. please tell me if you have any idea.

  2. frozenade says:

    Hello..

    Take a look at this link.

    GBU.😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: