PDA

Click to See Complete Forum and Search --> : Minimising to systray


Ell_holmes
Nov 9th, 1999, 09:21 PM
Hi All,

I've not been for a while, but now come seeking help and knowing you are all so wonderful, hope you can help me (Yes I am creeping!!)

I am in the middle of writing a fairly simple run-of-the-mill app to make my day easier, but When I minimize it, I want it to go into the Sys tray(The little thingy on the toolbar where the clock is - I think it's the systray anyway!). How can I do this? I'm sure it's been done before, but I can't find the code

TIA

Ell

barrie
Nov 9th, 1999, 10:05 PM
I think this article might give you some ideas:
http://www.vb-world.net/tips/tip61.html

Candou
Nov 9th, 1999, 10:07 PM
Check out the artical called: How to add an icon to the tray, on this site, which will add the icon to the taskbar tray. You will then need to hide your form and then transfer control to the little icon.

Aaron Young
Nov 9th, 1999, 10:19 PM
Like this:

Add an Invisible Picturebox to your 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 WM_MOUSEMOVE = &H200

Private tTrayIcon As NOTIFYICONDATA

Private Sub Form_Load()
With tTrayIcon
.hIcon = Icon
.hwnd = Picture1.hwnd
.szTip = Caption & Chr(0)
.uCallbackMessage = WM_MOUSEMOVE
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uID = 1
.cbSize = Len(tTrayIcon)
End With
End Sub

Private Sub Form_Resize()
If WindowState = vbMinimized Then
Hide
Shell_NotifyIcon NIM_ADD, tTrayIcon
End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Right(Hex(X), 1) = "D" Then
WindowState = vbNormal
Show
Shell_NotifyIcon NIM_DELETE, tTrayIcon
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-10-1999).]

Ell_holmes
Nov 9th, 1999, 10:26 PM
Thank you both very much, This should do the trick!!

Ell