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
AboutTMlAboutInfo—A 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.
IconListTCustomImageList—The list of icons used for cycling, i.e. a blinking alert.
IconListTImageList—The list of icons used for cycling, i.e. a blinking alert.
CycleIconsBooleanFalseCycles through the icons in IconList to make the tray icon blink.
CycleIntervalCardinal—Interval between icon changes, in milliseconds.
EnabledBooleanTrueWhether the control is usable; when off it greys out and stops responding.
HintTHintString—Tooltip text shown when the mouse rests on the control.
ShowHintBooleanTrueWhether a tooltip appears when the mouse rests on the tray icon.
IconTIcon—The icon shown in the tray.
IconVisibleBooleanFalseWhether the tray icon is visible.
IconIndexInteger—Which icon from IconList is currently shown.
PopupMenuTPopupMenu—The 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
OnClickTNotifyEvent—Fires when the control is clicked.
OnDblClickTNotifyEvent—Fires on a double click, usually used to show or hide the main form.
OnMouseDownTMouseEvent—Fires when a mouse button goes down.
OnMouseUpTMouseEvent—Fires when a mouse button is released.
OnMouseMoveTMouseMoveEvent—Fires as the mouse moves over the control.
OnMouseEnterTNotifyEvent—Fires when the mouse enters the control.
OnMouseExitTNotifyEvent—Fires when the mouse leaves the tray icon; requires WantEnterExitEvents.
OnCycleTCycleEvent—Fires each time the cycling icon advances.
OnBalloonHintShowTNotifyEvent—Fires when the balloon notification appears.
OnBalloonHintHideTNotifyEvent—Fires when the balloon notification is hidden.
OnBalloonHintTimeoutTNotifyEvent—Fires when the balloon notification closes on its own after timing out.
OnBalloonHintClickTNotifyEvent—Fires when the balloon notification is clicked, typically to open the matching window.
OnMinimizeToTrayTNotifyEvent—Fires when the form is hidden into the tray.
OnStartupTStartupEvent—Fires 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.