Creates an Ocx TrayIcon control 'in' the current active form, window, or dialog.
Ocx TrayIcon name [= text$] [, id%], [ x, y, w, h] [, style%]
text$:control text
id%:control identifier
x, y, w, h:iexp
style%:the control styles
TrayIcon creates a taskbar notification icon. It places an icon of your choice into the System Tray that most often will display a ToolTip of your choice when the mouse is rested over it, will restore the application when clicked, and will display a popup menu when right-clicked.
Icon | Index | Name | Parent | Tag | ToolTipText | Visible
MBDown | MBUp | MBDblClick | MMove
These events occur when the user presses (MBDown) or releases (MBUp) a mouse button. The Button% argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively.
Sub TrayIcon_MBDblClick(Button%)
Occurs when the user presses and releases a mouse button, then presses and releases it again over an object. The Button% argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively.
Occurs when the user moves the mouse over the tray icon.
OpenW 1
Ocx TrayIcon tic1
tic1.Icon = CreatePicture(LoadIcon(Null, IDI_APPLICATION))
tic1.ToolTipText = "Demo Application"
tic1.Visible = True
Do
Sleep
Until Me Is Nothing
'
Sub Win_1_Moved
If Win_1.WindowState = basMinimized _
Win_1.Hide
Sub tic1_MBDown(Button%)
Debug.Trace Button%
If Button% = 2
Local ret%
DoEvents
ret% = PopUp("&Open|-|E&xit", 0, 0, -3)
Switch ret%
Case 0 ' Restore / Open
If Win_1.WindowState = basMinimized || _
Win_1.Visible = False Then Win_1.Restore
Case 2 ' Exit
PostMessage Win_1.hWnd, WM_CLOSE, 0, 0
EndSwitch
EndIf
End Sub
Sub tic1_MBDblClick(Button%)
Debug.Trace Button%
If Button% = 1 Then _
PostMessage Me.hWnd, WM_CLOSE, 0, 0
End Sub
Sub tic1_MBUp(Button%)
Debug.Trace Button%
End Sub
To make PopUp (TrackPopupMenu API) work properly in the context of a tray, you must first call SetForegroundWindow on the window that owns the popup. Otherwise, the menu will not disappear when the user presses Escape or clicks the mouse outside the menu. To find out more, search for Q135788 in MSDN. "This behavior is by design."
Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, ListView, MonthView, Option, ProgressBar, RichEdit, Scroll, Slider, StatusBar, TabStrip, TextBox, Timer, TreeView, UpDown
{Created by Sjouke Hamstra; Last updated: 07/10/2017 by James Gaite}