|
-
November 18th, 1999, 02:56 PM
#1
Systray
How can I write a program which is not shown in the Task Bar but has an Icon in the SysTray.
Please help
mfG Pueromane
-
November 19th, 1999, 12:35 AM
#2
Re: Systray
Add this to a Form with an Invisible Picturebox and Set the ShowInTaskBar Property to False.
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 Const WM_LBUTTONDBLCLK = &H203
private Const WM_LBUTTONDOWN = &H201
private Const WM_RBUTTONDOWN = &H204
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_Resize()
DoEvents
If WindowState = vbMinimized then
Hide
End If
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)
Select Case ScaleX(X, vbTwips, vbPixels)
Case WM_RBUTTONDOWN
'Show Popup Menu
Case WM_LBUTTONDBLCLK
'Show the Form
WindowState = vbNormal
Show
End Select
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
November 19th, 1999, 05:36 AM
#3
Re: Systray
Thanks it works fine
mfg Pueromane
-
November 19th, 1999, 10:40 AM
#4
Re: Systray
I don't follow how the Select Case statement works here. Why would the ScaleX function return a match to the button click constants?
Thanks in advance.
-
November 19th, 1999, 12:40 PM
#5
Re: Systray
Because in the TrayIcon Structure we are telling it to send all Messages to the Picturebox Window Handle, and we tell it to use the WM_MOUSEMOVE Message, which triggers the Picture1_MouseMove() Event, because of this it is now passing the wParam and lParam Values Which end up in the X Parameter.
In Order to get the Value of the wParam which is a Long Data Type, we Get the Result of X in Pixels.
Aaron Young
Analyst Programmer
[email protected]
[email protected]
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
|