vb窗体最小化问题

PrivateSubForm_Load()WebBrowser1.Navigate"www.xxxx.cn/login.asp"EndSubPrivateSubTimer... Private Sub Form_Load()
WebBrowser1.Navigate "www.xxxx.cn/login.asp"
End Sub

Private Sub Timer1_Timer()
Me.Caption = WebBrowser1.LocationName
If InStr(Me.Caption, "管理端") > 0 Then
Form1.Width = 13590
Form1.Height = 8400
Dim oldwidth, oldheight
WebBrowser1.Width = 13590
WebBrowser1.Height = 8400
WebBrowser1.ToolBar = 0
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2
Timer1.Enabled = False
End If
End Sub
'-----------------------窗体中--------------------------
Dim WindowTop, WindowLeft
Function WindowStyle()
'以下把程序放入System Tray====================================System Tray Begin
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 = "已最小化到托盘" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
'=============================================================System Tray End
Me.Hide
End Function

Private Sub Form_Resize()
WindowTop = Me.Top
WindowLeft = Me.Left
If Me.WindowState = 1 Then
WindowStyle
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
Select Case lMsg
Case WM_LBUTTONDBLCLK '双击左键显示窗体,要改成其他的看模块里的定义
ShowWindow Me.hWnd, SW_RESTORE
Me.Top = WindowTop
Me.Left = WindowLeft
'Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
Me.SetFocus
Case WM_RBUTTONUP '在托盘图标上点右键显示菜单
PopupMenu F00 '菜单名称为F00,做菜单时你可以改成别的,这里也得改成相应的
End Select
End Sub

Private Sub F01_Click()
ShowWindow Me.hWnd, SW_RESTORE
Me.Top = WindowTop
Me.Left = WindowLeft
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub

Private Sub F02_Click()
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'退出程序时删除托盘图标
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub
我要的效果是从窗体登陆后,点击最小化按钮,让窗体最小化到系统托盘,可是现在的却只能点开的时候最小化可以,然后也可以恢复,当登陆后就只能最小化到系统托盘,却不能回复窗口。
希望高手帮忙...
展开
 我来答
lightwindxu
2009-07-31 · TA获得超过647个赞
知道小有建树答主
回答量:287
采纳率:66%
帮助的人:219万
展开全部
问题描述不清楚。
不过这段代码是错的,你在网上搜索的吧。

用这个试试:

'------------------------------最小化系统托盘,双击复原-------start---------------------
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDBLCLK = &H203

Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Dim tray As NOTIFYICONDATA

'装一个按钮,叫CommandButton,点击产生最小化事件
Private Sub CommandButton_Click()
tray.cbSize = Len(tray)
tray.uId = vbNull
tray.hWnd = Me.hWnd
tray.uFlags = NIF_TIP Or NIF_MESSAGE Or NIF_ICON
tray.uCallBackMessage = WM_MOUSEMOVE
tray.hIcon = Me.Icon
tray.szTip = "你的程序名称" & vbNullChar
Shell_NotifyIcon NIM_ADD, tray
Me.Hide
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Msg As Long
Msg = X / 15
If Msg = WM_LBUTTONDBLCLK Then
Me.Show
Shell_NotifyIcon NIM_DELETE, tray
End If
End Sub
'------------------------------最小化系统托盘,双击复原-------end---------------------
乌孙信凤溪
2020-02-05 · TA获得超过3.7万个赞
知道大有可为答主
回答量:1.4万
采纳率:34%
帮助的人:920万
展开全部
窗体属性设置的问题,很简单.
窗体的属性设置里有一个
ShowInTaskbar,用于决定一个窗体是否在任务栏上显示,你把Form2的ShowInTaskbar设为True就可以了.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式