Click to See Complete Forum and Search --> : System Tray Icons W/menus... Could ANYONE PLEASE HELP ME..
Certus1
Nov 1st, 1999, 08:18 AM
I've have seen how to add an icon to the system tray, but is there a way of adding the icon with a menu (E.I. when you right click it) such as the toolbar with out using c++... thanks.
------------------
Aaron Young
Nov 5th, 1999, 10:37 AM
No problem, add a Picturebox to a Form, Create a Menu Called mnuPopup and Set it's Visible Property to False, (Uncheck it), then add this code to the Form..
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 Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private Const NIF_ICON = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_TIP = &H4
Private Const NIM_ADD = &H0
Private Const NIM_DELETE = &H2
Private Const NIM_MODIFY = &H1
Private Const WM_MOUSEMOVE = &H200
Private tTrayIcon As NOTIFYICONDATA
Private Sub Form_Load()
'Create a Tray Icon
Picture1.Visible = False
With tTrayIcon
.hIcon = Icon
.hwnd = Picture1.hwnd
.szTip = "My Tray Icon" & Chr(0)
.uCallbackMessage = WM_MOUSEMOVE
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uID = 1
.cbSize = Len(tTrayIcon)
End With
Shell_NotifyIcon NIM_ADD, tTrayIcon
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Remove the Tray Icon
Shell_NotifyIcon NIM_DELETE, tTrayIcon
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Right(Hex(X), 2) = "4B" Then
'Right Clicked Tray Icon
'Show Popup Menu
PopupMenu mnuPopup
End If
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
[This message has been edited by Aaron Young (edited 11-05-1999).]
[-The Punisher-]
Dec 22nd, 1999, 04:51 PM
there's an easier way. Do you have the 2 Visual studio cd's? if you do, find systray.vbp on the 2nd cd and compile it to your windows\system directory. then just add the systray component to your project.
------------------
[-The Punisher-]
death
Dec 25th, 1999, 04:43 AM
you wouldn't stick the ocx on a web page would you please , for download
Thanks
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.