Berikut adalah kode VB 6.0 untuk meletakkan aplikasi yang telah kita buat pada system tray windows:
Option ExplicitPrivate Type NOTIFYICONDATAcbSize As LonghWnd As LonguId As LonguFlags As LongucallbackMessage As LonghIcon As LongszTip As String * 64End TypePrivate Const NIM_ADD = &H0Private Const NIM_MODIFY = &H1Private Const NIM_DELETE = &H2Private Const WM_MOUSEMOVE = &H200Private Const NIF_MESSAGE = &H1Private Const NIF_ICON = &H2Private Const NIF_TIP = &H4Private Declare Function Shell_NotifyIcon Lib "shell32" _Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid _As NOTIFYICONDATA) As BooleanDim t As NOTIFYICONDATAPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)Timer1.Enabled = Falset.cbSize = Len(t)t.hWnd = Picture1.hWndt.uId = 1&Shell_NotifyIcon NIM_DELETE, tEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)If Hex(X) = "1E3C" Then Me.PopupMenu menu1End IfEnd SubPrivate Sub Timer1_Timer()Static i As Long, img As Longt.cbSize = Len(t)t.hWnd = Picture1.hWndt.uId = 1&t.uFlags = NIF_ICONt.hIcon = Picture1.PictureShell_NotifyIcon NIM_MODIFY, tTimer1.Enabled = Truei = i + 1If i = 2 Then i = 0End SubPrivate Sub Form_Load()t.cbSize = Len(t)t.hWnd = Picture1.hWndt.uId = 1&t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGEt.ucallbackMessage = WM_MOUSEMOVEt.hIcon = Picture1.Picturet.szTip = "System Tray" & Chr$(0)Shell_NotifyIcon NIM_ADD, tTimer1.Enabled = TrueMe.HideApp.TaskVisible = FalseEnd Sub
0 komentar:
Posting Komentar