essage HWnd, WM_SYSCOMMAND, _
SC_MOVE, 0&
End Sub
''托盘图标右键菜单上的“恢复”项被点击时
Private Sub mnuTrayRestore_Click()
SendMessage HWnd, WM_SYSCOMMAND, _
SC_RESTORE, 0&
End Sub
''托盘图标右键菜单上的“退出”项被点击时
Private Sub mnuTraySize_Click()
SendMessage HWnd, WM_SYSCOMMAND, _
SC_SIZE, 0&
End Sub
''-----------------------------------------
''以下为模块中的代码:
''-----------------------------------------
Option Explicit
Public OldWindowProc As Long
Public TheForm As Form
Public TheMenu As Menu
''【VB声明】
''Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal HWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
''【说明】
'' 此函数发送消息到一个窗口过程
''【返回值】
'' Long,依据发送的消息不同而变化
''【参数表】
'' lpPrevWndFunc----- Long,原来的窗口过程地址
'' HWnd-------------- Long,窗口句柄
'' Msg -------------- Long,发送的消息
'' wParam ----------- Long,消息类型,参考wParam参数表
'' lParam ----------- Long,依据wParam参数的不同而不同
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal HWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
''【VB声明】
'' Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
''【说明】
'' 在窗口结构中为指定的窗口设置信息
''【返回值】
'' Long,指定数据的前一个值
''【参数表】
'' hwnd ----------- Long,欲为其取得信息的窗口的句柄
'' nIndex --------- Long,请参考GetWindowLong函数的nIndex参数的说明
'' dwNewLong ------ Long,由nIndex指定的窗口信息的新值
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal HWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
''【VB声明】
''Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
''【说明】
''【参数表】
''参数dwMessage ---- 为消息设置值,它可以是以下的几个常数值:0、1、2
''NIM_ADD = 0 加入图标到系统状态栏中
''NIM_MODIFY = 1 修改系统状态栏中的图标
''NIM_DELETE = 2 删除系统状态栏中的图标
''参数LpData ---- 用以传入NOTIFYICONDATA数据结构变量,我们也需要在"模块"中定义其结构如下:
''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 * 64 提示信息
''End Type
''---- 其中参数uCallbackMessage、hIcon、szTip也应在模块中声明为以下的常量:
''Public Const NIF_MESSAGE = 1
''Public Const NIF_ICON = 2
''Public Const NIF_TIP = 4
Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
P