只要动态改变托盘图标就可以了。
比如你用VB光盘里的SYSTRAY控件的话可以这样子Set cTray.TrayIcon=Image1.Picture可以用Timer控件来控制
比如你用VB光盘里的SYSTRAY控件的话可以这样子Set cTray.TrayIcon=Image1.Picture可以用Timer控件来控制
解决方案 »
- 关于宾馆客房信息管理的设计与实现的问题
- 如何用VB将日期分成几列?
- 关于VB加载TSZP.dll的问题, 系统目录下有TSZP.dll,但程序运行时提示没有找到动态库,若把TSZP.dll拷到程序目录下又可以了,但根据加载顺序应该不是这样的
- 怎样解决串口通迅时CPU占用高的问题
- 我是初学者,请问怎样在Form中添加一个属性页啊?~
- 如何判断机器处于锁定状态(急!!!!在线等~~)
- vb 调用WebService时,返回值是自定义类,请问怎样用呢
- 如何读取已经用 Picture1.Print 方法 在Picture1上某个矩形区域内的文字?
- Dim fso As New FileSystemObject为什么出错?
- Toolbar中的ButtonMenu在click后,可否象menu一样设置其checked属性,在前边打个勾
- 请问如何读到当前工程文件的最后修改日期?
- 如何实现“撤消”(Undo)功能?
2 QQ窗体的收缩隐藏是如何做到
都可用 Timer 控件.
timer控件捕捉 MouseExit 事件
'声明
Public Declare Function GetCursorPos Lib "user32" (lpPoint As _pointapi) As Long
Type pointapi
x As Long
y As Long
End Type
'过程
Private Sub Timer1_Timer()
Dim a As Long
a = GetCursorPos(mouse)
If (mouse.x > frmMain.ScaleWidth) Or (mouse.y > _frmMain.ScaleHeight ) Then
frmMain.Top = (0 - frmMain.Height) + 100
End If
If mouse.y < 30 Then
frmMain.Top = 10 '理论上为0End If
End Sub
注意:form1.scalemode设置为2
当MOUSE指向窗体时,它自动将高度height 变为正常的,当MOUSE离开窗体是再将
高度height 变成一个很小的值,我想不能是0
而且支持停靠。
注意:tmrMousePos的触发属性设置为1。反正能小就小,呵呵Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim MousePos As POINTAPI
Const FLAT_TOP = 1
Const FLAT_BOTTOM = 2
Const FLAT_LEFT = 4
Const FLAT_RIGHT = 8
Dim FlatFlag As IntegerPublic Function PtInRect(r As RECT, pt As POINTAPI) As Boolean
If r.Left <= pt.X And pt.X <= r.Right And r.Top <= pt.Y And pt.Y < r.Bottom Then PtInRect = True Else PtInRect = False
End FunctionPublic Sub CursorPosTimer()
Dim r As RECT
Dim lRight As Long
Dim ir As Boolean
GetWindowRect Me.hwnd, r
ir = PtInRect(r, MousePos)
If (FlatFlag And FLAT_LEFT) = FLAT_LEFT Then
If MousePos.X <= 2 And ir Then
Me.Left = 0
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
If Me.Left = 0 And Not ir Then
Me.Left = -Me.Width + 2 * Screen.TwipsPerPixelX
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End If
End If
lRight = Screen.Width / Screen.TwipsPerPixelX - Me.Width / Screen.TwipsPerPixelX
If (FlatFlag And FLAT_RIGHT) = FLAT_RIGHT Then
If MousePos.X >= lRight - 2 And ir Then
Me.Left = lRight * Screen.TwipsPerPixelX
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
If Me.Left = lRight * Screen.TwipsPerPixelX And Not ir Then
Me.Left = Screen.Width - 2 * Screen.TwipsPerPixelX
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End If
End If If (FlatFlag And FLAT_TOP) = FLAT_TOP Then
If MousePos.Y <= 2 And ir Then
Me.Top = 0
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
If Me.Top = 0 And Not ir Then
Me.Top = -Me.Height + 2 * Screen.TwipsPerPixelY
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End If
End If
End SubPrivate Sub tmrMousePos_Timer()
GetCursorPos MousePos
CursorPosTimer
End Sub
shell_notifyicon(nim_modify,@ddd);
行了,给分吧