1
Option Explicit
Private Const MAX_TOOLTIP As Integer = 64
Private Const NIF_ICON = &H2 '删除图标
Private Const NIF_MESSAGE = &H1
Private Const NIM_ADD = &H0 '添加图标到任务栏提示区
Private Const NIM_MODIFY = &H1 '修改系统状态栏中的图标
Private Const NIM_DELETE = &H2 '删除系统状态栏中的图标
Private Const NIF_TIP = &H4
Private Const WM_USER = &H400
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
Private Const SW_RESTORE = 9
Private Const SW_HIDE = 0
Private Const TRAY_CALLBACK = (WM_USER + 1001&)
Private Const GWL_WNDPROC = (-4)
Private Const GWL_USERDATA = (-21)
Private Type NOTIFYICONDATA
cbSize As Long '需填入NOTIFYICONDATA数据结构的长度
hwnd As Long '设置成窗口的句柄
uID As Long '为图标所设置的ID值
uFlags As Long '设置uCallbackMessage,hIcon,szTip是否有效
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 "shell32dll" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'返回值 Long,非零表示成功,零表示失败
Private nfIconData As NOTIFYICONDATA
'添加托盘图标,并隐藏窗体
Private Sub Command1_Click()
nfIconDatahwnd = Mehwnd
nfIconDatauID = MeIcon
nfIconDatauFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nfIconDatauCallbackMessage = WM_MOUSEMOVE
nfIconDatahIcon = MeIconHandle
nfIconDataszTip = "System Tray Example" & vbNullChar
nfIconDatacbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
MeHide
End Sub
'在托盘图标上点击
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / ScreenTwipsPerPixelX
If lMsg = WM_RBUTTONUP Or lMsg = WM_LBUTTONUP Then MePopupMenu mnusys
End Sub
(具体细节自己想了)
2
???
3
'使用Form_Unload事件来实现,也可以通过API捕获这个事件
'点击系统自带的关闭按钮后出现两个选择
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("确定退出?", vbYesNo, "提示") = vbNo Then Cancel = 1
End Sub
'如果要像QQ那样,不退出就隐藏到托盘区,可以结合上面(1)的代码
4
Private Sub cmdGeneral_Click()
FrmAboutShow '这个语句就能实现了
End Sub
5
这个用控件数组来做就很简单了
在设计时添加上控件数组Command1(0、1、2、3、4、5、6),Frame1(0、1、2、3、4、5、6),设定Frame1(0、1、2、3、4、5、6)的Visible属性为False
Private Sub Command1_Click(Index As Integer)
Frame1(Index)Visible = True '显示出Frame1(Index)控件来
Frame1(Index)ZOrder 0 '使Frame1(Index)置于其他控件之上
End Sub
'刚才我用自己的程序将QQ窗口隐藏了,句柄在,还能够重显方法如下:
'第一步,获取 *** 作窗口的句柄,(非问不述)
'调用api函数
setwindowpos
隐藏目标窗口
Public
Declare
Function
SetWindowPos
Lib
"user32"
(ByVal
hwnd
As
Long,
ByVal
hWndInsertAfter
As
Long,
ByVal
x
As
Long,
ByVal
y
As
Long,
ByVal
cx
As
Long,
ByVal
cy
As
Long,
ByVal
wFlags
As
Long)
As
Long
SetWindowPos
lngWindow,
-1,
0,
0,
0,
0,
&H80
'隐藏,注意-1表示顶层,但隐藏了,所以怎么设都没关系
SetWindowPos
lngWindow,
-1,
0,
0,
0,
0,
&H40
'就可以显示了
'注这只是隐藏指定窗口,而不能达到隐藏进程的目的
以上就是关于还是vb的问题。 1 那个程序我知道如何隐藏窗体,但是如何隐藏到托盘并显示我的图标全部的内容,包括:还是vb的问题。 1 那个程序我知道如何隐藏窗体,但是如何隐藏到托盘并显示我的图标、vb隐藏窗口、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)