怎样使VB程序最小化后,停在右边,即在输入法旁边。

polly_110 2003-11-08 01:40:03
问题如上,请给出详细的过程。我刚学VB。
...全文
44 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyr1978 2003-11-08
  • 打赏
  • 举报
回复
这叫做最小化到系统托盘,很多关于VB编程的网站都有源代码,找找看
射天狼 2003-11-08
  • 打赏
  • 举报
回复
Option Explicit

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

Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONUP = &H205
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIF_MESSAGE = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Const WM_MOUSEMOVE = &H200

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long

Dim TrayIcon As NOTIFYICONDATA, bolFlag As Boolean

Private Sub Form_Load()
TrayIcon.cbSize = Len(TrayIcon)
TrayIcon.hWnd = hWnd
TrayIcon.uId = vbNull
TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
TrayIcon.ucallbackMessage = WM_MOUSEMOVE
TrayIcon.hIcon = Me.Icon
TrayIcon.szTip = "拖盘" & Chr(0)

'在系统栏添加拖盘
Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'构造系统拖盘结构
TrayIcon.cbSize = Len(TrayIcon)
TrayIcon.hWnd = Me.hWnd
TrayIcon.uId = vbNull

'删除系统栏的拖盘
Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Dim Message As Long

Message = X / Screen.TwipsPerPixelX

'判断鼠标消息,执行不同的功能
Select Case Message
Case WM_LBUTTONDOWN
'点击拖盘
Case WM_RBUTTONUP
SetForegroundWindow Me.hWnd
'按右键弹出菜单
'PopupMenu mnuPopup
End Select
End Sub

Private Sub Timer1_Timer()
bolFlag = Not bolFlag

TrayIcon.cbSize = Len(TrayIcon)
TrayIcon.hWnd = hWnd
TrayIcon.uId = vbNull
TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
TrayIcon.ucallbackMessage = WM_MOUSEMOVE
TrayIcon.hIcon = IIf(bolFlag, Me.Icon, Picture1.Picture)
TrayIcon.szTip = "拖盘" & Chr(0)

'在系统栏添加拖盘
Call Shell_NotifyIcon(NIM_MODIFY, TrayIcon)
End Sub
polly_110 2003-11-08
  • 打赏
  • 举报
回复
最小化可以是自已做的“最小化”按钮。

7,768

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧