| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> yong C++Builder bian xie Tray cheng xu

yong C++Builder bian xie Tray cheng xu

2008-06-01 02:05:59 编辑來源:互联网 评论
 
 
 
本文为【用C++Builder编写Tray程序】的拼音翻译版
  Tray( tuo pan ) shi Windows9x ren wu tiao shang de yi ge fei fan qu yu , ta de ji shu ming cheng wei “ ren wu lan bu gao qu ”, yi xie ruan jian ( ru jin shan ci ba Ⅲ) yun xing shi hui zai tuo pan shang fang zhi yi ge tu biao , shi yong hu yi yan jiu neng zhi dao zhe ge cheng xu zheng zai hou tai yun xing , yao xiang ji huo ta ye hen qing yi , tong chang zhi xu dan ji yi xia zhe ge tu biao ji ke , fei chang fang bian 。
  Tray de bian cheng bi jiao fei fan , dan bing bu nan , zhu yao bao kuo tu biao 、 gong ju ti shi he xiao xi deng san ge fang mian , ta shi Shell bian cheng de yi bu fen 。ShellAPI ti gong le Shell—NotifyIcon han shu , yong ta ke yi zeng jia 、 shan chu huo zhe xiu gai tuo pan zhong de tu biao , zai tuo pan shang fang zhi tu biao hou ,Windows Shell hui fu ze ba fa sheng zai tu biao shang de shu biao shi jian tong zhi ying yong cheng xu 。Shell—NotifyIcon han shu ding yi ru xia :
  WINSHELLAPI BOOL WINAPI Shell—NotifyIcon(DWord dwMessage,PNOTIFYICONDATA pnid);
  dwMessage biao shi yao wan cheng de cao zuo :NIM—ADD( zeng jia tu biao )、NIM—DELETE( shan chu tu biao )、NIM—MODIFY( xiu gai tu biao huo ti shi wen ben ),pnid shi yi ge zhi xiang NOTIFYICONDATA jie gou de zhi zhen , jie gou de ding yi ru xia :
  typedef strUCt —NOTIFYICONDATA{
  DWORD cbSize;// jie gou suo zhan de zi jie shu , bi xu yong jie gou de da xiao lai chu shi hua 。
  HWND hWnd;// jie shou Tray tu biao xiao xi de chuang kou ju bing
  UINT uID;// you ying yong cheng xu ding yi de tu biao ID
  UINT uFlags;// yong lai jian bie na xie xu yao gai bian qi zhi de yu ,NIF_ICON biao shi hIcon you xiao , ke yong lai xiu gai tu biao ,NIF_MESSAGE biao shi uCallbackMessage you xiao , yong lai ding yi xiao xi ,NIF—TIP biao shi szTip shen shu you xiao , ke xiu gai gong ju ti shi 。
  UINT uCallbackMessage;// ying yong cheng xu ding yi de xiao xi
  HICON hIcon;//Tray tu biao de ju bing
  char szTip[64];// gong ju ti shi de wen ben
  }NOTIFYICONDATA;
  xia mian wo men jiu tong guo yi ge ju ti li zi lai shuo ming shi xian fang fa , cheng xu yun xing shi bu hui xian shi zhu chuang ti , zhi zai tuo pan shang zeng jia yi ge tu biao , shuang ji tu biao ke guan bi cheng xu 。
  cheng xu yun xing shi tuo pan qu xian shi ru xia :
  xin jian yi ge gong cheng , fang zhi yi ge Timer kong jian dao chuang ti shang 。 da kai unit1.h wen jian , zeng jia tou wen jian shuo ming #include <shellapi.h>, zai TForm1 ding yi de private duan zeng jia yi xie shu ju cheng yuan he fang fa de sheng ming :
  unsigned int iconmessage;// ding yi de xiao xi
  void AddTrayIcon();// zai tuo pan shang zeng jia tu biao
  void RemoveTrayIcon();// cong tuo pan zhong shan chu tu biao
  you yu yao zeng jia dui zi ding yi xiao xi de chu li , suo yi bi xu chong zai chuang kou guo cheng han shu WndProc, zai TForm1 de ding yi zhong zeng jia protected duan :virtual void ——fastcall WndProc(Messages::Tmessage& Message);
  zai unit1.cpp zhong ding yi xiang ying de cheng yuan han shu :
  void TForm1::AddTrayIcon()
  {
  NOTIFYICONDATA icondata;
  memset(&icondata,0,sizeof(icondata));
  // jiang jie gou icondata de ge yu chu shi hua wei 0
  icondata.cbSize=sizeof(icondata);
  icondata.hWnd=Handle;
  strncpy(icondata.szTip,″ wei zhi zhuang tai ″,sizeof(icondata.szTip));
  icondata.hIcon=Application->Icon->Handle;
  icondata.uCallbackMessage=iconmessage;
  icondata.uFlags=NIF—MESSAGENIF—ICONNIF—TIP;
  Shell—NotifyIcon(NIM—ADD,&icondata);
  }
  void TForm1::RemoveTrayIcon()
  {
  NOTIFYICONDATA icondata;
  memset(&icondata,0,sizeof(icondata));
  icondata.cbSize=sizeof(icondata);
  icondata.hWnd=Handle;
  Shell—NotifyIcon(NIM—DELETE,&icondata);
  }
  chong zai TForm1 de WndProc han shu , jia ru dui zi ding yi xiao xi de chu li dai ma , zhe qi shi xiang dang yu chuang jian le TForm lei de zi lei 。
  void __fastcall TForm1::WndProc(Messages::TMessage& Message)
  {
  if(Message.Msg==iconmessage)
  {
  if(Message.LParam==WM—LBUTTONDBLCLK)
  {
  Application->Terminate();
  // jia ru shuang ji tu biao , ze guan bi ying yong cheng xu
  }
  return;
  }
  TForm::WndProc(Message);// dui yu qi ta de xiao xi , tiao yong ji chu lei de WndProc han shu rang Windows jin xing que sheng chu li 。
  
  
  }
  chuang jian chuang ti de OnCreate shi jian ju bing :
  void ——fastcall TForm1::FormCreate(TObject *Sender)
  {
  iconmessage=RegisterWindowMessage(″IconNotify″);
  AddTrayIcon();
  }
  zhe li tong guo tiao yong RegisterWindowMessage han shu lai ding yi yi ge yong hu xiao xi , ye ke yi tong guo WM_USER+n lai huo de yi ge xi tong mei you shi yong de xiao xi bian hao 。
  void ——fastcall TForm1::FormDestroy(TObject *Sender)
  {
  RemoveTrayIcon();
  // chuang ti zai guan bi shi shan chu tuo pan zhong de tu biao
  }
  bian xie Timer1 de Timer shi jian dai ma , dang yong hu jiang shu biao ting liu zai tu biao shang shi , xian shi ti shi wen ben :
  void ——fastcall TForm1::Timer1Timer(TObject *Sender)
  {
  NOTIFYICONDATA icondata;
  memset (&icondata, 0, sizeof (icondata));
  icondata.cbSize = sizeof (icondata);
  icondata.hWnd = Handle;
  String s=″ wo de tu biao !″;// ding yi ti shi wen ben
  strncpy (icondata.szTip, s.c_str(), sizeof (icondata.szTip));
  icondata.uFlags = NIF—TIP ;
  Shell—NotifyIcon (NIM—MODIFY,&icondata);
  }
  cheng xu yun xing shi bu xian shi zhu chuang ti , zhi zai tuo pan shang fang zhi xiang ying de cheng xu tu biao , cong C++ Builder zhu xuan dan zhong xuan ze ViewProject Source, zai WinMain han shu de Application→Initialize() yu ju hou zeng jia dai ma :
  ShowWindow(Application→Handle,SW—HIDE);
  Application→ShowMainForm=false;
  an F9 bian yi bing yun xing cheng xu , tuo pan shang jiu hui chu xian xiang ying de tu biao 。 yi shang dai ma zai C++ Builder3、Pwin98 huan jing xia bian yi 、 yun xing tong guo 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
Tray( tuo pan ) shi Windows9x ren wu tiao shang de yi ge fei fan qu yu , ta de ji shu ming cheng wei “ ren wu lan bu gao qu ”, yi xie ruan jian ( ru jin shan ci ba Ⅲ) yun xing shi hui zai tuo pan shang fang zhi yi ge tu biao , shi yong hu yi yan jiu neng zhi dao zhe ge cheng xu zheng zai hou tai yun xing , yao xiang ji huo ta ye hen qing yi , tong chang zhi xu dan ji yi xia zhe ge tu biao ji ke , fei chang fang bian 。   Tray de bian cheng bi jiao fei fan , dan bing bu nan , zhu yao bao kuo tu biao 、 gong ju ti shi he xiao xi deng san ge fang mian , ta shi Shell bian cheng de yi bu fen 。ShellAPI ti gong le Shell—NotifyIcon han shu , yong ta ke yi zeng jia 、 shan chu huo zhe xiu gai tuo pan zhong de tu biao , zai tuo pan shang fang zhi tu biao hou ,Windows Shell hui fu ze ba fa sheng zai tu biao shang de shu biao shi jian tong zhi ying yong cheng xu 。Shell—NotifyIcon han shu ding yi ru xia :   WINSHELLAPI BOOL WINAPI Shell—NotifyIcon(DWord dwMessage,PNOTIFYICONDATA pnid);   dwMessage biao shi yao wan cheng de cao zuo :NIM—ADD( zeng jia tu biao )、NIM—DELETE( shan chu tu biao )、NIM—MODIFY( xiu gai tu biao huo ti shi wen ben ),pnid shi yi ge zhi xiang NOTIFYICONDATA jie gou de zhi zhen , jie gou de ding yi ru xia :   typedef strUCt —NOTIFYICONDATA{   DWORD cbSize;// jie gou suo zhan de zi jie shu , bi xu yong jie gou de da xiao lai chu shi hua 。   HWND hWnd;// jie shou Tray tu biao xiao xi de chuang kou ju bing   UINT uID;// you ying yong cheng xu ding yi de tu biao ID   UINT uFlags;// yong lai jian bie na xie xu yao gai bian qi zhi de yu ,NIF_ICON biao shi hIcon you xiao , ke yong lai xiu gai tu biao ,NIF_MESSAGE biao shi uCallbackMessage you xiao , yong lai ding yi xiao xi ,NIF—TIP biao shi szTip shen shu you xiao , ke xiu gai gong ju ti shi 。   UINT uCallbackMessage;// ying yong cheng xu ding yi de xiao xi   HICON hIcon;//Tray tu biao de ju bing   char szTip[64];// gong ju ti shi de wen ben   }NOTIFYICONDATA;    xia mian wo men jiu tong guo yi ge ju ti li zi lai shuo ming shi xian fang fa , cheng xu yun xing shi bu hui xian shi zhu chuang ti , zhi zai tuo pan shang zeng jia yi ge tu biao , shuang ji tu biao ke guan bi cheng xu 。    cheng xu yun xing shi tuo pan qu xian shi ru xia :    xin jian yi ge gong cheng , fang zhi yi ge Timer kong jian dao chuang ti shang 。 da kai unit1.h wen jian , zeng jia tou wen jian shuo ming #include <shellapi.h>, zai TForm1 ding yi de private duan zeng jia yi xie shu ju cheng yuan he fang fa de sheng ming :   unsigned int iconmessage;// ding yi de xiao xi   void AddTrayIcon();// zai tuo pan shang zeng jia tu biao   void RemoveTrayIcon();// cong tuo pan zhong shan chu tu biao    you yu yao zeng jia dui zi ding yi xiao xi de chu li , suo yi bi xu chong zai chuang kou guo cheng han shu WndProc, zai TForm1 de ding yi zhong zeng jia protected duan :virtual void ——fastcall WndProc(Messages::Tmessage& Message);    zai unit1.cpp zhong ding yi xiang ying de cheng yuan han shu :   void TForm1::AddTrayIcon()   {   NOTIFYICONDATA icondata;   memset(&icondata,0,sizeof(icondata));   // jiang jie gou icondata de ge yu chu shi hua wei 0   icondata.cbSize=sizeof(icondata);   icondata.hWnd=Handle;   strncpy(icondata.szTip,″ wei zhi zhuang tai ″,sizeof(icondata.szTip));   icondata.hIcon=Application->Icon->Handle;   icondata.uCallbackMessage=iconmessage;   icondata.uFlags=NIF—MESSAGENIF—ICONNIF—TIP;   Shell—NotifyIcon(NIM—ADD,&icondata);   }   void TForm1::RemoveTrayIcon()   {   NOTIFYICONDATA icondata;   memset(&icondata,0,sizeof(icondata));   icondata.cbSize=sizeof(icondata);   icondata.hWnd=Handle;   Shell—NotifyIcon(NIM—DELETE,&icondata);   }    chong zai TForm1 de WndProc han shu , jia ru dui zi ding yi xiao xi de chu li dai ma , zhe qi shi xiang dang yu chuang jian le TForm lei de zi lei 。   void __fastcall TForm1::WndProc(Messages::TMessage& Message)   {   if(Message.Msg==iconmessage)   {    if(Message.LParam==WM—LBUTTONDBLCLK)    {    Application->Terminate();   // jia ru shuang ji tu biao , ze guan bi ying yong cheng xu    }    return;   }   TForm::WndProc(Message);// dui yu qi ta de xiao xi , tiao yong ji chu lei de WndProc han shu rang Windows jin xing que sheng chu li 。   }    chuang jian chuang ti de OnCreate shi jian ju bing :   void ——fastcall TForm1::FormCreate(TObject *Sender)   {   iconmessage=RegisterWindowMessage(″IconNotify″);   AddTrayIcon();   }    zhe li tong guo tiao yong RegisterWindowMessage han shu lai ding yi yi ge yong hu xiao xi , ye ke yi tong guo WM_USER+n lai huo de yi ge xi tong mei you shi yong de xiao xi bian hao 。   void ——fastcall TForm1::FormDestroy(TObject *Sender)   {   RemoveTrayIcon();   // chuang ti zai guan bi shi shan chu tuo pan zhong de tu biao   }    bian xie Timer1 de Timer shi jian dai ma , dang yong hu jiang shu biao ting liu zai tu biao shang shi , xian shi ti shi wen ben :   void ——fastcall TForm1::Timer1Timer(TObject *Sender)   {   NOTIFYICONDATA icondata;   memset (&icondata, 0, sizeof (icondata));   icondata.cbSize = sizeof (icondata);   icondata.hWnd = Handle;   String s=″ wo de tu biao !″;// ding yi ti shi wen ben   strncpy (icondata.szTip, s.c_str(), sizeof (icondata.szTip));   icondata.uFlags = NIF—TIP ;   Shell—NotifyIcon (NIM—MODIFY,&icondata);   }    cheng xu yun xing shi bu xian shi zhu chuang ti , zhi zai tuo pan shang fang zhi xiang ying de cheng xu tu biao , cong C++ Builder zhu xuan dan zhong xuan ze ViewProject Source, zai WinMain han shu de Application→Initialize() yu ju hou zeng jia dai ma :   ShowWindow(Application→Handle,SW—HIDE);   Application→ShowMainForm=false;    an F9 bian yi bing yun xing cheng xu , tuo pan shang jiu hui chu xian xiang ying de tu biao 。 yi shang dai ma zai C++ Builder3、Pwin98 huan jing xia bian yi 、 yun xing tong guo 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有