VB,托盘图标,事件(窗口进入托盘图标后,点击图标打开窗口,这个事件怎么写?)
窗口最小化后,不知道怎么写:..点击托盘图标这个事件代码该怎么写呢?"点击托盘图标后,打开窗口!"如何实现双击托盘图标,打开窗口??...
窗口最小化后,不知道怎么写:..点击托盘图标
这个事件代码该怎么写呢?"点击托盘图标后,打开窗口!"
如何实现双击托盘图标,打开窗口?? 展开
这个事件代码该怎么写呢?"点击托盘图标后,打开窗口!"
如何实现双击托盘图标,打开窗口?? 展开
2个回答
展开全部
Private Sub Form_Load()
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = App.Title + "(版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static Message As Long
Static RR As Boolean
Message = X / Screen.TwipsPerPixelX
If RR = False Then
RR = True
Select Case Message
Case WM_LBUTTONUP
Me.Show
Me.WindowState = 0
Case WM_RBUTTONUP
Me.PopupMenu m '见注释
End Select
RR = False
End If
End Sub
'注释,m为右击鼠标时出现的菜单,可以用菜单编辑器根据你需要编,如果你想在双击图标时才显示窗口,可改为:
Case WM_LBUTTONDBLCLK
Me.Show
Me.WindowState = 0
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = App.Title + "(版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static Message As Long
Static RR As Boolean
Message = X / Screen.TwipsPerPixelX
If RR = False Then
RR = True
Select Case Message
Case WM_LBUTTONUP
Me.Show
Me.WindowState = 0
Case WM_RBUTTONUP
Me.PopupMenu m '见注释
End Select
RR = False
End If
End Sub
'注释,m为右击鼠标时出现的菜单,可以用菜单编辑器根据你需要编,如果你想在双击图标时才显示窗口,可改为:
Case WM_LBUTTONDBLCLK
Me.Show
Me.WindowState = 0
展开全部
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'气泡单击时的鼠标事件
Dim Result As Long
Dim cEvent As Single
cEvent = X / Screen.TwipsPerPixelX
Select Case cEvent
Case &H201'"左键按下"
Form1.WindowState = 0
Form1.Show
end select
end sub
'气泡单击时的鼠标事件
Dim Result As Long
Dim cEvent As Single
cEvent = X / Screen.TwipsPerPixelX
Select Case cEvent
Case &H201'"左键按下"
Form1.WindowState = 0
Form1.Show
end select
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询