VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Drop Menu for icon in System Tray

Patrick K. Bigley  (14 Submissions)   Miscellaneous   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Easy Code here: Place an icon in the System Tray and have a drop menu appear when you click the icon with the right-mouse button. If you already have code with bitmaps in your menu, just add this code to your project! This code DOES WORK, just be careful and follow the tips. Then slap yourself for other people's long and drawn out useless code from the past.

Assumes
' Created by [email protected] ' Original source is unknown ' Before you begin! ' Make sure your form is in view within Visual Basic, ' then press Ctrl+E to open the Menu Editor. ' Next create a Main Menu item and make it's name ' property "mnu_1", without the quotes. You can ' always change this name, but make sure that you ' change it in the Form_MouseMove too. Now create a ' few sub menus under the main menu ' and name them anything that you want, ' the code will take care of the rest. ' "TIP: Make the "mnu_1" visible property = False ' Then create a second Main menu item with sub menus ' as normal (This will appear to look as though ' it is the first menu item. The Actual First ' will be seen in the System tray when clicked with ' the right mouse button.

Side Effects
NO SIDE EFFECTS, but make sure your first menu item's name is consistant through out your entire project. (Just remember to refer to the proper main menu item,)

API Declarations

'Uuser defined type required by Shell_NotifyIcon API call
Public 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
'constants required by Shell_NotifyIcon API call:
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA


Rate Drop Menu for icon in System Tray (3(3 Vote))
Drop Menu for icon in System Tray.bas

Drop Menu for icon in System Tray Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters