Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I am getting error in the below code

VB
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 64

End Type

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

Public Enum Acoes
NIM_ADD = &H0
NIM_DELETE = &H2
NIM_MODIFY = &H1

End Enum

Public Sub Tray(ByVal hWnd&, ByVal hIcon As StdPicture, ByVal sTip$, Acao As Acoes)

Dim i As NOTIFYICONDATA

With i
.hWnd = hWnd
.hIcon = hIcon
.szTip = sTip & vbNullChar
.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
.uCallbackMessage = &H200
.uID = vbNull
.cbSize = Len(i)

Shell_NotifyIcon Acao, i

End With

End Sub


Please let me know the problem here
Posted
Updated 1-Feb-16 19:58pm
v2

1 solution

Try this

VB
Public Sub Tray(ByVal hWnd&, ByVal hIcon As StdPicture, ByVal sTip$, Acao As Acoes)
 
   Dim i As NOTIFYICONDATA
 
   With i
    .hWnd = hWnd
    .hIcon = hIcon
    .szTip = sTip & vbNullChar
    .uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
    .uCallbackMessage = &H200
    .uID = vbNull
    .cbSize = Len(i)
   End With

   Shell_NotifyIcon Acao, i

End Sub
 
Share this answer
 
Comments
Black_Rose 2-Feb-16 4:44am    
I did that. now i am getting expected '(' at line 1 char 27
_Asif_ 2-Feb-16 5:13am    
there nothing seems to be wrong at line 1. can you show it here what your line 1 is
Black_Rose 2-Feb-16 5:33am    
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
_Asif_ 2-Feb-16 6:16am    
Try readin this "http://stackoverflow.com/questions/9378313/display-new-mail-icon-in-windows-taskbar-using-vbscript", its almost identical of what you are doing and it works
Black_Rose 2-Feb-16 6:25am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900