Advanced interactive service | ||
Step 4. Tray icon and interactive service. | ||
There are a lot of possible reasons that cause necessity of interactive user detection. One of possible reasons is the tray icon usage. When user logs off and the logs on again the shell looses information about previously shown icons in the tray. To restore them the application should wait until user logs on and re-create the tray icon. The questions about services and tray icon are very popular so I've included the answer into this example. On this step the tray icon will be added to our example and on the next step I'll show how to re-create it when interactive user logs on again. There are a lot of components that implement tray icon functionality and you can use any of them. As for me I prefer the TrxTrayIcon component to the RxLib components library1. It`s usage is very simple: drop it onto form and set event handlers - it should be activated when the form hides and deactivated when the form shows. The click on the tray icon should show the form again.
The resulting code should look like this (zip, 3kb). Test it. Reinstall the service if necessary, then start it and try to close the service form. The new icon appears in the tray zone, it is the icon of our example. Click on it and service form will appear again. So everything works fine but if you try to re-logon when the form is hidden then you won`t see our icon in tray after logon. It`s not restored automatically, and our example should do it itself. Necessary modifications are simple enough . They will be done on the next step. |
||
1. If you have not it yet then get it now! It is the best freeware components set I've ever seen. |
||
<< | Index | Step 1 | Step 2 | Step 3 | Step 4 | Step 5 | Conclusions | >> | ||
Add your comment | Read comments |
© 1998-2001
Alexey Dynnikov |