In the previous chapter I talked about the Windows tray, and I promised an example after events were covered. This Tray subclass is instantiated in the Open event of the RSS class: Dim myTrayItem as CustomTray myTrayItem = New CustomTray Me.AddTrayItem( myTrayItem ) To work with the tray, you need to subclass TrayItem. The Action event controls what happens when the user clicks the icon as it appears on the tray. This class doesn't really perform anything useful, and it is based on the example used in REALbasic's documentation, but it should be enough to show you how it works. The Action event gets passed an Integer that indicates what kind of action has taken placewhether the left or right mouse button was clicked, or if it was double-clicked. In this example, the main application Window will get maximized if the TrayItem is clicked with the left mouse button. If the right mouse button is clicked, a MenuItem pops up and provides an About option and an Exit option. Finally, if the TrayItem is double-clicked, the application becomes invisible if it is currently visible. If it is currently invisible, it will become visible.
|