永发信息网

怎么写一VB程序可以把它缩到屏幕右下角的系统托盘呢?

答案:2  悬赏:80  手机版
解决时间 2021-08-11 05:42
  • 提问者网友:送舟行
  • 2021-08-10 17:25
跪求,我怎么也实现不了。
最佳答案
  • 五星知识达人网友:有你哪都是故乡
  • 2021-08-10 18:07

看看我这个可以实现不


这是FORM1的


VERSION 5.00
Begin VB.Form Form1
   Caption    =   "Form1"
   ClientHeight    =   3090
   ClientLeft    =   60
   ClientTop    =   450
   ClientWidth    =   4680
   LinkTopic    =   "Form1"
   ScaleHeight    =   3090
   ScaleWidth    =   4680
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.Label Label1
    Caption    =   "点击最小化按钮,即可最小化到托盘"
    Height    =   615
    Left    =   240
    TabIndex    =   0
    Top    =   600
    Width    =   3735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


'最小化到托盘(类似于QQ)


'说明:将Form1的ShowInTaskBar属性设置为False(此时已修改完毕)    图标放入方式正常


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
'定义鼠标移动到托盘上时显示的Tip
.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)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
'单击左键,显示窗体
ShowWindow Me.hWnd, SW_RESTORE
End Select
End Sub


这是module1的


Attribute VB_Name = "Module1"
Option Explicit
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
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 Const SW_RESTORE = 9
Public Const SW_HIDE = 0


Public nfIconData As NOTIFYICONDATA



Public 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


Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

全部回答
  • 1楼网友:洎扰庸人
  • 2021-08-10 19:27
下载个 托盘显示控件 吧,帮你轻松解决的!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯