选择显示字体大小

用vb6在托盘程序中加入应用程序图标

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

  4、在form1的load事件中写下如下代码:

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

  5、在form1的queryunload事件中写入如下代码:

private sub form_queryunload(cancel as integer, unloadmode as integer)
call shell_notifyicon(nim_delete, nficondata)
end sub

  6、在form1的mousemove事件中写下如下代码:

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

  7、现在将程序保存起来运行看看系统托盘处是否增加了一个本工程的图标。单击此图标,form1就自动弹出来了。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

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   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons