📄 cooltrayicon.html
字号:
</tr>
<tr>
<td class='name2' valign='top'>HideMainForm</td>
<td class='desc' valign='top'><i>This method applies only when the owner of the
tray icon component is a form.</i><br>
<span class='declaration'>procedure HideMainForm;</span><br>
Hides the main form.</td>
<td class='default' valign='top'><br></td>
</tr>
<tr>
<td class='name2' valign='top'>ShowTaskbarIcon</td>
<td class='desc' valign='top'><i>This method applies only when the owner of the
tray icon component is a form.</i><br>
<span class='declaration'>procedure ShowTaskbarIcon;</span><br>
Shows the application's taskbar icon (not to be confused with the tray icon).<br>
<td class='default' valign='top'><br></td>
</tr>
<tr>
<td class='name2' valign='top'>HideTaskbarIcon</td>
<td class='desc' valign='top'><i>This method applies only when the owner of the
tray icon component is a form.</i><br>
<span class='declaration'>procedure HideTaskbarIcon;</span><br>
Hides the application's taskbar icon (not to be confused with the tray icon).<br>
<b>NOTE:</b> If you display a child form the taskbar icon will become visible again
automatically. This is standard Windows behavior.</td>
<td class='default' valign='top'><br></td>
</tr>
</table>
<a name='Events'></a><h2>Events</h2>
<table cellpadding='2' cellspacing='2' border='0' width='100%'>
<tr>
<td class='name' valign='top'>OnClick</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Works like the similar event for window controls.<br>
<b>NOTE:</b> The Click event corresponds to a MouseDown followed by a MouseUp.
If no DblClick event is assigned the Click event fires immediately (ie. after
the MouseUp). Otherwise it will wait for a small period of time to see if the
user clicks again, in which case we have a double click. If no DblClick event
is assigned a double click will actually cause the Click event to fire.
This is intentional.</td>
</tr>
<tr>
<td class='name' valign='top'>OnDblClick</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Works like the similar event for window controls.</td>
</tr>
<tr>
<td class='name' valign='top'>OnMouseDown</td>
<td class='desc' valign='top'><span class='declaration'>TMouseEvent;</span><br>
Works like the similar event for window controls.</td>
</tr>
<tr>
<td class='name' valign='top'>OnMouseUp</td>
<td class='desc' valign='top'><span class='declaration'>TMouseEvent;</span><br>
Works like the similar event for window controls.</td>
</tr>
<tr>
<td class='name' valign='top'>OnMouseMove</td>
<td class='desc' valign='top'><span class='declaration'>TMouseMoveEvent;</span><br>
Works like the similar event for window controls.</td>
</tr>
<tr>
<td class='name' valign='top'>OnMouseEnter</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired after the cursor enters the tray icon. Requires
the WantEnterExitEvents property to be true.</td>
</tr>
<tr>
<td class='name' valign='top'>OnMouseExit</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired after the cursor leaves the tray icon. Requires
the WantEnterExitEvents property to be true.</td>
</tr>
<tr>
<td class='name' valign='top'>OnCycle</td>
<td class='desc' valign='top'><span class='declaration'>procedure(Sender: TObject; NextIndex: Integer) of object;</span><br>
Fired just before the icon changes via CycleIcons.
Returns the next index in the assigned imagelist.</td>
</tr>
<tr>
<td class='name' valign='top'>OnBalloonHintShow</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired after the balloon hint shows itself. This doesn't have to occur immediately
after you call the ShowBalloonHint method. In case another application is already
showing a balloon hint, your application must wait for it to close before it gets
to show the balloon hint itself. This event will tell you when it has shown the hint.</td>
</tr>
<tr>
<td class='name' valign='top'>OnBalloonHintHide</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired after the balloon hint closes because another application needs to show a
balloon hint, or because you called either the ShowBalloonHint or the
HideBalloonHint method.</td>
</tr>
<tr>
<td class='name' valign='top'>OnBalloonHintTimeout</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired after the balloon hint closes because it timed out.</td>
</tr>
<tr>
<td class='name' valign='top'>OnBalloonHintClick</td>
<td class='desc' valign='top'><span class='declaration'>TNotifyEvent;</span><br>
Fired when the user clicks the balloon hint.</td>
</tr>
<tr>
<td class='name2' valign='top'>OnMinimizeToTray</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'>TNotifyEvent;</span><br>
Fired when the application is about to minimize to tray. Useful if you want to do special
processing, like animation effects, when the app. gets minimized (hidden).<br>
<b>NOTE:</b> MinimizeToTray must be true for this event to fire.</td>
</tr>
<tr>
<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 and set IconVisible to true.
See also the <a href='#Bugs'>bugs</a> section 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>
I don't know exactly how to do this, but try refreshing the tray icon at regular
intervals. 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>
</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>
-->
<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>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>
<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>
</ul>
<a name='Comments'></a><h2>Comments</h2>
The CoolTrayIcon component is <i>freeware</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 app. 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).
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://www3.brinkster.com/troels/delphi.asp' target='_blank'>
http://www3.brinkster.com/troels/delphi.asp</a>.
</p>
<p>
Troels Jakobsen<br>
<a href='mailto:delphiuser@get2net.dk'>delphiuser@get2net.dk</a>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -