那位大哥有空帮我看下代码可不可以优化下!
这个模块代码是托盘用的,可以用,但就是点击了以后不会自动关闭,有谁知道怎么让菜单在鼠标移开后会自动关闭呢?
代码加在哪里?易做图抽空指教下!
Option Explicit
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Const TRAY_CALLBACK = (&H400 + 1001&)
Public Const GWL_WNDPROC = -4
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206
Public Enum WIN_STATUS
STA_MIN
STA_NORMAL
End Enum
Public glWinRet As Long
Public OrgWinRet As Long
Public Status As WIN_STATUS
Public Function CallbackMsgs(ByVal wHwnd As Long, ByVal wMsg As Long, ByVal wp_id As Long, ByVal lp_id As Long) As Long
On Error Resume Next
If wMsg = TRAY_CALLBACK Then
With frmMain
Select Case CLng(lp_id)
Case WM_RBUTTONUP '右键
.PopupMenu .mnuTray, , , , .mnuShow
Case WM_LBUTTONUP '左键
If .WindowState = vbMinimized Then
Status = STA_NORMAL
.Visible = True
.WindowState = vbNormal
Else
Status = STA_MIN
.WindowState = vbMinimized
.Visible = False
End If
End Select
End With
End If
CallbackMsgs = CallWindowProc(glWinRet, wHwnd, wMsg, wp_id, lp_id)
End Function
啥意思啊。 托盘菜单在点开后,鼠标移开不会自动关闭!那位兄台知道a ? 难道没有人知道吗 有没有人知道啊!!!!! 期待高手出现吧
补充:VB , 网络编程