vb的托盘菜单问题
WEBQQ1.0.2下载地址:http://www.namipan.com/d/Web%20QQ.exe/90bee94a5028c0f5fa70ec808e269ad7...
WEB QQ 1.0.2
下载地址:http://www.namipan.com/d/Web%20QQ.exe/90bee94a5028c0f5fa70ec808e269ad7156fc2ee00600000
源代码:
Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
Const SW_RESTORE = 9
Const SW_HIDE = 0
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private nfIconData As NOTIFYICONDATA
Private Sub Form_Load()
Me.Width = 15360
Me.Height = 11100
WebBrowser1.Width = Me.Width - 100
WebBrowser1.Height = 10600
WebBrowser1.Left = 0
WebBrowser1.Top = 8
Me.Top = 0
Me.Left = 0
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "Web QQ" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
ShowWindow Me.hwnd, SW_HIDE
WebBrowser1.Navigate ("web.qq.com")
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = Form1.Caption & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
ShowWindow Me.hwnd, SW_HIDE
End If
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
If lMsg = WM_LBUTTONUP Then
Me.WindowState = 0
Me.Show
Else
If lMsg = WM_RBUTTONUP Then PopupMenu traymenu
End If
End Sub
Private Sub menuexit_Click()
Unload Me
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim NewWindow As Form1
Set NewWindow = New Form1
NewWindow.Show
Set ppDisp = NewWindow.WebBrowser1.Object
End Sub
Private Sub Form_Unload(Cancel As Integer)
Shell_NotifyIcon NIM_DELETE, nfIconData
End Sub
其中的
WebBrowser1.Top = 8
一定要大于或等于8
否则鼠标右键点托盘图标无法弹出菜单
我想可能是掩盖了本来菜单的位置所以无法弹出
有没有解决办法? 展开
下载地址:http://www.namipan.com/d/Web%20QQ.exe/90bee94a5028c0f5fa70ec808e269ad7156fc2ee00600000
源代码:
Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
Const SW_RESTORE = 9
Const SW_HIDE = 0
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private nfIconData As NOTIFYICONDATA
Private Sub Form_Load()
Me.Width = 15360
Me.Height = 11100
WebBrowser1.Width = Me.Width - 100
WebBrowser1.Height = 10600
WebBrowser1.Left = 0
WebBrowser1.Top = 8
Me.Top = 0
Me.Left = 0
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "Web QQ" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
ShowWindow Me.hwnd, SW_HIDE
WebBrowser1.Navigate ("web.qq.com")
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = Form1.Caption & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
ShowWindow Me.hwnd, SW_HIDE
End If
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
If lMsg = WM_LBUTTONUP Then
Me.WindowState = 0
Me.Show
Else
If lMsg = WM_RBUTTONUP Then PopupMenu traymenu
End If
End Sub
Private Sub menuexit_Click()
Unload Me
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim NewWindow As Form1
Set NewWindow = New Form1
NewWindow.Show
Set ppDisp = NewWindow.WebBrowser1.Object
End Sub
Private Sub Form_Unload(Cancel As Integer)
Shell_NotifyIcon NIM_DELETE, nfIconData
End Sub
其中的
WebBrowser1.Top = 8
一定要大于或等于8
否则鼠标右键点托盘图标无法弹出菜单
我想可能是掩盖了本来菜单的位置所以无法弹出
有没有解决办法? 展开
1个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询