Current test code
`ICON constants
#constant IMAGE_BITMAP 0
#constant IMAGE_ICON 1
#constant IMAGE_CURSOR 2
#constant LR_CREATEDIBSECTION 0x00002000
#constant LR_DEFAULTCOLOR 0x00000000
#constant LR_DEFAULTSIZE 0x00000040
#constant LR_LOADFROMFILE 0x00000010
#constant LR_LOADMAP3COLORS 0x00001000
#constant LR_LOADTRANSPARENT 0x00000020
#constant LR_MONOCHROME 0x00000001
#constant LR_SHARED 0x00008000
#constant LR_VGACOLOR 0x00000080
`Message types used with Shell_NotifyIcon
#constant NIM_ADD 0x00000000
#constant NIM_MODIFY 0x00000001
#constant NIM_DELETE 0x00000002
#constant NIM_SETFOCUS 0x00000003
#constant NIM_SETVERSION 0x00000004
`NOTIFYICONDATA flags
#constant NIF_MESSAGE 0x00000001
#constant NIF_ICON 0x00000002
#constant NIF_TIP 0x00000004
#constant NIF_STATE 0x00000008
#constant NIF_INFO 0x00000010
#constant NIF_GUID 0x00000020
#constant NIF_REALTIME 0x00000040
#constant NIF_SHOWTIP 0x00000080
`NOTIFYICONDATA states
#constant NIS_HIDDEN 0x00000001
#constant NIS_SHAREDICON 0x00000002
`NOTIFYICONDATA versions
#constant NOTIFYICON_LEGACY 0x00000000
#constant NOTIFYICON_VERSION 0x00000003
#constant NOTIFYICON_VERSION_4 0x00000004
`NOTIFYICONDATA info flags
#constant NIIF_NONE 0x00000000
#constant NIIF_INFO 0x00000001
#constant NIIF_WARNING 0x00000002
#constant NIIF_ERROR 0x00000003
#constant NIIF_USER 0x00000004
#constant NIIF_NOSOUND 0x00000010
#constant NIIF_LARGE_ICON 0x00000020
#constant NIIF_RESPECT_QUIET_TIME 0x00000080
#constant NIIF_ICON_MASK 0x0000000f
`Offsets for NOTIFYICONDATA memory structure
`https://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx
#constant NID__SIZEOF 508
#constant NID_CBSIZE 0
#constant NID_HWND 4
#constant NID_UID 8
#constant NID_UFLAGS 12
#constant NID_UCALLBACKMESSAGE 16
#constant NID_HICON 20
#constant NID_SZTIP 24
#constant NID_DWSTATE 152
#constant NID_DWSTATEMASK 156
#constant NID_SZINFO 160
#constant NID_UNION_TIMEOUT_VERSION 416
#constant NID_SZINFOTITLE 420
#constant NID_DWINFOFLAGS 484
#constant NID_GUIDITEM 488
#constant NID_HBALLOONICON 504
`User-defined messages
#constant _WM_APP 0x8000
`Load libraries
#constant USER32 1
#constant SHELL32 4
load dll "user32.dll" ,USER32
load dll "shell32.dll",SHELL32
icon$="iconimage.ico"
hIcon = call dll(USER32, "LoadImageA", 0, get string ptr(icon$), IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
hwnd = get dbpro window()
`Create NOTIFYICONDATA structure
pNid = alloc zeroed(NID__SIZEOF)
poke dword pNid + NID_CBSIZE , NID__SIZEOF `Set size of structure
poke dword pNid + NID_HWND , hwnd `Handle window receive tray icon messages (DBPRO window)
poke dword pNid + NID_UID , 1 `User message Identifier
poke dword pNid + NID_UFLAGS , NIF_MESSAGE + NIF_ICON + NIF_TIP + NIF_SHOWTIP
poke dword pNid + NID_UCALLBACKMESSAGE , _WM_APP + 1
poke dword pNid + NID_HICON , hIcon `Handle to tray icon to use
poke string pNid + NID_SZTIP , "DB SysTray", 127
poke dword pNid + NID_DWSTATE , 0 `Icon state (hidden, shared) not used
poke dword pNid + NID_DWSTATEMASK , 0
poke string pNid + NID_SZINFO , "", 255 `Text to display in balloon notification. Up to 255 char
poke dword pNid + NID_UNION_TIMEOUT_VERSION, NOTIFYICON_VERSION_4 `Vista and later
poke string pNid + NID_SZINFOTITLE , "", 63 `Balloon notification title (Up to 63 characters)
poke dword pNid + NID_DWINFOFLAGS , NIIF_USER `Balloon notification behaviour flags
poke dword pNid + NID_HBALLOONICON , hIcon `Handle to balloon notification icon (same as tray)
success = call dll(SHELL32, "Shell_NotifyIconA", NIM_ADD, pNid) `Add tray icon
print success
`Emulate message structure
#constant MSG_size 28
#constant MSG_hwnd 0 `dword
#constant MSG_message 4 `dword
#constant MSG_wParam 8 `dword
#constant MSG_lParam 12 `dword
#constant MSG_time 16 `dword
#constant MSG_ptX 20 `integer
#constant MSG_ptY 24 `integer
msgPtr=alloc zeroed(MSG_size)
`Check messages
do
call dll USER32, "GetMessageA", msgPtr, hwnd, 0, 0
print peek dword(msgPtr+MSG_message);" ";peek dword(msgPtr+MSG_wparam);" ";peek dword(msgPtr+MSG_lparam);" ";
print peek dword(msgPtr+MSG_ptX);" ";peek dword(msgPtr+MSG_ptY)
call dll USER32, "TranslateMessage", msgPtr
call dll USER32, "DispatchMessageA", msgPtr
loop
free msgPtr
success = call dll(SHELL32, "Shell_NotifyIconA",NIM_DELETE, pNid) `Remove tray icon
success = call dll(USER32, "DestroyIcon", hIcon) `Delete icon data
free pNid `Delete NOTIFYICONDATA structure