Advertisement
C_Volume2 Windows System Services #73372

How to add an icon to the tray

One of the questions that occurs most often in the VB Q and A forum is how to add an icon to the tray area of the Windows 95 taskbar.This tip will show you how to add and delete the icon,and also trap the mouse events.

AI

ملخص الذكاء الاصطناعي: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

كود المصدر
original-source
Public Sub CreateIcon()
       Dim Tic As NOTIFYICONDATA
       Tic.cbSize = Len(Tic)
       Tic.hwnd = Picture1.hwnd
       Tic.uID = 1&
       Tic.uFlags = NIF_DOALL
       Tic.uCallbackMessage = WM_MOUSEMOVE
       Tic.hIcon = Picture1.Picture
       Tic.szTip = "Visual Basic Demo Project" & Chr$(0)
       erg = Shell_NotifyIcon(NIM_ADD, Tic)
       End Sub
       Public Sub DeleteIcon()
       Dim Tic As NOTIFYICONDATA
       Tic.cbSize = Len(Tic)
       Tic.hwnd = Picture1.hwnd
       Tic.uID = 1&
       erg = Shell_NotifyIcon(NIM_DELETE, Tic)
       End Sub
Private Sub Command1_Click()
CreateIcon
End Sub
Private Sub Command2_Click()
DeleteIcon
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
X = X / Screen.TwipsPerPixelX
       Select Case X
       Case WM_LBUTTONDOWN
       Caption = "Left Click"
       Case WM_RBUTTONDOWN
       Caption = "Right Click"
       Case WM_MOUSEMOVE
       Caption = "Move"
       Case WM_LBUTTONDBLCLK
       Caption = "Double Click"
       End Select
End Sub
التعليقات الأصلية (3)
مسترجع من Wayback Machine