|
-
Jan 22nd, 2000, 06:12 AM
#1
Thread Starter
Member
How can I make my application go in the system tray when the 'minimize button' is clicked?
What's the code to make it go in the System Tray?
-
Jan 22nd, 2000, 06:27 AM
#2
Registered User
Hey man...
In order to put your program in Win98's system tray, you need to use the Windows API.
Here is a piece of code that should help you:
Option Explicit
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 Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid _
As NOTIFYICONDATA) As Boolean
Dim t As NOTIFYICONDATA
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Timer1.Enabled = False
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
Shell_NotifyIcon NIM_DELETE, t
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Hex(X) = "1E3C" Then
Me.PopupMenu menu1
End If
End Sub
Private Sub Timer1_Timer()
Static i As Long, img As Long
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
t.uFlags = NIF_ICON
t.hIcon = Picture1.Picture
Shell_NotifyIcon NIM_MODIFY, t
Timer1.Enabled = True
i = i + 1
If i = 2 Then i = 0
End Sub
Private Sub Form_Load()
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
t.ucallbackMessage = WM_MOUSEMOVE
t.hIcon = Picture1.Picture
t.szTip = "System Tray" & Chr$(0)
Shell_NotifyIcon NIM_ADD, t
Timer1.Enabled = True
Me.Hide
App.TaskVisible = False
End Sub
------------------
------
God:
------
Oh...those israeli programmers..!
-
Jan 23rd, 2000, 03:26 AM
#3
Thread Starter
Member
I copied and pasted the code into my project and drew the necessary controls but it still didn't work. Gave some error about "t" not being a defined type or something.
-
Jan 23rd, 2000, 12:10 PM
#4
Thread Starter
Member
Thank you,
But why do you have a timer and a picture box in there?
[This message has been edited by madd indian (edited 01-23-2000).]
-
Jan 23rd, 2000, 12:12 PM
#5
Hyperactive Member
I think that the picture box hold the image that will be displyed in the System Tray?
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
|