发现二义性的名称,怎么解决?
程序代码:
Option Explicit '主窗体源码 Private Sub Form_Load() TrayAddIcon Form1, "测试" Dim lRet As Long, lParam As Long lRet = EnumChildWindows(Me.hwnd, AddressOf EnumChildProc, lParam) If FHW <> 0 Then glPrevWndProc = SubClass() End If End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If FHW <> 0 Then UnSubClass End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim lMsg As Single lMsg = X / Screen.TwipsPerPixelX Select Case lMsg Case WM_LBUTTONUP If Me.WindowState = 1 Then Me.WindowState = 0 Me.show Else Me.WindowState = 1 Me.hide End If Case WM_RBUTTONUP '发现二义性的名称,来自这一句怎么解决, SetForegroundWindow Me.hwnd Me.PopupMenu Tmenue End Select End Sub Private Sub Form_Unload(Cancel As Integer) TrayRemoveIcon End Sub Private Sub hide_Click() Me.WindowState = 1 Me.hide End Sub Private Sub show_Click() Me.WindowState = 0 Me.show End Sub 'Flash右击模块 Option Explicit Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Public glPrevWndProc As Long Public FHW As Long Public Const GWL_WNDPROC = (-4) 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 Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Const WM_KEYDOWN = &H100 Public Const WM_RBUTTONDBLCLK = &H206 Public Const WM_RBUTTONDOWN = &H204 Public Const WM_RBUTTONUP = &H205 Function EnumChildProc(ByVal lhWnd As Long, ByVal lParam As Long) As Long Dim RetVal As Long Dim WinClassBuf As String * 255 Dim WinClass As String RetVal = GetClassName(lhWnd, WinClassBuf, 255) If (InStr(WinClassBuf, Chr(0)) > 0) Then WinClass = Left(WinClassBuf, InStr(WinClassBuf, Chr(0)) - 1) End If If WinClass = "MacromediaFlashPlayerActiveX" Then FHW = lhWnd EnumChildProc = False ElseIf Left(WinClass, 4) = "ATL:" Then FHW = lhWnd EnumChildProc = False Else EnumChildProc = True End If End Function Public Sub UnSubClass() Call SetWindowLong(FHW, GWL_WNDPROC, glPrevWndProc) FHW = 0 End Sub Public Function MyWindowProc(ByVal HW As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If uMsg = WM_RBUTTONDOWN Then Exit Function ElseIf uMsg = WM_RBUTTONUP Then Form1.PopupMenu Form1.mnuPop Exit Function ElseIf uMsg = WM_KEYDOWN Then End If MyWindowProc = CallWindowProc(glPrevWndProc, HW, uMsg, wParam, lParam) End Function Public Function SubClass() As Long SubClass = SetWindowLong(FHW, GWL_WNDPROC, AddressOf MyWindowProc) End Function '系统托盘 Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long Public Declare Function WSAStartup Lib "wsock32" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long Public Declare Function WSACleanup Lib "wsock32" () As Long Public Declare Function IcmpCreateFile Lib "icmp.dll" () As Long Public Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As Long Public Declare Function IcmpSendEcho Lib "icmp.dll" (ByVal IcmpHandle As Long, ByVal DestinationAddress As Long, ByVal RequestData As String, ByVal RequestSize As Long, ByVal RequestOptions As Long, ReplyBuffer As ICMP_ECHO_REPLY, ByVal ReplySize As Long, ByVal Timeout As Long) As Long Public Const NIF_MESSAGE = &H1 Public Const NIF_ICON = &H2 Public Const NIF_TIP = &H4 Public Const NIF_STATE = &H8 Public Const NIF_INFO = &H10 Public Const NIM_ADD = &H0 Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const NIM_SETFOCUS = &H3 Public Const NIM_SETVERSION = &H4 Public Const NIM_VERSION = &H5 Public Const WM_USER As Long = &H400 Public Const NIN_BALLOONSHOW = (WM_USER + 2) Public Const NIN_BALLOONHIDE = (WM_USER + 3) Public Const NIN_BALLOONTIMEOUT = (WM_USER + 4) Public Const NIN_BALLOONUSERCLICK = (WM_USER + 5) Public Const NOTIFYICON_VERSION = 3 Public Const NIS_HIDDEN = &H1 Public Const NIS_SHAREDICON = &H2 Public Const WM_NOTIFY As Long = &H4E Public Const WM_COMMAND As Long = &H111 Public Const WM_CLOSE As Long = &H10 Public Const WM_MOUSEMOVE As Long = &H200 Public Const WM_LBUTTONDOWN As Long = &H201 Public Const WM_LBUTTONUP As Long = &H202 Public Const WM_LBUTTONDBLCLK As Long = &H203 Public Const WM_MBUTTONDOWN As Long = &H207 Public Const WM_MBUTTONUP As Long = &H208 Public Const WM_MBUTTONDBLCLK As Long = &H209 Public Const WM_RBUTTONDOWN As Long = &H204 Public Const WM_RBUTTONUP As Long = &H205 Public Const WM_RBUTTONDBLCLK As Long = &H206 Public Const WS_VERSION_REQD As Long = &H101 Public Const MIN_SOCKETS_REQD As Long = 1 Public Const SOCKET_ERROR As Long = -1 Public Const INADDR_NONE As Long = &HFFFFFFFF Public Const MAX_WSADescription As Long = 256 Public Const MAX_WSASYSStatus As Long = 128 Public Enum bFlag NIIF_NONE = &H0 NIIF_INFO = &H1 NIIF_WARNING = &H2 NIIF_ERROR = &H3 NIIF_GUID = &H5 NIIF_ICON_MASK = &HF NIIF_NOSOUND = &H10 '关闭提示音标志 End Enum Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 128 dwState As Long dwStateMask As Long szInfo As String * 256 uTimeoutAndVersion As Long szInfoTitle As String * 64 dwInfoFlags As Long End Type '鼠标事件 Public Enum TrayRetunEventEnum MouseMove = &H200 LeftUp = &H202 LeftDown = &H201 LeftDbClick = &H203 RightUp = &H205 RightDown = &H204 RightDbClick = &H206 MiddleUp = &H208 MiddleDown = &H207 MiddleDbClick = &H209 BalloonClick = (WM_USER + 5) End Enum Public Type WSADATA wVersion As Integer wHighVersion As Integer szDescription(0 To MAX_WSADescription) As Byte szSystemStatus(0 To MAX_WSASYSStatus) As Byte wMaxSockets As Long wMaxUDPDG As Long dwVendorInfo As Long End Type Public Type ICMP_OPTIONS Ttl As Byte Tos As Byte Flags As Byte OptionsSize As Byte OptionsData As Long End Type Public Type ICMP_ECHO_REPLY Address As Long status As Long RoundTripTime As Long DataSize As Long DataPointer As Long Options As ICMP_OPTIONS Data As String * 250 End Type Public Tb As NOTIFYICONDATA Public Sub TrayAddIcon(ByVal MyForm As Form, ByVal ToolTip As String, Optional ByVal bFlag As bFlag) With Tb .uCallbackMessage = WM_MOUSEMOVE '512 'WM_MOUSEMOVE .hwnd = Form1.hwnd .hIcon = Form1.Icon .szTip = ToolTip & vbNullChar .uID = vbNull .cbSize = Len(Tb) .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE End With TuoPanXianShi = True Call Shell_NotifyIcon(NIM_ADD, Tb) End Sub Public Sub TrayRemoveIcon() Shell_NotifyIcon NIM_DELETE, Tb TuoPanXianShi = False End Sub Public Sub TrayBalloon(ByVal MyForm As Form, ByVal sBaloonText As String, sBallonTitle As String, Optional ByVal bFlag As bFlag) With Tb .cbSize = Len(Tb) .hwnd = ZForm.hwnd .uID = vbNull .uFlags = NIF_INFO .dwInfoFlags = bFlag '.uTimeoutAndVersion =5 .szInfoTitle = sBallonTitle & vbNullChar .szInfo = sBaloonText & vbNullChar End With Shell_NotifyIcon NIM_MODIFY, Tb End Sub Public Sub TrayTip(ByVal MyForm As Form, ByVal sTipText As String) With Tb .cbSize = Len(Tb) .hwnd = MyForm.hwnd .uID = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .szTip = sTipText & vbNullChar End With Shell_NotifyIcon NIM_MODIFY, Tb End Sub
[ 本帖最后由 ymhy12345 于 2012-9-11 19:41 编辑 ]