<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../style.css">
<title>
Gambas Documentation - TrayIcon
 (gb.qt)</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../../help+en"><img class="flag" alt="Home" border="0" src="../../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../gb.qt+en">Up</a>&nbsp;
<a href="toolbutton/_new+en">Previous</a>&nbsp;
<a href="trayicon/_dblclick+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
TrayIcon
 (gb.qt)</h1>
<img src="../../../image/control/+trayicon+en" alt="TrayIcon">
<p>
This class implements a tray icon.
<p>
<div class="black"><font size="-2"><b>Symbols</b></font></div>
<div class="border">
This class is <a class="none" href="trayicon/_new+en">creatable</a>.<br>
<hr><table class="none" cellspacing="0" cellpadding="0">
<tr>
<td align=left><b>Properties</b></td><td width="32">&nbsp;</td>
<td align=left><b>Methods</b></td><td width="32">&nbsp;</td>
<td align=left><b>Events</b></td><td width="32">&nbsp;</td>
</tr>
<tr valign=top>
<td>
<a class="none" href="trayicon/h+en">H</a>&nbsp;&nbsp; <a class="none" href="trayicon/height+en">Height</a>&nbsp;&nbsp; <a class="none" href="trayicon/icon+en">Icon</a>&nbsp;&nbsp; <a class="none" href="trayicon/picture+en">Picture</a>&nbsp;&nbsp; <a class="none" href="trayicon/screenx+en">ScreenX</a>&nbsp;&nbsp; <a class="none" href="trayicon/screeny+en">ScreenY</a>&nbsp;&nbsp; <a class="none" href="trayicon/tag+en">Tag</a>&nbsp;&nbsp; <a class="none" href="trayicon/text+en">Text</a>&nbsp;&nbsp; <a class="none" href="trayicon/tooltip+en">Tooltip</a>&nbsp;&nbsp; <a class="none" href="trayicon/visible+en">Visible</a>&nbsp;&nbsp; <a class="none" href="trayicon/w+en">W</a>&nbsp;&nbsp; <a class="none" href="trayicon/width+en">Width</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
<td>
<a class="none" href="trayicon/hide+en">Hide</a>&nbsp;&nbsp; <a class="none" href="trayicon/show+en">Show</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
<td>
<a class="none" href="trayicon/_dblclick+en">DblClick</a>&nbsp;&nbsp; <a class="none" href="trayicon/_enter+en">Enter</a>&nbsp;&nbsp; <a class="none" href="trayicon/_gotfocus+en">GotFocus</a>&nbsp;&nbsp; <a class="none" href="trayicon/_leave+en">Leave</a>&nbsp;&nbsp; <a class="none" href="trayicon/_lostfocus+en">LostFocus</a>&nbsp;&nbsp; <a class="none" href="trayicon/_menu+en">Menu</a>&nbsp;&nbsp; <a class="none" href="trayicon/_mousedown+en">MouseDown</a>&nbsp;&nbsp; <a class="none" href="trayicon/_mousemove+en">MouseMove</a>&nbsp;&nbsp; <a class="none" href="trayicon/_mouseup+en">MouseUp</a>&nbsp;&nbsp; <a class="none" href="trayicon/_mousewheel+en">MouseWheel</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
</tr>
</table>
</div><p>

<div class="box">
A <a href="trayicon+en">TrayIcon</a> typically responds to either the <a href="trayicon/_dblclick+en">DblClick</a> event to initiate a preset action (for instance to restore a minimized <a href="form+en">Form</a>) or the <a href="trayicon/_menu+en">Menu</a> event to
produce a popup <a href="menu+en">Menu</a>.  My observations are that creating a popup on the fly is troublesome
and that it is best to create a <i>&quot;stub&quot;</i> <a href="menu+en">Menu</a> in your <a href="form+en">Form</a> and set that menu's <a href="control/enabled+en">Enabled</a> property to <a href="../../lang/false+en">FALSE</a> and its <a href="control/visible+en">Visible</a> property to <a href="../../lang/false+en">FALSE</a>.  The you can add and remove items with ease to match the current state of the
application in the available popup menu options.
<p>
You can also use the <a href="control/tooltip+en">ToolTip</a> property of the <a href="trayicon+en">TrayIcon</a> to display application status
when such behavior is appropriate to your particular project.
<p>
You create a hidden invisible menu in your main form called <b>TrayMenu</b> whose <a href="../../def/identifier+en">identifier</a>
is also <b>TrayMenu</b>.  You give your TrayIcon control the <a href="../../def/identifier+en">identifier</a> <b>MyTrayIcon</b>.  You want
to create a context menu for your <a href="trayicon+en">TrayIcon</a>.  For this example <b>TrayMenu</b> and <b>MyTrayIcon</b>
need to be in the same <a href="form+en">Form</a>.
<p>
In the form containing <b>MyTrayIcon</b> and <b>TrayMenu</b>:
<pre class="code">Public Sub MyTrayIcon_Menu()

    TrayMenu.Popup()

End
</pre><p><p>
There may be stability issues with the use of this control at present.
<p>
In my attempt to use this control I've had the KDE panel segfault (crash) on several
occasions after a number of edit/run cycles of a <a href="../../def/gambas+en">Gambas</a> project using a TrayIcon in the
startup form.
<p>
--<b>Brian Jack 2006.01.29 02:28 PST</b>
<p>
Can you be more precise about what is troublesome in creating a popup menu?
<p>
--<b>Benoit Minisini 2006.01.29 22:59 CET</b>
<p>
If you use the <a href="form+en">Form</a> as a parent and create the popup <a href="menu+en">Menu</a> you need to add a bunch of bookkeeping to make sure the menu is only created once otherwise a menubar with several copies of the popup menu results.  Since I do not believe there is a way to delete objects at this time it is just as well to make a persistent <a href="menu+en">Menu</a> within the <a href="form+en">Form</a> in the <u>IDE Menu Editor</u> then call it up from the TrayIcon's <a href="menu+en">Menu</a> event.
<p>
--<b>Brian Jack 2006.02.02 09:49 PST</b>
</div>

</div>
</body>
</html>

