Cara Menambahkan Icon Notification di Taskbar dengan VB6 - Pada pertemuan kali ini Saya ingin membagikan trik bagaimana cara menambahkan ikon Notification pada Taskbar di komputer Anda.Taskbar adalah komponen dari program windows yang menampung tombol Star, tombol program, salah satunya Icon Notification yang letaknya berada dibawah.
Notification biasanya muncul dibagian pojok kanan bawah dari jendela windows. Biasanya icon notification ini terdiri dari icon-icon tertentu yang berjalan secara start-up, walaupun tidak semua program notification yang masuk ke area notification berjalan secara start-up. Biasanya icon yang masuk ke are notification adalah anti virus, icon volume suara, koneksi internet serta jam dan tanggal.Terkadang ada icon yang selalu muncul otomatis secara start-up dan ada juga yang muncul pada saat program tersebut dijalankan.Anda bisa mengatui icon-icon tesebut agar selalu muncul dan bisa juga Anda menambahkannya sendiri dengan icon program Anda
Berikut dibawah ini dalah kode untuk menambahkan icon Taksbar Notification di komputer Anda dengan menggunakan Visual Basic 6.0 :
Cara Menambahkan Icon Notification di TaskBar dengan menggunakan VB6
1. Buka Form VB6 Anda
2. Tambahkan 3 Commabutton di Form :
-Commandbutton1 Caption : Add the Icon Name: cmdAdd
-Commandbutton2 Caption : Modify the Icon Name: cmdModify
-Commandbutton3 Caption : Delete the Icon Name: cmdDelete
3. Tambahkan 1 Textbox :
-Textbox1 Text : Hello, from the Tray
4. Ketik kode dibawah ini di jendela kode :
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 * 64
End Type
Private Const NIM_ADD = 0
Private Const NIM_MODIFY = 1
Private Const NIM_DELETE = 2
Private Const NIF_MESSAGE = 1
Private Const NIF_ICON = 2
Private Const NIF_TIP = 4
Private Declare Function Shell_NotifyIconA Lib "SHELL32" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer
Private Function setNOTIFYICONDATA(hWnd As Long, ID As Long, _
Flags As Long, CallbackMessage As Long, Icon As Long, _
Tip As String) As NOTIFYICONDATA
Dim nidTemp As NOTIFYICONDATA
nidTemp.cbSize = Len(nidTemp)
nidTemp.hWnd = hWnd
nidTemp.uID = ID
nidTemp.uFlags = Flags
nidTemp.uCallbackMessage = CallbackMessage
nidTemp.hIcon = Icon
nidTemp.szTip = Tip & Chr$(0)
setNOTIFYICONDATA = nidTemp
End Function
Private Sub cmdAdd_Click()
' This will add the Form1 icon to the system tray
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
' This creates our NotifyIconData variable
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
' Now we call our API with this variable
retVal = Shell_NotifyIconA(NIM_ADD, nid)
End Sub
Private Sub cmdModify_Click()
' This will modify an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_MODIFY, nid)
End Sub
Private Sub cmdDelete_Click()
' This will delete an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_DELETE, nid)
End Sub
5. Simpan hasil pekerjaan Anda dan jalankan program
Contoh Gambar dibawah ini adalah hasil dari penambahan icon di taksbar dengan menggunakan kode vb6.
Demukian tip cara Cara Menambahkan Icon Notification di Taskbar dengan VB6 - Pada pertemuan kali ini Saya ingin membagikan trik bagaimana cara menambahkan ikon Notification pada Taskbar di komputer Anda.Taskbar adalah komponen dari program windows yang menampung tombol Star, tombol program, Ikon Notifikasi serta tanggal dan waktu yang letaknya berada dibawah.
Berikut dibawah ini dalah kode untuk menambahkan icon Taksbar Notification di komputer Anda dengan menggunakan Visual Basic 6.0 :
Cara Menambahkan Icon Notification di TaskBar dengan menggunakan VB6
1. Buka Form VB6 Anda2. Tambahkan 3 Commabutton di Form :
-Commandbutton1 Caption : Add the Icon Name: cmdAdd
-Commandbutton2 Caption : Modify the Icon Name: cmdModify
-Commandbutton3 Caption : Delete the Icon Name: cmdDelete
3. Tambahkan 1 Textbox :
-Textbox1 Text : Hello, from the Tray
4. Ketik kode dibawah ini di jendela kode :
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 * 64
End Type
Private Const NIM_ADD = 0
Private Const NIM_MODIFY = 1
Private Const NIM_DELETE = 2
Private Const NIF_MESSAGE = 1
Private Const NIF_ICON = 2
Private Const NIF_TIP = 4
Private Declare Function Shell_NotifyIconA Lib "SHELL32" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer
Private Function setNOTIFYICONDATA(hWnd As Long, ID As Long, _
Flags As Long, CallbackMessage As Long, Icon As Long, _
Tip As String) As NOTIFYICONDATA
Dim nidTemp As NOTIFYICONDATA
nidTemp.cbSize = Len(nidTemp)
nidTemp.hWnd = hWnd
nidTemp.uID = ID
nidTemp.uFlags = Flags
nidTemp.uCallbackMessage = CallbackMessage
nidTemp.hIcon = Icon
nidTemp.szTip = Tip & Chr$(0)
setNOTIFYICONDATA = nidTemp
End Function
Private Sub cmdAdd_Click()
' This will add the Form1 icon to the system tray
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
' This creates our NotifyIconData variable
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
' Now we call our API with this variable
retVal = Shell_NotifyIconA(NIM_ADD, nid)
End Sub
Private Sub cmdModify_Click()
' This will modify an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_MODIFY, nid)
End Sub
Private Sub cmdDelete_Click()
' This will delete an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_DELETE, nid)
End Sub
5. Simpan hasil pekerjaan Anda dan jalankan programPrivate 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 NIM_ADD = 0
Private Const NIM_MODIFY = 1
Private Const NIM_DELETE = 2
Private Const NIF_MESSAGE = 1
Private Const NIF_ICON = 2
Private Const NIF_TIP = 4
Private Declare Function Shell_NotifyIconA Lib "SHELL32" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer
Private Function setNOTIFYICONDATA(hWnd As Long, ID As Long, _
Flags As Long, CallbackMessage As Long, Icon As Long, _
Tip As String) As NOTIFYICONDATA
Dim nidTemp As NOTIFYICONDATA
nidTemp.cbSize = Len(nidTemp)
nidTemp.hWnd = hWnd
nidTemp.uID = ID
nidTemp.uFlags = Flags
nidTemp.uCallbackMessage = CallbackMessage
nidTemp.hIcon = Icon
nidTemp.szTip = Tip & Chr$(0)
setNOTIFYICONDATA = nidTemp
End Function
Private Sub cmdAdd_Click()
' This will add the Form1 icon to the system tray
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
' This creates our NotifyIconData variable
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
' Now we call our API with this variable
retVal = Shell_NotifyIconA(NIM_ADD, nid)
End Sub
Private Sub cmdModify_Click()
' This will modify an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_MODIFY, nid)
End Sub
Private Sub cmdDelete_Click()
' This will delete an existing tray icon
Dim retVal As Integer
Dim nid As NOTIFYICONDATA
nid = setNOTIFYICONDATA( _
Form1.hWnd, vbNull, _
NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
vbNull, Form1.Icon, txtTip)
retVal = Shell_NotifyIconA(NIM_DELETE, nid)
End Sub
Contoh Gambar dibawah ini adalah hasil dari penambahan icon di taksbar dengan menggunakan kode vb6.
Demikian tip cara Cara Menambahkan Icon Notification di Taskbar dengan VB6. Selamat mencoba semoga berhasil.
No comments:
Post a Comment