📄 c++ builder高手进阶(四)动态显示任务栏图标.htm
字号:
<A title=Google究竟知道多少个人隐私?
href="http://www.malegebide.com/article/5/11/2006/200608301361.html">Google究竟知道多少..</A><BR>·
<A title="Google搜索从入门到精通 (1)"
href="http://www.malegebide.com/article/5/11/2006/200608301351.html">Google搜索从入门到..</A><BR>·
<FONT color=#0066ff>[图文]</FONT> <A title=google也来做统计了
href="http://www.malegebide.com/article/5/12/2006/200608311519.html">google也来做..</A><BR>·
<FONT color=#ff0066>[组图]</FONT> <A title=Google徽标全集(1998-2005)
href="http://www.malegebide.com/article/5/12/2006/200608311488.html">Google徽标全..</A><BR>·
<FONT color=#0066ff>[图文]</FONT> <A title=有趣的Google新鲜技巧玩法
href="http://www.malegebide.com/article/5/11/2006/200608301352.html">有趣的Google..</A><BR>·
<A title=Google排名—搜索引擎登记技巧
href="http://www.malegebide.com/article/5/11/2006/200608301360.html">Google排名—搜索引..</A><BR>·
<FONT color=#0066ff>[图文]</FONT> <A title=菜鸟安全防患之饿死木马
href="http://www.malegebide.com/article/10/2006/200608291188.html">菜鸟安全防患..</A><BR>·
<A title=数学最大数字
href="http://www.malegebide.com/article/9/2006/20060827361.html">数学最大数字</A><BR>·
<A title=Google搜索技巧(6):用Google找自己
href="http://www.malegebide.com/article/10/2006/200608291195.html">Google搜索技巧(6):..</A><BR></TD></TR>
<TR>
<TD bgColor=#ffffff height=2></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=titleback1>相关文章</TD></TR>
<TR>
<TD vAlign=top height=100>· <A title="《c++ primer》读书笔记4"
href="http://www.malegebide.com/article/1/14/2006/2006092518481.html">《c++
primer》读书..</A><BR>· <A title="《c++ primer》读书笔记6"
href="http://www.malegebide.com/article/1/14/2006/2006092518480.html">《c++
primer》读书..</A><BR>· <A title="一个有意思的C++ trick (2)"
href="http://www.malegebide.com/article/1/14/2006/2006092518477.html">一个有意思的C++
tr..</A><BR>· <A title="《c++ primer》读书笔记3"
href="http://www.malegebide.com/article/1/14/2006/2006092518473.html">《c++
primer》读书..</A><BR>· <A title="《c++ primer》读书笔记5"
href="http://www.malegebide.com/article/1/14/2006/2006092518472.html">《c++
primer》读书..</A><BR>· <A title="如何在C++ Builder的DLL中使用数据库控件"
href="http://www.malegebide.com/article/1/14/2006/2006092518470.html">如何在C++
Builder的..</A><BR>· <A title="Python 与 C++ 程序的简单实例对比"
href="http://www.malegebide.com/article/1/14/2006/2006092518469.html">Python
与 C++ 程序..</A><BR>· <A title="Visual C++ MFC 一文说尽 (推荐)(很长,没耐心就不要看了)"
href="http://www.malegebide.com/article/1/14/2006/2006092518468.html">Visual
C++ MFC 一文..</A><BR>· <A title="VC++ Members Weblog"
href="http://www.malegebide.com/article/1/14/2006/2006092518466.html">VC++
Members Weblo..</A><BR>· <A title="C++ Builder和托管C++中属性的使用建议"
href="http://www.malegebide.com/article/1/14/2006/2006092518459.html">C++
Builder和托管C..</A><BR></TD></TR></TBODY></TABLE></TD>
<TD class=tableright align=right width=588>
<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=575 border=0>
<TBODY>
<TR>
<TD style="FONT-SIZE: 12pt; COLOR: #ff6600" align=middle
height=32>C++ Builder高手进阶 (四)动态显示任务栏图标</TD></TR>
<TR>
<TD align=middle bgColor=#f7f7f7
height=25>作者:佚名 来源:不详 发布时间:25/09/2006
19:11:35 发布人:admin</TD></TR>
<SCRIPT language=javascript>
var newasp_fontsize=9;
var newasp_lineheight=12;
</SCRIPT>
<TR>
<TD>
<P align=right><A title=减小字体
style="CURSOR: hand; POSITION: relative"
onclick='if(newasp_fontsize>8){NewaspContentLabel.style.fontSize=(--newasp_fontsize)+"pt";NewaspContentLabel.style.lineHeight=(--newasp_lineheight)+"pt";}'><IMG
height=15 src="C++ Builder高手进阶(四)动态显示任务栏图标.files/1.gif" width=15
border=0><FONT color=#ff6600>减小字体</FONT></A> <A title=增大字体
style="CURSOR: hand; POSITION: relative"
onclick='if(newasp_fontsize<64){NewaspContentLabel.style.fontSize=(++newasp_fontsize)+"pt";NewaspContentLabel.style.lineHeight=(++newasp_lineheight)+"pt";}'><IMG
height=15 src="C++ Builder高手进阶(四)动态显示任务栏图标.files/2.gif" width=15
border=0><FONT color=#ff6600>增大字体</FONT></A> </P>
<DIV class=ContentFont id=NewaspContentLabel
style="PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"><FONT
id=font_word
style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif">
<P align=center><STRONG><FONT face=宋体 size=4>C++
Builder高手进阶 </FONT></STRONG></P>
<P align=center><FONT face=宋体 size=3><STRONG><FONT
size=4> </FONT>(四)动态显示任务栏图标</STRONG></FONT></P>
<P align=center><FONT face=宋体 size=3><A
href="mailto:nxyc_twz@163.com">nxyc_twz@163.com</A></FONT></P>
<P> 在应用程序运行时,
<DIV
id=kjifiullqorbstvrge>网vwx网VX网#C.qh]件管育3</DIV>有时可能会因为要处理的数据量很大而暂时失去反应,这样给用户的感觉极其不好,影响了软件的更广泛应用。利用多线程技术固然可以解决这个问题,可这里我并想使用多线程,我想示范一下如何编制动态任务栏图标。<BR><BR> 我的编程思路是:通过设置Timer时钟控件使应用程序在规定的时间间隔内发送特定的消息,使任务栏图标不断更改,从而形成动画效果。实现方法为在应用程序的窗体中拖放几个Image控件,<FONT
id=dvmcaawlmcdsfpvdie>q~^]-软;YC业IY1w软.[国</FONT><FONT
id=wpdkcaswmumrmmnquc>;%iOCI[2OG]件无管理~a软</FONT>使他们装载相应的图画,几幅图画按顺序连续的被显示,就形成了动画。<BR><BR> 应用程序必须用发送消息的办法通知任务栏增加,删除,和修改图标。发送消息必须调用Shell_NotifyIcon。它的原形为:<BR><BR> WINSHELLAPI
BOLL WINAPI Shell_NotifyIcon(<BR> DWORD dwMessage, POINTIFYCONDATA
pnid);<BR><BR> 第一个参数 dwMessage是发送消息的标志,可以选<BR> NIM_ADD //
往任务栏通知区添加图标<BR> NIM_DELETE //往任务栏通知区删除图标<BR> NIM_MODIFY
//通知任务栏通知区修改图标<BR><BR>编制消息发送函数TrayMessage<BR>bool __fastcall
TForm1::TrayMessage(DWORD dwMessage)<BR>{<BR>NOTIFYICONDATA
tnd;<BR>PSTR pszTip;<BR>pszTip = TipText();<BR>tnd.cbSize=
sizeof(NOTIFYICONDATA);<BR>//结构的大小<BR>tnd.uCallbackMessage =
MYWM_NOTIFY;<BR>//自定义回调消息,在头文件中声明<BR>tnd.hWnd=
Handle;<BR>//接受回调消息的窗口句柄<BR>tnd.uID =
IDC_MYICON;<BR>//图标标志号<BR>tnd.uFlags= NIF_MESSAGE | NIF_ICON |
NIF_TIP;<BR>//指定以下三个参数哪个包含有效数据<BR>if (dwMessage ==
NIM_MODIFY)<BR>{<BR>tnd.hIcon =<BR>(HICON)IconHandle();
//取得图标句柄<BR>if (pszTip)<BR>lstrcpyn(tnd.szTip,
pszTip,<BR>sizeof(tnd.szTip));<BR>else<BR>tnd.szTip[0] =
''''\0'''';<BR>}<BR>else<BR>{<BR>tnd.hIcon = NULL;<BR>tnd.szTip[0] =
''''\0'''';<BR>}<BR>return (Shell_NotifyIcon(dwMessage,
&tnd));<BR>}<BR>编制取得图标句柄的函数<BR>HICON __fastcall
TForm1::IconHandle(void)<BR>{<BR>if (n==1)<BR>{ return (Image1-
>Picture->Icon- >Handle);<BR>//n是全局变量,<SPAN
id=dghcuehahipgjwu>m的4软-理管ShqTNa8s</SPAN><FONT
id=salqcoauqvgjg>yS:C[HVc业6中CZ</FONT>1为显示Image1,0为Image2<BR>}<BR>else<BR>{
return (Image2- >Picture- >Icon-
>Handle);<BR>}<BR>}<BR>编制图标状态转换函数<BR><BR>void __fastcall
TForm1::ToggleState(void)<BR>{<BR>if (n==1) //n为图标句柄锁,<SPAN
id=pnhcoclcwtelp>育!3提ZY:Qw:)中0</SPAN>是全局变量,<BR>1为显示Image1,0为Image2<BR>{<BR>n=n-1;<BR>}<BR>else<BR>{<BR>n=n+1;<BR>}<BR>TrayMessage(NIM_MODIFY);<BR>//发送图标变换消息<BR>}<BR><BR><BR> 对Timer控件编制代码,设它的Interval属性为1000,即定时器每一秒响应一次。为
Ontimer事件键入代码:<BR><BR>void __fastcall TForm1::Timer1Timer(TObject
*Sender)<BR>{ ToggleState( );<BR>}<BR><BR>
<P></P></SPAN></SPAN>
<DIV class=Message id=Message></DIV></FONT></DIV>
<DIV></DIV></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"
align=right bgColor=#f7f7f7 height=25>[
<SCRIPT language=JavaScript
src="C++ Builder高手进阶(四)动态显示任务栏图标.files/Hits.htm"></SCRIPT>
] [<A href="javascript:history.go(-1)">返回上一页</A>] [<A
href="javascript:window.print()">打 印</A>] [<A
href="http://www.malegebide.com/user/favorite.asp?action=add&topic=C++ Builder高手进阶 (四)动态显示任务栏图标">收
藏</A>]</TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
<DIV>上一篇文章:<A
href="http://www.malegebide.com/article/1/14/2006/2006092518222.html">用C++
Builder轻松打造RealPlayer播放器</A></DIV>
<DIV>下一篇文章:<A
href="http://www.malegebide.com/article/1/14/2006/2006092518224.html">C++
Builder 高手进阶 (五)用BCB编写多线程应用程序</A></DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=575 border=0>
<TBODY>
<TR>
<TD class=titlebg1>∷相关文章评论∷ (评论内容只代表网友观点,与本站立场无关!) [<A
href="http://www.malegebide.com/article/comment.asp?ArticleID=18223"
target=_blank>更多评论</A>…]</TD></TR>
<TR vAlign=top>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!-- 页面底部开始 -->
<TABLE class=tableborder cellSpacing=0 cellPadding=0 width=778 align=center
border=0>
<TBODY>
<TR>
<TD height=5></TD></TR>
<TR>
<TD class=linebar height=8></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD class=tablebody align=middle height=65>QQ:310646 <A class=navmenu
href="http://www.malegebide.com/admin/admin_login.asp" target=_blank>A</A>
Copyright © 2006 <FONT face=Verdana, sans-serif Helvetica,
Arial,><B>Malegebide.Com</B></FONT>.
<SCRIPT language=javascript
src="C++ Builder高手进阶(四)动态显示任务栏图标.files/529370.js"
type=text/javascript></SCRIPT>
No Rights Reserved <BR></TD></TR>
<TR>
<TD height=5></TD></TR></TBODY></TABLE>
<SCRIPT language=javascript
src="C++ Builder高手进阶(四)动态显示任务栏图标.files/Std_StranJF.Js"></SCRIPT>
<!-- 页面底部结束 -->
<SCRIPT src="C++ Builder高手进阶(四)动态显示任务栏图标.files/count.htm"
type=text/javascript></SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -