Delphi7使用控件CoolTrayIcon时如何做到程序启动就最小化到托盘

学习Delphi时,使用了第3方控件CoolTrayIcon。CoolTrayIcon的功能很强大,能够将程序添加进托盘,省去了我们再编写代码来实现托盘。但是在看搜CoolTrayIcon的时候,发现好多朋友在求如何让程序在启动就最小化多托盘的方法。但是貌似都不曾成功过。笔者摸索了一下,成功实现了。

找原因

首先我们来看一下CoolTrayIcon的功能函数:根据CoolTrayIcon的使用实例来看,CoolTrayIcon提供了函数HideMainForm()。好吧我们如果在FromCreat里面如果调用该函数会发现没有任何反应。为什么呢?我们接着跟踪这个函数看一下它的声明:

procedure TCoolTrayIcon.HideMainForm;
begin
  if Owner is TWinControl then         // Owner might be of type TService
    if Application.MainForm <> nil then
    begin
      // Hide the form itself (and thus any child windows)
      Application.MainForm.Visible := False;
      { Hide application's TASKBAR icon (not the tray icon). Do this AFTER
        the main form is hidden, or any child windows will redisplay the
        taskbar icon if they are visible. }
      HideTaskbarIcon;
    end;
end;

好吧,我们看到这里应该知道了吧。如果你还不知道,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
目录清单:  01界面设计           制作一个屏幕保护程序           制作一个漂亮的VCD播放器           制作几何形状的窗体           制作桌面小精灵           制作相框           实现带阴影效果的画框           给Memo组件的显示区域加边框  02系统设置           一个托盘程序           如何实现目录的复制、删除和移动           如何改换壁纸和启动、关闭屏保           文件管理器           格式化磁盘           获取Windows、System和Temp目录           获取文件日期信息           获取驱动器信息           重启或关闭计算机           隐藏任务栏和桌面图标  03硬件访问与控制           实例1-获取和设置显示器模式           实例10 两种不同的方法获取端口信息           实例2-电源电池信息           实例3-内存状态信息           实例4-CPU型号信息           实例5-硬盘和光盘的操作           实例6-获取不同的声音播放设备           实例7-键盘相关设置           实例8-鼠标相关设置           实例9-从注册表中读取各类硬件信息  04控件应用           LISTBOX控件的折行显示           在控件中添加消息处理           将系统中的com接口包装为控件           带背景图的标签           我的资源管理器           打造自己的文件分割器           编写一个滚动提示控件           自制邮件发送客户端  05文件操作           Delphi中的INI文件编程           删除或移动正在使用的文件           如何在Delphi中操作Excel           实现应用程序的文件拖放功能           将EXE文件转换成SWF文件           将SWF文件转换成EXE文件           文件捆绑           统计中英文字个数  06图形图像多媒体           实例一--艺术字效果           实例七---photoshop图层效果           实例三---图象效果处理           实例九---在IntraWeb中显示图片数据           实例二--渐变色和动画矩形效果           实例五--编织带           实例八--动画屏保           实例六--镜框效果           实例十--matlab结合           实例十--电子地图开发之GIS组件--Mapobject深入开发           实例四---scanline属性  07数据库应用           实例1  Session获取BDE信息           实例10   决策图的使用           实例11  ThreadedIBX           实例2  可视化创建数据表格           实例3  SQL语句的使用           实例4  “一对多表”的设计           实例5   文本和数据记录的转换           实例6 利用ADO的从SQL Server 2000中读取数据           实例7  多媒体数据库的使用           实例8  IntraWeb技术的实现           实例9  Rave报表的数据库使用  08网络与通讯           实例一 用DELPHI实现网络信使服务           实例七 NetClock           实例三 断点续传           实例二 升级精灵           实例五 网络文件传输           实例六 Ping           实例四 邮件群发  09趣味游戏           实例1--小狗过桥游戏           实例10--深入opengl游戏           实例2--键盘练习           实例3--字母拼图游戏           实例4--乒乓球           实例5-6--打地鼠---2个部分           实例7-8--扫雷--2个部分           实例9--一个简单的opengl游戏
DELPHI7下好用的托盘控件,安装简单,版本进度如下:TCoolTrayIcon, ver. 2.3.0 - ver. 2.3.0: Various minor bugs fixed: 1) Calling the ShowMainForm and HideMainForm methods before the main form was created would crash the app. Fixed thanks to James Legg. 2) The tooltip would give trouble if it was 64 chars. Thanks to Toms Baugis and Teus de Jong. 3) The popup menu would not close itself auto- matically if the StartMinimized property was true. Thanks to Ingo Krueger, Chris Witt, and Reister HansJoerg. - ver. 2.2.2: When there was more than one form visible the taskbar icon would not hide when the main form was minimized. Fixed. - ver. 2.2.1: Fixed a popup menu bug. Also fixed a bug which meant D2 and D3 users could not compile the component. Added more icon animations in the demo. Thanks to Daniele Gervasoni for the "tray graph". - ver. 2.2.0: IconIndex is now a property, allowing you to specify an icon at run-time. The OnCycle event is changed so it returns the index to the next icon that will display when cycling. Finally, I fixed a bug that caused the taskbar icon not to display itself when MinimizeToTray was true. Thanks to Lorenz Graf for pointing it out to me. - ver. 2.1.4: The main form will no longer show itself untimely after the form's BorderStyle property is changed. Thanks to Thomas Reimann. - ver. 2.1.3: Fixed a bug that caused the main form not to display itself (how embarassing). - ver. 2.1.2: I *finally* found the bug that would cause some compound controls (like controls on notebook pages or tab sheets) not to display properly when StartMinimized was true. Incidently, this also means that TForm.Position now works. Also fixed a minor bug that caused modal forms owned by the main form to appear behind the main form when the popup menu appeared (thanks to Arash Ramin). - ver. 2.1.1: Added notification method to properly detect whether the associated popup menu and imagelist are deleted. Thanks to

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值