- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
怎样使用直接从
VisualBasic
系统任务栏
本文演示了怎样充分利用Windows系统送纸器或使用VisualBasic的任务栏通知地区。它将您选择的图
标放入任务栏通知地区时鼠标rested经过它,将复原应用程序时单击了,并将显示一个弹出式菜单将显示
您选择的工具提示的时用鼠标右键单击。这是全部可能惹起的直接办理回调的VisualBasic的能力,因
此利用完整Shell_NotifyIcon函数的Shell32.dll由被导出。
能够向任何可视的基本项目拥有起码一个窗体和标准模块增添下边的示例。
分步示例
将下边的代码增添到项目中的标准模块的申明部分:
1.
userdefinedtyperequiredbyShell_NotifyIconAPIcall
2.
PublicTypeNOTIFYICONDATA
3.
cbSizeAsLong
4.
hwndAsLong
5.
uIdAsLong
6.
uFlagsAsLong
7.
uCallBackMessageAsLong
8.
hIconAsLong
9.
szTipAsString*64
10.
EndType
11.
12.
constantsrequiredbyShell_NotifyIconAPIcall:
13.
PublicConstNIM_ADD=H0
14.
PublicConstNIM_MODIFY=H1
15.
PublicConstNIM_DELETE=H2
16.
PublicConstNIF_MESSAGE=H1
17.
PublicConstNIF_ICON=H2
18.
PublicConstNIF_TIP=H4
19.
PublicConstWM_MOUSEMOVE=H200
Buttondown
20.
PublicConstWM_LBUTTONDOWN=H201
21.
PublicConstWM_LBUTTONUP=H202
Buttonup
22.
PublicConstWM_LBUTTONDBLCLK=H203
Double-click
23.
PublicConstWM_RBUTTONDOWN=H204
Buttondown
24.
PublicConstWM_RBUTTONUP=H205
Buttonup
25.
PublicConstWM_RBUTTONDBLCLK=H206
Double-click
26.
PublicDeclareFunctionSetForegroundWindowLibuser32_
27.
28.
(ByValhwndAsLong)AsLong
29.
PublicDeclareFunctionShell_NotifyIconLibshell32_
30.
AliasShell_NotifyIconA_
31.
(ByValdwMessageAsLong,pnidAsNOTIFYICONDATA)As
32.
Boolean
PublicnidAsNOTIFYICONDATA
33.
下边的代码增添到您要为您的应用程序响应系统任务栏图标或通知图标在项目中的任何窗体:
35.PrivateSubForm_Load( )
36.theformmustbefullyvisiblebeforecallingShell_NotifyIcon
37.
Me.Show
38.
Me.Refresh
39.
Withnid
40.
.cbSize=Len(nid)
41.
.hwnd=Me.hwnd
42.
.uId=vbNull
43.
.uFlags=NIF_ICONOrNIF_TIPOrNIF_MESSAGE
44.
.uCallBackMessage=WM_MOUSEMOVE
45.
.hIcon=Me.Icon
46.
.szTip=YourToolTipvbNullChar
47.
EndWith
48.
Shell_NotifyIconNIM_ADD,nid
49.
EndSub
50.
51.
PrivateSubForm_MouseMove(ButtonAsInteger,ShiftAs
Integer,XAsSingle,YAsSingle)
52.
thisprocedurereceivesthecallbacksfromtheSystem
Trayicon.
53.
DimResultAsLong
54.
DimmsgAsLong
55.
thevalueofXwillvarydependinguponthescalemode
56.
setting
IfMe.ScaleMode=vbPixelsThen
57.
msg=X
58.
Else
59.
msg=X/Scre
文档评论(0)