|
-
November 11th, 1999, 04:16 PM
#1
Running app in systray only
Does anyone know how to make a VB program run in the systray only?
-
November 11th, 1999, 11:34 PM
#2
Re: Running app in systray only
Set the Forms ShowInTaskBar Property to False then add this 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 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]
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
|