|
-
Sep 11th, 2006, 09:54 AM
#1
Thread Starter
Hyperactive Member
Load into tray
Hi there,
Thanks to this beautiful forum I have this for SyStray:
VB Code:
Option Explicit
'// FORM
Private Sub Form_Load()
mTray.Refresh Me ' TRAY ICON LOAD
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
mTray.Click Me, X ' TRAY ICON CLICK
End Sub
Private Sub Form_Resize()
mTray.Resize Me ' TRAY ICON SHOW/HIDE
End Sub
Private Sub Form_Unload(Cancel As Integer)
mTray.Destroy ' TRAY ICON CLOSE
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
And this in a module
VB Code:
Option Explicit
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
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
Public nid As NOTIFYICONDATA
Private FX As Single
Private FY As Single
Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Const WM_LBUTTONDBLCLK = &H203
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_RBUTTONDBLCLK = &H206
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Public Sub Refresh(ByVal frm As Form)
FX = frm.Width
FY = frm.Height
nid.cbSize = Len(nid)
nid.hwnd = frm.hwnd
nid.uId = vbNull
nid.uflags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = frm.Icon
nid.szTip = App.Title & vbNullChar
Call Shell_NotifyIcon(NIM_ADD, nid)
End Sub
Public Sub Click(ByVal frm As Form, ByVal X As Single)
Dim Msg As Long
Dim sFilter As String
Msg = X / Screen.TwipsPerPixelX
Select Case Msg
Case WM_LBUTTONDOWN
frm.WindowState = 0
frm.Show
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select
End Sub
Public Sub Resize(ByVal frm As Form)
If frm.WindowState = 1 Then
frm.Hide
frm.WindowState = 0
ElseIf frm.WindowState = 0 Then
frm.Show
frm.Width = FX
frm.Height = FY
End If
End Sub
Public Sub Destroy()
Call Shell_NotifyIcon(NIM_DELETE, nid)
End Sub
Now I want, that if i run the program, that the Form1 WONT be visible but will be visible if I hit it in the Tray Icon?
So that it runs into tray, and you can 'open' it from tray..
How to?
-
Sep 11th, 2006, 10:03 AM
#2
Re: Load into tray
Delete what you have in Form_Load and Form_Resize and try this:
VB Code:
Private Sub Form_Load()
Me.WindowState = 1
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
mTray.Refresh Me
Else
mTray.Destroy
End If
End Sub
Now the icon appears in tray only when you minimize the window, and if you click on it, window is restored, and icon dissapeares - that's just my idea about the tray icon
Last edited by gavio; Sep 11th, 2006 at 10:06 AM.
-
Sep 11th, 2006, 10:04 AM
#3
Thread Starter
Hyperactive Member
Re: Load into tray
Thnx, but I had a another idea...
I want, if I hit myapp.exe that u wont see any form, but only a icon into tray
And if u hit that, then it will 'show' form1... :]
-
Sep 11th, 2006, 10:07 AM
#4
Re: Load into tray
Yes, just edited my previous post Didn't read it carefully before. Basic idea is that the startup form must be minimized at startup. You can do that at design time by seting it's WindowState property to 1, or at runtime, as explained in my previous post.
-
Sep 11th, 2006, 10:17 AM
#5
Thread Starter
Hyperactive Member
Re: Load into tray
ok, that works.
I thank you :]:]:]
-
Sep 11th, 2006, 10:19 AM
#6
Re: Load into tray
 Originally Posted by Account
ok, that works.
I thank you :]:]:]
No prob
-
Sep 11th, 2006, 10:27 AM
#7
Thread Starter
Hyperactive Member
Re: Load into tray
lol, now I have a little other problem.
I want it isnt in the task bar?
[like maps, programs...]
only into the tray
So if i start my comp, and it loads my program[already fixed that] I want ONLY see it in tray[like time] and not in the taskbar...
-
Sep 11th, 2006, 10:29 AM
#8
Fanatic Member
Re: Load into tray
did you set the form property for show in taksbar?
Good Luck!
-
Sep 11th, 2006, 10:31 AM
#9
Thread Starter
Hyperactive Member
Re: Load into tray
lol, no didnt do that.
But Now I have, thank you :]
-
Sep 11th, 2006, 10:31 AM
#10
Re: Load into tray
Set ShowInTaskbar=False (on a Form). But i think that the code already works that way.
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
|