|
|
|
The API Declarations
We are going to need some Windows API's to be able to
add the icon to the tray area
and also we are going to use some Api's to draw a border on our controls
when it is in
the VB IDE environment. The GetClientRect API function will tell us the
rectangular space
occupied by our control and the DrawEdge API function will do the drawing of
the border
around our control. The Shell_NotifyIcon is the API Function responsible for
manipulating
the tray area, it can add, modify and delete icons to the tray area. If the
function can not succeed
the operation it returns the value Zero.
The declarations that we need ( API functions, Constants and one data Type
for the drawing functions):
Private Type RECT
Left
As Long
Top
As Long
Right
As Long
Bottom
As Long
End
Type
'Win32 API Function declarations
Private
Declare Function GetClientRect
Lib
"user32" (ByVal
hwnd
As Long,
lpRect
As
RECT)
As Long
Private
Declare Function DrawEdge
Lib
"user32" (ByVal
hdc
As Long,
qrc
As
RECT,
ByVal
edge
As Long,
ByVal
grfFlags
As Long)
As Long
Private
Const BDR_RAISED = &H5
Private
Const BF_BOTTOM = &H8
Private
Const BF_LEFT = &H1
Private
Const BF_RIGHT = &H4
Private
Const BF_TOP = &H2
Private
Const BF_RECT = (BF_LEFT
Or
BF_TOP
Or
BF_RIGHT
Or
BF_BOTTOM)
Private
Declare Function Shell_NotifyIcon
Lib
"shell32.dll"
Alias
_
"Shell_NotifyIconA" (ByVal
dwMessage
As Long,
lpData
As
_
NOTIFYICONDATA)
As Long
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 NIF_MESSAGE = &H1
Private
Const NIF_ICON = &H2
Private
Const NIF_TIP = &H4
'Make your own
constant, e.g.:
Private
Const NIF_DOALL = NIF_MESSAGE
Or
NIF_ICON
Or
NIF_TIP
Private
Const WM_MOUSEMOVE = &H200
Private
Const WM_LBUTTONDBLCLK = &H203
Private
Const WM_LBUTTONDOWN = &H201
Private
Const WM_RBUTTONDOWN = &H204
Private
Const WM_RBUTTONDBLCLK = &H206&
[ TrayControl ] [ Create Custom Interface Members ] [ The API Declarations ] [ Code Please! ] [ Let the drawing begin! ] [ The Control in use ]
|
|
|