System tray icon management function¶
system_tray_icon() |
Add, modify or delete an icon in the system tray |
SYNTAX
system_tray_icon(opcode, window_id, icon, tip)
Add an icon for the program to the system tray. The function can also be used to change or delete the icon.
opcode |
The icon operation to be performed. Possible values for opcode (defined in sculptor.h) are:
|
window_id |
The identifier of the window whose event function receives events from the system tray icon. This is normally wintask, but can be another window. |
icon |
The pathname of the icon image file (must have a .ico extension). Can be NULL, in which case the standard Sculptor icon is used. |
tip |
Text for the tip to be displayed when the mouse is moved over the icon. Can be NULL if a tip is not required. |
The system tray icon can generate a number of mouse click events. Note that a double event code is used to distinguish from the same event occurring in window window_id itself. The events that can be trapped are:
EV_SINGLE_CLICK |
A single left click on the icon. |
EV_DOUBLE_CLICK |
A double left click on the icon. |
EV_RIGHT_MOUSE_DOWN |
Right mouse button down on the icon. Not generally used. |
EV_RIGHT_MOUSE_UP |
Right mouse button up on the icon. This is the preferred event for responding to right mouse clicks. A likely use is to open a popup menu. |
Note that EV_RIGHT_MOUSE_UP and EV_RIGHT_MOUSE_DOWN are not default events and must be enabled for the window, e.g.
event_enable = EV_DEFAULT | EV_RIGHT_MOUSE_UP
The program $SCULPTOR/demo/misc/systray.q demonstrates this function.
EXAMPLE
!temp TrayTip,,a64 = "System tray tip"
!temp KeyIcon,,a80
tmp.KeyIcon = "$SCULPTOR/images/keys.ico"
system_tray_icon(STI_ADD, wintask, NULL, tmp.TrayTip) /* Add system tray icon using standard Sculptor icon */
...
system_tray_icon(STI_MODIFY, wintask, tmp.KeyIcon, tmp.TrayTip) /* Change icon */
system_tray_icon(STI_DELETE, wintask, NULL, NULL) /* Delete icon from system tray */
!function TaskWinEvent(EventCode, Object, XPos, YPos) { /* wintask event function */
!temp TrayEvent,,i4
if (EventCode & EV_SYSTEM_TRAY_ICON) {
TrayEvent = EventCode & ~EV_SYSTEM_TRAY_ICON
switch (TrayEvent) {
case == EV_SINGLE_CLICK:
info "System tray left mouse single click"
break
case == EV_DOUBLE_CLICK:
info "System tray left mouse double click"
break
case == EV_RIGHT_MOUSE_UP:
move cursor to XPos, YPos in wintask
open systray_popup /* open popup menu on right mouse click */
break
}
}
other event codes
return
}
RELATED TOPICS |