منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : برنامج صغير لعرض ايقونه في الTask bar
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
كاتب الموضوع : AhmedEssawy

كود :
' shell_notify icon is api which instruct to the the operating
' system to show icon in a taskbar
' it contain two parameter first give message what to be
' done another parameter notifyicon object which contain the
' property of icon
Private Declare Function Shell_NotifyIcon Lib _
"shell32.dll" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'To create structure which variable contain the property of icon
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szToolTip As String * 64
End Type
'then create a object which pass the NotifyIcon procedure
Dim notify As NOTIFYICONDATA
'It declare the constant value
Const NIM_ADD = &H0 'constant value for add the icon in a taskbar
Const NIM_DELETE = &H2 'constant value for remove the icon in a taskbar
Const NIF_TIP = &H4
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const WM_MOUSEMOVE = &H200

Private Sub Form_Load()
Me.mnurun.Checked = False
Me.mnuStop.Checked = False
With notify
.cbSize = Len(obj)
.hwnd = Picture1.hwnd 'to assign the pointer or handle
'property of picture
.uID = 1&
.uFlags = NIF_TIP Or NIF_MESSAGE Or NIF_ICON
.uCallbackMessage = WM_MOUSEMOVE

.hIcon = Picture1.Picture
.szToolTip = "Yellow Color" 'to show the message when
'mouse over on the icon

End With

'lastly,we setup the icon througth the procedre
Shell_NotifyIcon NIM_ADD, notify 'first give message to add
'the icon in a taskbar
End Sub
Private Sub mnurun_Click()
Me.mnurun.Checked = True
Me.mnuStop.Checked = False
'Load Form1
End Sub
Private Sub mnuStop_Click()
Me.mnurun.Checked = False
Me.mnuStop.Checked = True
Shell_NotifyIcon NIM_DELETE, notify
' Unload Form1
Unload Me
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Me.PopupMenu Main
End If
End Sub