Postup:
-
Do sekce (general) do
deklaracφ vlo₧te nßsledujφcφ deklarace:
'Typ pot°ebn² pro
API funkci
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
'Konstanty
pro API funkci
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 Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
'Deklarace
API funkce
Private Declare
Function Shell_NotifyIcon Lib "shell32" Alias
"Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As
NOTIFYICONDATA) As Boolean
'Ka₧dß
deklarace musφ b²t na samostatnΘm °ßdku
'Definice prom∞nnΘ
Dim t As
NOTIFYICONDATA
- Ve formulß°i definujte
menu, kterΘ se bude jmenovat mnuBar a jeho submenu s nadpisem Konec a
jmΘnem mnuBar_Quit
- Na udßlost mnuBar_Quit_Click
vlo₧te p°φkaz Unload Me
- Do formulß°e p°ipojte
prvek PictureBox, kter² pojmenujte PicHook.
- Formulß°i specifikujte
ikonu, kterß se b∞₧n∞ zobrazuje v titulku okna.
-
Na udßlost Load formulß°e
vlo₧te nßsledujφcφ k≤d:
Private Sub
Form_Load()
t.cbSize = Len(t)
t.hWnd = pichook.hWnd
t.uId = 1&
t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
t.ucallbackMessage = WM_MOUSEMOVE
t.hIcon = Me.Icon
t.szTip = "Ukßzka ikony v systΘmovΘm °ßdku ..." & Chr$(0)
Shell_NotifyIcon NIM_ADD, t
Me.Hide
App.TaskVisible = False
End Sub
-
Na udßlost QueryUnload
p°ipojte nßsledujφcφ k≤d:
Private Sub
Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
t.cbSize = Len(t)
t.hWnd = pichook.hWnd
t.uId = 1&
Shell_NotifyIcon NIM_DELETE, t
End Sub
-
Na udßlost MouseMove
prvku PicHook vlo₧te nßsledujφcφ k≤d:
Private Sub
pichook_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
Static rec As Boolean, msg As Long
msg = X / Screen.TwipsPerPixelX
If rec = False Then
rec = True
Select Case msg
Case
WM_LBUTTONDBLCLK:
MsgBox "Double click !"
Case
WM_LBUTTONDOWN:
Case
WM_LBUTTONUP:
Case WM_RBUTTONDBLCLK:
Case
WM_RBUTTONDOWN:
Case
WM_RBUTTONUP:
Me.PopupMenu mnuBar
End Select
rec = False
End If
End Sub
- Spus¥te aplikaci.
Klepnutφ na ikonu v systΘmovΘm °ßdku prav²m tlaΦφtkem myÜi
vyvolß menu
|