📄 cooltrayicon.html
字号:
<td class='name2' valign='top'>OnStartup</td>
<td class='desc' valign='top'><i>This event applies only when the owner of the
tray icon component is a form.</i><br>
<span class='declaration'>procedure(Sender: TObject; var ShowMainForm: Boolean) of object;</span><br>
Fired initially at application startup when the main form is about to display.
Set the ShowMainForm parameter to false if you don't want the form to display.<br>
<b>NOTE:</b> May fire multiple times for an MDI form (once for every child form
created at startup).<br>
<b>NOTE:</b> This event occurs before the form's OnCreate method (if used with a form).<br>
<b>NOTE:</b> Replaces the StartMinimized property found in earlier versions.</td>
</tr>
</table>
<a name='Hints'></a><h2>Hints</h2>
<ul>
<li><b>How do I start my app. with the tray icon visible and the main form invisible?</b><br>
At design time set IconVisible to true and set the form's Visible property to false.
Set the ShowMainForm parameter to false in the OnStartup event. See the StartHidden demo.
</li>
<li><b>What is the proper way to restore the form?</b><br>
ALWAYS use the method ShowMainForm! This method contains important calls that affect
how the form and the application display themselves. Simply setting the form visible
or calling Application.Restore is not enough. A common symptom is the form with tabpages
that don't update themselves because ShowMainForm wasn't used.
</li>
<li><b>I used the OnStartup event to hide the form, but I can still see a quick flash on
the taskbar when the app. is starting?</b><br>
If it bothers you you can set the Application.ShowMainForm property in the main
project source, like this:
<pre> .....
Application.Initialize;
Application.ShowMainForm := False;
.....</pre>
</li>
<li><b>Why does the tray icon not appear in my NT/2000/XP service app.?</b><br>
Set the service's Interactive property to true, set ServiceType to stWin32, and set the tray icon's
IconVisible property to true.
See also the <a href='#NTServiceIconBug'>bugs section</a> concerning services in NT4.
</li>
<li><b>I want multiple tray icons in my app.?</b><br>
Just create a CoolTrayIcon object for each tray icon you want. The component is optimized
to share resources between the tray icons.
</li>
<li><b>How do I send a message to the tray icon through code?</b><br>
Use PostMessage or SendMessage and specify the message as the LParam parameter.
Here's an example of sending a WM_LBUTTONDOWN message, invoking the tray icon's
OnMouseDown event:
<pre> PostMessage(CoolTrayIcon1.Handle, WM_TRAYNOTIFY, Integer(CoolTrayIcon1), WM_LBUTTONDOWN);</pre>
</li>
<li><b>I want to hide ALL windows, including dialogs and popup forms?</b><br>
Minimize the app. before calling HideMainForm, like this:
<pre>
Application.Minimize;
CoolTrayIcon1.HideMainForm;</pre>
</li>
<li><b>I want to override the "hide inactive tray icons" feature in WinXP?</b><br>
Calling the tray icon's Refresh method at regular intervals should do the trick (I think).
Anyway, it's not a good idea to override standard Windows behavior.
</li>
<li><b>When does the OnStartup event occur?</b><br>
The OnStartup event occurs before the owner form's OnCreate event.
</li>
<li><b>How do I show the balloon hint for less than 10 seconds?</b><br>
Set a timer to close the hint prematurely, using the HideBalloonHint method.
</li>
<li><b>How do I check if balloon hints are available (since they don't work in Win95 and Win98)?</b><br>
This should work in D4 and up:
<pre> uses ComCtrls;
if (GetComCtlVersion < ComCtlVersionIE4) or
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
(Win32MinorVersion <> 90)) then
// Balloon hints NOT supported</pre>
</li>
<li><b>Can I use the ballon hints without the tray icon?</b><br>
Take a look at the <a href='http://www.finances-ltd.narod.ru/' target='_blank'>zBalloon</a> component.
</li>
</ul>
<a name='Bugs'></a><h2>Known Bugs</h2>
<ul>
<!--
<li>Someone complains the component's hint will not show when CycleIcons is true.
This happens in WinME. I've been unable to reproduce this error, but please tell me if
you get it.
</li>
-->
<!--
<li>CoolTrayIcon has previously had a bug that prevented the user from logging off
unless he manually terminated the application CoolTrayIcon was used in.
This should be fixed by now, but if not, please tell me.
</li>
-->
<a name='XPBalloonTimeoutBug'></a>
<li>It appears there's a bug in WinXP (apparently both with SP 1 and SP 2 versions of
WinXP - possibly it's a general bug independent of service packs).
The bug makes the balloon hint appear for a random amount of time, no matter which timeout
value you specify in the call to ShowBalloonHint. I haven't verified this with Microsoft,
but it is not a problem in other Windows versions. Also, other tray icon components
suffer from this problem, so it is most likely an issue with WinXP. Please tell me if
you have this problem and you are not running WinXP SP 1 or SP 2.
</li>
<a name='2000BalloonEventsBug'></a>
<li>Some people report that the balloon hint events never fire. This is a Win2000 issue.
It doesn't appear to matter which service pack, Internet Explorer version, or comctl32.dll
version you use. This makes me suspect that Win2000 simply does not support these events.
</li>
<a name='NTServiceIconBug'></a>
<li>The tray icon may disappear in NT4 if it is used in an interactive service and
you log off, then log back on. I've been trying to fix this, but have so far been
unsuccessful.
An explanation for why the problem occurs can be found
<a href='http://support.microsoft.com/default.aspx?scid=kb;EN-US;q238721'>here</a>.
(BTW: some service packs, like SP6 seem to fix this problem).
</li>
<li>It is possible to disable balloon hints in Windows. If the balloon hint doesn't
display when it's supposed to (and if you're not using Win9x), you should verify this setting.
</li>
<li>Occasionally someone reports that an application using CoolTrayIcon prevents the
user from logging off or shutting down until he manually terminates the application.
I've more or less come to the conclusion that this is not a bug in CoolTrayIcon.
More likely it's a bug in some other third party component. At least it seems
people always get this error when they use CoolTrayIcon together with other
third party components. If you get this error try removing the other components
one at a time and see if that doesn't solve the problem (or even simpler - run my
demo app. and see if it has the problem). Afterwards, if you still have reason to
believe CoolTrayIcon is the problem, don't hesitate to tell me, but please perform
this simple test of exclusion first. (NOTE: It would seem various components in
Delphi's FastNet collection have this problem - independently of CoolTrayIcon).
<br><br>
Also make sure you use CoolTrayIcon correctly. If your app. "closes to tray"
(goes to the tray when the user clicks the form's close button) you need to handle
the WM_QUERYENDSESSION message manually, or the app. (unsurprisingly) won't terminate
when Windows shuts down. See the source in the CoolTrayTest demo for a solution.
</li>
<!--
<li>One person has reported that the default icon that is created when you add a
CoolTrayIcon component to your application is invalid. You get a runtime error:
"Error reading CoolTrayIcon1.Icon.Data: The parameter is incorrect.".
I've not had anyone else report this, but please tell me if it happens to you.
To get around it, simply assign an icon to the Icon property.
</li>
-->
<li>If you're using CoolTrayIcon with an ActionList (associated with popup menu items),
you'll find that actions based on TCustomAction (like TFileExit) don't execute if the
form that owns the tray icon is invisible. I'm guessing TCustomAction is designed to
behave like this. However, this problem doesn't occur with standard actions.
</li>
</ul>
<a name='Comments'></a><h2>Comments</h2>
The CoolTrayIcon component is <i>free for personal and commercial use</i>.
Feel free to use and improve it, but <i>please include all original files if you
redistribute the zip-file</i>. If you have any comments or corrections to the component
I would very much like to hear them. A lot of Delphi programmers have already told me
they like the component and use it, which is a huge boost for my ego. Thanks a lot,
guys - especially those of you who gave suggestions and pointed out the bugs.
</p>
<p>
If you use the component some credit somewhere in your application would be a nice gesture,
but it is not a requirement.
</p>
<p>
The component should work on any Windows platform (Win9x, ME, NT, 2000, XP, 2003, Vista).
If you experience any problems related to the operating system you use, please tell me.
Also, it should work in Delphi 3 and up (Delphi 2?) and C++Builder 3 and up.
Again, tell me if I'm wrong.
</p>
<p>
<a name='Service'></a><b>A word about services:</b> CoolTrayIcon does not require its
owner to be a form. This allows you to use it for non-windowed apps. such as services.
Some of the properties, methods, and events don't make sense without a form, but rather
than creating a superclass without these properties/methods/events I've simply let them
stay in CoolTrayIcon itself. You can use them in your service app., but they will not do
anything. I figured the component would be more flexible and easier to extend into
subclasses this way.
</p>
<p>
Get the latest version from <a href='http://subsimple.com/delphi.asp' target='_blank'>
http://subsimple.com/delphi.asp</a>.
</p>
<p>
Troels Jakobsen<br>
<a href='mailto:troels.jakobsen@gmail.com'>troels.jakobsen@gmail.com</a>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -