systray

Discussion in 'Chinese Forum' started by tmxk, Jan 14, 2009.

  1. tmxk

    tmxk New Member

    下面是一个系统托盘程序代码
    Sub Globals
    '设备端添加NotifyIcon.dll,dzHW.dll外部库。PC桌面端添加 NotifyIconDesktop.dll,dzHWdesktop.dll外部库.
    Dim ExitCondition
    AppName ="系统托盘程序演示"
    EmailName = "tmxt_fy@qq.com"
    CompanyName = "@ 2009 云飞工作室"
    VersionNumber = "V 1.0.0-测试版"
    End Sub
    Sub App_Start
    '初始值'初始化类的外部库
    ExitCondition = False
    dzHW.New1 '创建dzHW组件
    ni.New1 '创建NotifyIcon组件
    Form1.Text = AppName
    ni.IconText = AppName '设置图标文字,设备端设备端不显示
    ni.Add
    Form1.Show

    End Sub
    Sub mnuAbout_Click
    '关于
    Msgbox(AppName & CRLF & VersionNumber & CRLF & CompanyName & CRLF & EmailName, "关于")
    End Sub
    Sub mnuExit_Click
    '退出程序
    ExitCondition = True
    AppClose
    End Sub
    Sub Form1_Close
    '关闭事件
    If ExitCondition = False Then
    '要求关闭。不关闭...
    form1.CancelClose
    '...隐藏窗口 - SW_HIDE
    dzHW.ShowWindow(dzHW.GetActiveWindowHandle, 0)
    Else
    '删除图标
    ni.Remove
    End If
    End Sub
    Sub ni_Click
    '单击系统托盘图标
    Dim hWnd
    hWnd = dzHW.GetWindowHandle("null", AppName)'获取窗口句柄名称和类的名称
    dzHW.ShowWindow(hWnd, 5)'显示窗口 - SW_SHOW
    dzHW.ShowWindow(hWnd, 9)'还原窗口 - SW_RESTORE
    dzHW.BringWindowToFront(AppName)'让程序的窗口成为前端窗口
    End Sub
    Sub mnuHide_Click
    '进入后台
    dzHW.ShowWindow(dzHW.GetActiveWindowHandle, 0)'隐藏 - SW_HIDE
    End Sub

    演示文件的使用:去掉zip用winrar解压双击运行开始播放
     
    Last edited: Jan 14, 2009
  2. Fall

    Fall New Member

    编译的时候报错:(
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice