Private Sub Form_Load()
With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = "Console" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub
---------
Private Sub mnuShow_Click()
form1.Show
mnuShow.Enabled = False
mnuHide.Enabled = True
End Sub
Private Sub mnuHide_Click()
form1.Hide
mnuHide.Enabled = False
mnuShow.Enabled = True
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
---------
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Result, Action As Long
If Me.ScaleMode = vbPixels Then
Action = X
Else
Action = X / Screen.TwipsPerPixelX
End If
Select Case Action
Case WM_LBUTTONUP
Result = SetForegroundWindow(Me.hwnd)
PopupMenu mnuFile
Case WM_RBUTTONUP
Result = SetForegroundWindow(Me.hwnd)
PopupMenu mnuFile
End Select
End Sub
----------------------------------------------***---------------------------------------------------------
For Modules Modules
_______________________________________________________________________
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 = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
No comments:
Post a Comment