还是vb的问题。 1 那个程序我知道如何隐藏窗体,但是如何隐藏到托盘并显示我的图标?
2我已经在主窗体有了一些别的代码,怎么办?3我想点击系统自带的关闭按钮后出现两个选择,就像qq的主程序关闭一样4如何让点击一个按钮(如cmdGeneral)后就打开一个我...
2 我已经在主窗体有了一些别的代码,怎么办?
3 我想点击系统自带的关闭按钮后出现两个选择,就像qq的主程序关闭一样
4 如何让点击一个按钮(如cmdGeneral)后就打开一个我设计的窗体(如FrmAbout)我要写使用帮助
5 如何让我点击一个按钮后就在本窗体打开一个控件(如 Frame7)只要Frame7在窗体上,我就可以点击这个按钮使他显示出来,无论有多少个控件挡住了它还是这样。并且,在程序一开始运行时,控件不会显示出来,只有当点击按钮时,它才会出现。 (第一个按钮名:cmdGeneral,控件名:Frame1:;第二个按钮名Command1,控件名Frame2;除第一个外,名称后数字以此类推,一共6个,不含第一个)
【一定要写问题序号】 展开
3 我想点击系统自带的关闭按钮后出现两个选择,就像qq的主程序关闭一样
4 如何让点击一个按钮(如cmdGeneral)后就打开一个我设计的窗体(如FrmAbout)我要写使用帮助
5 如何让我点击一个按钮后就在本窗体打开一个控件(如 Frame7)只要Frame7在窗体上,我就可以点击这个按钮使他显示出来,无论有多少个控件挡住了它还是这样。并且,在程序一开始运行时,控件不会显示出来,只有当点击按钮时,它才会出现。 (第一个按钮名:cmdGeneral,控件名:Frame1:;第二个按钮名Command1,控件名Frame2;除第一个外,名称后数字以此类推,一共6个,不含第一个)
【一定要写问题序号】 展开
1个回答
展开全部
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 "shell32.dll" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'返回值 Long,非零表示成功,零表示失败
Private nfIconData As NOTIFYICONDATA
'添加托盘图标,并隐藏窗体
Private Sub Command1_Click()
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 = "System Tray Example" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide
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_RBUTTONUP Or lMsg = WM_LBUTTONUP Then Me.PopupMenu 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()
FrmAbout.Show '这个语句就能实现了...
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
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 "shell32.dll" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
'返回值 Long,非零表示成功,零表示失败
Private nfIconData As NOTIFYICONDATA
'添加托盘图标,并隐藏窗体
Private Sub Command1_Click()
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 = "System Tray Example" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide
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_RBUTTONUP Or lMsg = WM_LBUTTONUP Then Me.PopupMenu 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()
FrmAbout.Show '这个语句就能实现了...
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询