The System Tray Object
By Matt Galanto

WARNING: This object will not work properly if you add more than one of them to a frame (this includes any sub-apps that may be included in the frame). You shouldn't need to do that, though, anyway. I've made things such that one object per frame should be plenty. If you do try to do so, however, extra objects will be destroyed and an error will be generated.

Index

Disclaimer

The author of this extension makes no claims concerning the fitness of this extension for any purpose whatsoever, and makes no gurantees, written or implied, of its level of security and safety to authors or to end users in any respect. You agree to use this extension at your own risk and to hold the author harmless in any event.

The Basics

The System Tray Object allows you to put custom icons into the Windows system tray. You can have as many icons down there as Windows will allow you to have (I'm not sure what limit Windows has). You specify the maximum number of icons in the set-up dialogue box. You're required to have at least one icon. You can also load in various icon images. These are stored in memory so that you do not have to keep reading from file each time you want to change an icon's image. You specify the maximum number of icon images you will load at one time in the set-up dialogue box. You're not required to have any icon images.

You can make this object global if you'd like (just check the checkbox in the setup dialogue box). This global doesn't work like that of other objects. In MMF (edit-time), all of the objects are still independent of one another. At run-time, the first time a System Tray object with global enabled is created, the data for that object will override the data of all subsequent objects enocuntered. Also, if you have a global object put icons in the system tray, those will remain until the application is closed or until you remove them yourself with the "Remove Icon from Tray" action.

Conditions

Is an Icon Displayed in Tray?
You can use this condition to test whether or not a specific icon is (or if any iconsare) currently being shown in the system tray.

User Clicks an Icon
Events with this condition are triggered when the specified mouse click happens on a specific icon (or on any icon). The ID of the icon that received the click is stored and can be retrieved with the "Get ID of Icon Associated with Last Event" expression.

User Releases Left-Click on Icon
Events with this condition are triggered when the left-click is released over a specific icon (or on any icon). The ID of the icon that received the release is stored and can be retrieved with the "Get ID of Icon Associated with Last Event" expression.

User Releases Middle-Click on Icon
Events with this condition are triggered when the middle-click is released over a specific icon (or on any icon). The ID of the icon that received the release is stored and can be retrieved with the "Get ID of Icon Associated with Last Event" expression.

User Releases Right-Click on Icon
Events with this condition are triggered when the right-click is released over a specific icon (or on any icon). The ID of the icon that received the release is stored and can be retrieved with the "Get ID of Icon Associated with Last Event" expression.

On Minimize Command
Events with this condition are triggered when a minimize command is sent to the main window.

On Maximize Command
Events with this condition are triggered when a maximize command is sent to the main window.

On Close Command
Events with this condition are triggered when a close command is sent to the main window.

On Task Bar Command
Events with this condition are triggered when a task bar command (user left-clicks on window in task bar) is sent to the main window.

On Specific System Command
Events with this condition are triggered when the specified system command is sent to the main window.

Has an Error Occured?
Events with this condition are triggered as soon as the object encounters an error. The error message is available to events with this condition and can be retrieved with the "Get Current Error Message" expression.

Actions

Show Icon in Tray
This action will show the specified icon (or all icons) in the system tray.

Remove Icon from Tray
This action will remove the specified icon (or all icons) from the system tray.

Load Icon Image from File
This action allows you to load a specified number of icon images from an ICO file into the object's icon image storage locations. You specify the first icon image storage location to use, the first icon from the ICO file to load, and the maximum number of icon images to load.

Load Icon Image from EXE or DLL File
This action allows you to load a specified number of pairs of icon images (in these files, icons come as pairs of icons where one is mall and the other is large) from an EXE or DLL file into the object's icon image storage locations. You specify the first icon image storage location to use, the first icon pair from the file to load, and the maximum number of pairs of icon images to load. The Fomat Number determines how the pairs are stored in the object:

Load Small Icon from Application
This action allows you to store your application's current small icon into one of your icon images.

Load Big Icon from Application
This action allows you to store your application's current big icon into one of your icon images.

Change Application's Small Icon
This action allows you to change your application's small icon to one of your icon images.

Change Application's Big Icon
This action allows you to change your application's big icon to one of your icon images.

Reset Application's Small Icon
This action sets your application's small icon back to it's original icon.

Reset Application's Big Icon
This action sets your application's big icon back to it's original icon.

Change Icon Image

Show Tool Tip
This action tells the specified icon (or all icons) to display a tool tip when the mouse hovers over it (or them).

Hide Tool Tip (broke)
This action tells the specified icon (or all icons) not to display a tool tip when the mouse hovers over it (or them)... it doesn't work, though.

Set Tool Tip
This action sets the tool tip for the specified icon (or for all icons) to the specified text. If the text is longer than 63 characters, it will be truncated.

Halt Minimize Command
This action tells the object to halt the current minimize command so that the main window does not receive the command.

Halt Maximize Command
This action tells the object to halt the current maximize command so that the main window does not receive the command.

Halt Close Command
This action tells the object to halt the current close command so that the main window does not receive the command.

Halt Task Bar Command
This action tells the object to halt the current task bar command (user left-clicks on window in task bar) so that the main window does not receive the command.

Halt this System Command
This action tells the object to halt the current system command (the one specified in the "On Specific System Command" condition) so that the main window does not receive the command.

Expressions

Get ID of Icon Associated with Last Event
GetEventIcon("System Tray Object")
Returns the ID of the icon associated with the last mouse-click event.

Get Current Error Message
GetCurrentError$("System Tray Object")
Returns the current error message. Meaningful messages are only available to events with the "On Error" condition.