|Kixforms Class Library|
The following example demonstrates using the NotifyIcon class without a form. It implements a clock running in the system tray. A timer is used to update the clock every second. Hover the mouse over the icon to display the time. Double-click the tray icon to stop the program. This example uses the static DoEvents methods of the Application class to run in form-less mode.
Break On ; Imports System $System = CreateObject("Kixtart.System") ; Create the NotifyIcon. $NotifyIcon1 = $System.NotifyIcon() ; The Icon property sets the icon that will appear ; in the systray for this application. $NotifyIcon1.Icon = $System.BuiltinIcons(63) ; Clock ; The Text property sets the text that will be displayed, ; in a tooltip, when the mouse hovers over the systray icon. $NotifyIcon1.Text = "@DATE - @TIME" ; This will occur when the icon is double-clicked. $NotifyIcon1.OnDoubleClick = "DoubleClick()" ; Create a timer to update the tooltip clock every second. $Timer1 = $System.Timer() $Timer1.Interval = 1000 $Timer1.OnTick = "Tick()" $Timer1.Start() $NotifyIcon1.Visible = True While $NotifyIcon1.Visible $= Execute($System.Application.DoEvents) Loop Exit 1 Function Tick() $NotifyIcon1.Text = "@DATE - @TIME" EndFunction Function DoubleClick() ; Ask the user if they want to exit. If $System.MessageBox.Show("The date and time is @DATE @TIME. "+ "Would you like to exit this program now ?", "NotifyIcon Timer", $System.MessageBoxButtons.YesNo, $System.MessageBoxIcon.Question, $System.MessageBoxDefaultButton.Button2 ) = $System.DialogResult.Yes ; If yes, hide the icon which stops the DoEvents loop. $NotifyIcon1.Visible = 0 EndIf EndFunction
|The CHM file was converted to HTML by chm2web software.|