AIR:计算系统托盘图标位置 — 观Acrobat AIR有感


大家知道Acrobat AIR程序切换到Widget模式下,最小化时有个收缩并移动到系统托盘区的过渡动画效果,即使将任务栏更改到屏幕的其他区域,程序均能正确的收缩到新的系统托盘位置.
对这个效果很感兴趣,于是从文档及网络查了相关的API,包括DockIcon,SystemTrayIcon,无果.
最后在想是不是Adobe开发人员使用了未开放的屏幕类,呵呵,想到屏幕类忽然来了灵感,虽然最开始时Screen类也排查过,并无提供系统托盘相关方法,但仔细观察她的方法和属性:
[color=Blue]bounds : Rectangle
[color=Black][read-only] The bounds of this Screen.
[color=Blue]mainScreen : Screen
[color=Black][static] [read-only] The primary display.
[color=Blue]visibleBounds : Rectangle
[color=Black][read-only] The bounds of the area on this Screen in which windows will be visible.
通过mainScreen.bounds和visibleBounds的比较得出当前任务栏的位置.
trace得到:
[color=Brown](x=0, y=0, w=1400, h=1050)
(x=0, y=0, w=1400, h=1020)
得出我的任务栏位置是bottom,任务栏高度是30像素.Y坐标没问题了,那么X坐标呢?
观察得知,Acrobat AIR程序并未获得精确的X坐标.通过增加或减少托盘区的图标,可以发现每次收缩结束时的X坐标位置未有任何变化.那么暂时可以使用固定值来代替.
接下来就是代码的工作了 :)
[b]AIR Setup File
Source Code[/b]
测试的操作系统:Windows XP Pro. SP2
如果DEMO程序有BUG或你有更好的方法甚至知道如何获得系统托盘精确位置,务必留言或写信联系我.
auzn1982[AT]gmail.com
Cheers!

10 comments to AIR:计算系统托盘图标位置 — 观Acrobat AIR有感

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">