-
Notifications
You must be signed in to change notification settings - Fork 1
/
mdlMinToTray.bas
55 lines (45 loc) · 1.58 KB
/
mdlMinToTray.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Attribute VB_Name = "mdlMinToTray"
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 Type TrayTrack
UserHoverInTray As Boolean
EntryXY As CursorState
End Type
'constants required by Shell_NotifyIcon API call:
Public Const NIM_Add = &H0
Public Const NIM_Modify = &H1
Public Const NIM_Delete = &H2
Public Const NIF_Message = &H1
Public Const NIF_Icon = &H2
Public Const NIF_Tip = &H4
Public Const WM_Mousemove = &H200 'Mouse Move
Public Const WM_LButtonDown = &H201 'Button down
Public Const WM_LButtonUp = &H202 'Button up
Public Const WM_LButtonDblClk = &H203 'Double-click
Public Const WM_RButtonDown = &H204 'Button down
Public Const WM_RButtonUp = &H205 'Button up
Public Const WM_RButtonDblClk = &H206 'Double-click
Public nid As NotifyIconData
Public IsWindowInTray As Integer
Public TrayMotion As TrayTrack
Public Function MinimizeToTray(ThisForm As Form) As Integer
ThisForm.Hide
nid.cbSize = Len(nid)
nid.hWnd = ThisForm.hWnd
nid.uId = vbNull
nid.uFlags = NIF_Icon Or NIF_Tip Or NIF_Message
nid.uCallBackMessage = WM_Mousemove
nid.hIcon = ThisForm.Icon ' the icon will be your thisform project icon
nid.szTip = "Project Timers. Click to restore" & vbNullChar
Shell_NotifyIcon NIM_Add, nid
MinimizeToTray = 1
End Function