|
-
Nov 1st, 1999, 09:18 AM
#1
Thread Starter
New Member
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.
------------------
-
Nov 5th, 1999, 11:37 AM
#2
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..
Code:
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
[email protected]
[email protected]
[This message has been edited by Aaron Young (edited 11-05-1999).]
-
Dec 22nd, 1999, 05:51 PM
#3
New Member
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-]
-
Dec 25th, 1999, 05:43 AM
#4
Lively Member
you wouldn't stick the ocx on a web page would you please , for download
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|