System Tray help

Function help:

Real API_Systray_Add (Real Window Handle, String Tip Text, Real System Tray Number);

This function adds a new icon to the system tray.

If you give each icon a different number you can assign multiple icons to a window.

Return value:
Returns true (1) when succesful, or false (0) otherwise.

Real API_Systray_Remove (Real Window Handle, Real System Tray Number);

This function removes an icon from the system tray.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Systray_SetTip (Real Window Handle, Real System Tray Number, String Text);

This function changes the tip text of a systray icon.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Systray_SetIcon (Real Window Handle, Real System Tray Number, Real Icon Resource Handle);

This function changes the icon of a systray icon.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Systray_PrepareBalloon (String Title, String Text, Real Time Out In Miliseconds, Real Flags);

This function prepares a call to API_Systray_SetBalloon.

Flags:
NIIF_ERROR
An error icon.
NIIF_INFO
An information icon.
NIIF_NONE
No icon.
NIIF_USER
Windows XP Service Pack 2 (SP2) and later. Use the currently set system tray icon in the balloon.
NIIF_WARNING
A warning icon.
NIIF_NOSOUND
Do not play the associated sound. Applies only to balloon ToolTips.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Systray_SetBalloon (Real Window Handle, Real System Tray Number);

This function shows a ballon above the system tray using the settings defined in a previous API_Systray_PrepareBalloon call.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
System Tray Checking

When a system tray icon action occurs, API_Check_Command is set to a value of WM_ICONNOTIFY+Icon Number.
For example icon number 0 sends WM_ICONNOTIFY, icon number 1 sends WM_ICONNOTIFY+1, and go on ...

is
Command = API_Check_Command (1); // Check the command for check handle 1

if (Command == WM_ICONNOTIFY) // Tray Icon 0 sends a command
{
Second = API_Check_SecondaryCommand (1); // Check the kind of action
if (Second == WM_RBUTTONDOWN) // The right button is down
if (show_menu ("Exit",-1) == 0) // Show a tray menu
game_end (); // The user has choosen to exit
}

Secondary Check Commands:

NIN_BALLOONTIMEOUT
- The balloon timeout hit
NIN_BALLOONUSERCLICK - The user clicked the balloon

The mouse click commands are also supported.



Example code:

is
API_Systray_Add (Win,"Max WinAPI 2",0); // Create the icon

API_Systray_PrepareBalloon ("Max WinAPI 2","Hi!

Welcome to Max WinAPI 2!",100,NIIF_USER); // Set balloon settings

API_Systray_SetBalloon (Win,0); // Display the balloon

Return to help index