Its simple to add code to your Clarion Application and you too can have icons in the System Tray. The concept is sound and simple to do in windows yourself! Microsoft has all the tools you need in their Windows API to help you extend your clarion apps by yourself...
Here is a starting point...
To place icons in the system tray Win API Shell Notify Icon Function does all the work for you - providing an interface to add, change and remove icons from the system tray. (See example code below for implementation)
If you want animated icons in the System Tray you will need to setup a timer event and change the icons to create the effect of animated gif.
If you want to capture mouse events on the icon you will need to subclass the windows event handlers of the parent clarion window. (See example code below for implementation)
Once subclassed you can intercept messages to the window and handle them appropriately....like left mouse clicks on the icon in the system tray. You can also handle windows shutdown grace fully! When windows shuts down it sends a system exit message to all applications running...You can then shutdown your application properly and avoid those Application is still active messages....(See example code below for implementation)
In further articles I will explain Balloon tips and other issues surrounding icons and windows services.
Learning through doing is an excellent way to become a better programmer but not necessarily a better developer. Having said that a good mix of both skill sets is essential. I believe that any experience a good or painful one helps us grow.
Here are some example pieces of code that I use in some of my personal applications at home.
Example Code: (Subclassing Windows Event handlers)
After opening window do the following....
SubClassWindows ROUTINE
SavedProc1 = Window{PROP:WndProc}
Window{PROP:WndProc} = ADDRESS(SubFunc1)
SavedProc2 = Window{PROP:ClientWndProc}
Window{PROP:ClientWndProc} = ADDRESS(SubFunc2)
DO SetupNID
Once subclassed you can intercept messages to the window and handle them appropriately....like left mouse clicks on the icon in the system tray. You can also handle windows shutdown grace fully!
Example Code: (Subclass WndProc)
Some code adapted from a clarionmag article some years ago.
SubFunc1 FUNCTION (hWnd,wMsg,wP,lP) ! Declare Procedure
WM_QUERYENDSESSION Equate(00011H)
WM_ENDSESSION Equate(00016H)
CODE ! Begin processed code
CASE wMsg
IF WM_QUERYENDSESSION
RETURN(TRUE)
OF WM_ENDSESSION
POST(EVENT:CloseWindow,,MainThread) RETURN(TRUE)
OF EVENT:NIM
CASE BAND(lP, 0FFFFh) OF LOC:WM_LBUTTONUP ! Left mouse click POST(Event:NIM:MouseLeft,,MainThread) OF LOC:WM_LBUTTONDBLCLK ! Left mouse double click POST(Event:NIM:MouseLeft2,,MainThread) OF LOC:WM_RBUTTONDOWN ! Right mouse click - pressed
OF LOC:WM_RBUTTONUP ! Right mouse click - released POST(Event:NIM:MouseRight,,MainThread) OF LOC:WM_RBUTTONDBLCLK ! Right mouse double click POST(Event:NIM:MouseRight2,,MainThread) END
RETURN(0)
ELSE
! Pass the unhandled event and it's params on to the previous window procedure in the chain
RETURN(CallWindowProc(SavedProc1,hWnd,wMsg,wP,lP))
END
Example Code:(Icons in the Tray)
Shell Notify Icon does all the work for you here!!!!
SetupNID ROUTINE
TrayCString = 'generic_ico'
NID:cbSize = SIZE(NotifyIconData)
NID:hWnd = Window{Prop:Handle}
NID:uID = 100
NID:uFlags = NIF_ICON + NIF_MESSAGE + NIF_TIP
NID:uCBmessage = Event:NIM
!your defined message to capture in the parent clarion window
NID:hIcon = LoadIcon(SYSTEM{PROP:APPINSTANCE},ADDRESS(TrayCString))
NID:ToolTip = CLIP(SVC:ToolTip) & CHR(0)
DO AddIconToTray
AddIconToTray ROUTINE
IF Shell_NotifyIcon(NIM_ADD, ADDRESS(NotifyIconData)) THEN
Icon change success fult
END
ChangeIconInTray ROUTINE
IF Shell_NotifyIcon(NIM_MODIFY, ADDRESS(NotifyIconData)) THEN
!Suceeded
ELSE
!Failed
END
RemoveIconFromTray ROUTINE
IF Shell_NotifyIcon(NIM_DELETE, ADDRESS(NotifyIconData)) THEN
Removed
END
A lot of this code would be easily adaptable to your own reusable class...enjoy learning...