1、新建立一个vb6工程,将form1的showintaskbar属性设置为false
2、菜单:工程--添加模块 按“打开”这样就添加了一个新模块,名为module1,保存为module1.bas
3、在module1中写下如下代码:
| option explicit public const max_tooltip as integer = 64 public const nif_icon = &h2 public const nif_message = &h1 public const nif_tip = &h4 public const nim_add = &h0 public const nim_delete = &h2 public const wm_mousemove = &h200 public const wm_lbuttondown = &h201 public const wm_lbuttonup = &h202 public const wm_lbuttondblclk = &h203 public const wm_rbuttondown = &h204 public const wm_rbuttonup = &h205 public const wm_rbuttondblclk = &h206 public const sw_restore = 9 public const sw_hide = 0 public nficondata as notifyicondata public type notifyicondata cbsize as long hwnd as long uid as long uflags as long ucallbackmessage as long hicon as long sztip as string * max_tooltip end type public declare function showwindow lib "user32" (byval hwnd as long, byval ncmdshow as long) as long public declare function shell_notifyicon lib "shell32.dll" alias "shell_notifyicona" (byval dwmessage as long, lpdata as notifyicondata) as long |
| private sub form_load() '以下把程序放入system tray====================================system tray begin with nficondata .hwnd = me.hwnd .uid = me.icon .uflags = nif_icon or nif_message or nif_tip .ucallbackmessage = wm_mousemove .hicon = me.icon.handle '定义鼠标移动到托盘上时显示的tip .sztip = app.title + "(版本 " & app.major & "." & app.minor & "." & app.revision & ")" & vbnullchar .cbsize = len(nficondata) end with call shell_notifyicon(nim_add, nficondata) '=============================================================system tray end me.hide end sub |
| private sub form_queryunload(cancel as integer, unloadmode as integer) call shell_notifyicon(nim_delete, nficondata) end sub |
| private sub form_mousemove(button as integer, shift as integer, x as single, y as single) dim lmsg as single lmsg = x / screen.twipsperpixelx select case lmsg case wm_lbuttonup 'msgbox "请用鼠标右键点击图标!", vbinformation, "实时播音专家" '单击左键,显示窗体 showwindow me.hwnd, sw_restore '下面两句的目的是把窗口显示在窗口最顶层 'me.show 'me.setfocus '' case wm_rbuttonup '' popupmenu menutray '如果是在系统tray图标上点右键,则弹出菜单menutray '' case wm_mousemove '' case wm_lbuttondown '' case wm_lbuttondblclk '' case wm_rbuttondown '' case wm_rbuttondblclk '' case else end select end sub |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器