TMlTrayIcon

A tray icon component: it shows an icon in the Windows notification area with a context menu, balloon notifications and minimize-to-tray.

Category
Tray icon
Unit
uMlTrayIcon.pas
Inherits from
TComponent

Notes

  • Icon is the icon to show and IconVisible controls whether it appears.
  • PopupMenu attaches the context menu; with LeftPopup on, a left click opens it too.
  • With MinimizeToTray on, minimizing the form hides it into the tray and fires OnMinimizeToTray.
  • For a blinking alert (new mail, say) put several icons in IconList, turn on CycleIcons and set CycleInterval.
  • Separate events cover the balloon being shown, hidden, timing out and clicked, so you can react when the user clicks a notification.

Example

From the demo MlSkin.MainDemo.v3.0 (.dfm form file)

object mltrycn1: TMlTrayIcon
  CycleInterval = 0
  Icon.Data = {
  000001000900303010000100040068060000960000002020100001000400E802
  0000FE060000101010000100040028010000E60900003030000001000800A80E
  00000E0B00002020000001000800A8080000B619000010100000010008006805
  00005E2200003030000001002000A8250000C62700002020000001002000A810
  00006E4D0000101000000100200068040000165E000028000000300000006000
  0000010004000000000080040000000000000000000000000000000000000000
  000000008000008000000080800080000000800080008080000080808000C0C0
  C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000FF
  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFF
  FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  FFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FF
  FFFFFFFF78F8FFFFFFFFFFFFFFFFF8F88FFFFFFFFF0000FFFFFFFFFF77F7FFFF
  FFFFFFFFFFFFF7F7F7FFFFFFFF0000FFFFFFFFF7F7F7FFFFFFFFFFFFFFFFF7F7
  F7FFFFFFFF0000FFFFFFFFF787F7FFFFFFFFFFFFFFFFF887888FFFFFFF0000FF
  FFFFFF887F88FFF8FF87878FFFFFFF788F7FFFFFFF0000FFFFFFFF7F7F7FFFF7
  7788F887777FFF887F78FFFFFF0000FFFFFFF87F7F7FFF87FFFFFFFFF878FFF7
  78F7FFFFFF0000FFFFFFF7F8888FFF7FFFFFFFFFFFF7FFF788F8FFFFFF0000FF

Properties 16

NameTypeDefaultDescription
AboutTMlAboutInfoA design-time property: double-clicking it in the Object Inspector opens the MLSkin about box with the component version. It has no effect at run time and is not stored in the .dfm.
DesignPreviewBooleanFalseDesign-time preview: shows the tray icon while you are still in the IDE.
IconListTCustomImageListThe list of icons used for cycling, i.e. a blinking alert.
IconListTImageListThe list of icons used for cycling, i.e. a blinking alert.
CycleIconsBooleanFalseCycles through the icons in IconList to make the tray icon blink.
CycleIntervalCardinalInterval between icon changes, in milliseconds.
EnabledBooleanTrueWhether the control is usable; when off it greys out and stops responding.
HintTHintStringTooltip text shown when the mouse rests on the control.
ShowHintBooleanTrueWhether a tooltip appears when the mouse rests on the tray icon.
IconTIconThe icon shown in the tray.
IconVisibleBooleanFalseWhether the tray icon is visible.
IconIndexIntegerWhich icon from IconList is currently shown.
PopupMenuTPopupMenuThe menu shown when the tray icon is right-clicked.
LeftPopupBooleanFalseWhether a left click also opens the menu.
WantEnterExitEventsBooleanFalseWhether mouse enter and exit events over the tray icon are reported.
MinimizeToTrayBooleanFalseHides the form into the tray when it is minimized, so it leaves the taskbar.

Events 14

NameTypeDefaultDescription
OnClickTNotifyEventFires when the control is clicked.
OnDblClickTNotifyEventFires on a double click, usually used to show or hide the main form.
OnMouseDownTMouseEventFires when a mouse button goes down.
OnMouseUpTMouseEventFires when a mouse button is released.
OnMouseMoveTMouseMoveEventFires as the mouse moves over the control.
OnMouseEnterTNotifyEventFires when the mouse enters the control.
OnMouseExitTNotifyEventFires when the mouse leaves the tray icon; requires WantEnterExitEvents.
OnCycleTCycleEventFires each time the cycling icon advances.
OnBalloonHintShowTNotifyEventFires when the balloon notification appears.
OnBalloonHintHideTNotifyEventFires when the balloon notification is hidden.
OnBalloonHintTimeoutTNotifyEventFires when the balloon notification closes on its own after timing out.
OnBalloonHintClickTNotifyEventFires when the balloon notification is clicked, typically to open the matching window.
OnMinimizeToTrayTNotifyEventFires when the form is hidden into the tray.
OnStartupTStartupEventFires at startup, once the tray icon has been created.

Only the properties and events MLSkin adds are listed here. Standard VCL properties such as Align, Anchors, Font and OnClick are available too and behave exactly as on the stock controls.

Offline helpA PDF / CHM version is available for offline reading.