Minimizing a window to the System Tray

by Rob den Boer

The attached example procedure creates a Progress window. When the window is minimized, it shows an icon in the system tray (that's in the corner of the taskbar, next to the clock). Features of this tray icon are:
* on left mouse click, the window is restored
* on right mouse click a popup-menu appears (as shown on picture)
* the icon has a tooltip
* the icon can be animated

Installing the example

Download systray.zip (12 kilobyte) and unzip it to a directory in your PROPATH.
The example was created using the AppBuilder in Progress 9, it will have to be rewritten to run in Progress 8. The example uses the PSTimer ActiveX control and also the MsgBlaster control.

How it works

Run procedure ip-systray-init when the window gets initialized.

This procedure takes three input parameters: a unique ID for the icon, a comma-separated list of .ico filenames and a tooltip string.

Procedure ip-systray-init shows the icon and sets the MsgBlaster OCX to pass mouse-messages from the icon on to the Progress procedure. The event-handler for the MsgBlaster contains the code for showing the popup-menu (on mouse-menu-click) or for restoring the window (on mouse-select-click).
The icon can be animated only by using a PSTimer control: on pstimer.tick simply run ip-next-icon. This procedure fetches the next name from a comma-separated list of .ico filenames and updates the taskbar icon. You may refine this procedure by using an Imagelist control.
Don't forget to call procedure ip-systray-exit when the program ends.

API-procedures used in this example are listed here to be included in the search index: 
PROCEDURE SHGetFileInfoA    EXTERNAL "shell32"
PROCEDURE Shell_NotifyIconA EXTERNAL "shell32"
PROCEDURE SendMessageA      EXTERNAL "user32"

More Progress examples available on the homepage of Rob den Boer: http:home.hccnet.nl/rc.den.boer/progress/index.html

Attachments

systray.zip : (by Rob den Boer, improved by Peter Kiss)


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Make a balloon notification with OpenEdge

The attached code allows to make a balloon notification in Windows' notification area. No OCX involved.

Usage is simple, just use something like:
notifyIcon(
SEARCH("C:\Progress\OpenEdge\gui\adeicon\progress.ico")
, {&NIF_ICON} /* show the icon */
+ {&NIF_INFO} /* show the balloon */
+ {&NIF_TIP} /* show the tool tip */
,"Coucou" /* tool tip */
,"Coucou" /* balloon contents */
,"Coucou" /* balloon title */
,{&NIIF_WARNING} /* balloon icon */
).

See the code for the constants definition.

PS: Works in 11.5 32 bits; could not find why in 11.6 64 bits it does not. All the Windows API say "success" however the icon and balloon do not show.

PPS: no context menu nor action can be performed; this would need something like the MsgBlaster OCX to be able to receive the Windows messages.


AttachmentSize
winnotify.i8.33 KB