Module Code
Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias _
"Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As _
NOTIFYICONDATA) As Long
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 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 = &H4Public Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIPPublic Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_RBUTTONDOWN = &H204
Form Code
Public Sub CreateIcon()
Dim Tic As NOTIFYICONDATA
Tic.cbSize = Len(Tic)
Tic.hwnd = Picture1.hwnd
Tic.uID = 1&
Tic.uFlags = NIF_DOALL
Tic.uCallbackMessage = WM_MOUSEMOVE
Tic.hIcon = Picture1.Picture
Tic.szTip = "Visual Basic Demo Project" & Chr$(0)
erg = Shell_NotifyIcon(NIM_ADD, Tic)
End Sub
Public Sub DeleteIcon()
Dim Tic As NOTIFYICONDATA
Tic.cbSize = Len(Tic)
Tic.hwnd = Picture1.hwnd
Tic.uID = 1&
erg = Shell_NotifyIcon(NIM_DELETE, Tic)
End Sub
Buat dua command buttons & picture box dan ubah property pada icon (select icon).
To to Click event of Command1, add the following code:
Private Sub Command1_Click()
CreateIcon
End Sub
Private Sub Command2_Click()
DeleteIcon
End Sub
Pada MouseMove event dari Picture1, ketikan kode berikut ini:
X = X / Screen.TwipsPerPixelX
Select Case X
Case WM_LBUTTONDOWN
Caption = "Left Click"
Case WM_RBUTTONDOWN
Caption = "Right Click"
Case WM_MOUSEMOVE
Caption = "Move"
Case WM_LBUTTONDBLCLK
Caption = "Double Click"
End Select
Langganan:
Posting Komentar
(
Atom
)
Tidak ada komentar :
Posting Komentar