将程序放入托盘中

原创 2006年05月17日 08:18:00

'以下是一个完整的托盘程序代码****************************************************************************
'************************************************************************************************************
'以下中模块代码
Public Type NOTIFYICONDATA '托盘结构
    cbSize As Long
    hwnd As Long
    uID As Long
    uFlags As Long
    uCallbackMessage As Long
    hIcon As Long
    szTip As String * 128
    dwState As Long
    dwStateMask As Long
    szInfo As String * 256
    uTimeoutAndVersion As Long
    szInfoTitle As String * 64
    dwInfoFlags As Long
End Type

Const niif_info = &H1

Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const NIF_INFO = &H10


Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_RBUTTONUP = &H205
Public Const WM_MOUSEMOVE As Long = &H200

Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean '托盘函数
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

Public TrayI As NOTIFYICONDATA
Public Title_tray As String
'*****************************************************************************************************************

Option Explicit
'以下是窗体代码
Private Sub Form_Load()
On Error Resume Next
    Title_tray = "你好,这是一个托盘程序演示"
    With TrayI
       .cbSize = Len(TrayI)
       .hwnd = Form1.hwnd
       .uID = vbNull
       .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
       .uCallbackMessage = WM_MOUSEMOVE
       .hIcon = Form1.Icon
       .szTip = Title_tray & vbNullChar
    End With
    Call Shell_NotifyIcon(NIM_ADD, TrayI)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Button = 1 Then
       Me.WindowState = vbNormal
       Me.Visible = True
       SetForegroundWindow Me.hwnd
       Form1.PopupMenu Form1.bb '弹出菜单
     End If
     If Button = 2 Then
     '右键
       
     End If
End Sub

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

C#(WPF)程序将Debug中的.exe文件放入注册表中启动,获取错误的当前路径--解决方案

编写的程序需要开机运行,又不想进入win7的桌面。这样可以通过修改注册表,把原来的explorer.exe换成需要启动的软件。 注意,比如.exe文件存在于D盘的Debug文件夹中,则用 D:\\D...

拆分多个字符串放入对应的容器程序代码

描述如下: 若干个虚拟机以“2#1c#10G#1M"标识,现需要拆分每个字符串标识,按照#拆分,放到对应的容器中,代码如下: import java.util.ArrayList; import ...

C#窗体程序入门,实现3秒倒计时关闭显示器,实现系统托盘,右键菜单。

3秒倒计时关闭显示器本文适合新入门C#的同学了解和学习: 软件功能简单,实用。 适合有的时候电脑需要开机又想立即关闭显示器,比如下楼吃饭,比如睡觉前,还比如游戏副本挂机时候。源代码在最后先看界面:...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)