48 lines
1.1 KiB
Markdown
48 lines
1.1 KiB
Markdown
# racket-tray
|
|
|
|
A small system tray API for Racket.
|
|
|
|
Version 0.1 implements Windows directly through the Win32 API. It uses the
|
|
native `HWND` of an existing Racket `frame%`/`dialog%`, `Shell_NotifyIconW`, and
|
|
`SetWindowSubclass`. No additional native DLL is required.
|
|
|
|
```racket
|
|
#lang racket/gui
|
|
|
|
(require racket-tray)
|
|
|
|
(define frame
|
|
(new frame%
|
|
[label "Tray example"]
|
|
[width 400]
|
|
[height 250]))
|
|
|
|
(define tray
|
|
(mk-tray frame
|
|
"example.png"
|
|
(λ ()
|
|
(send frame show #t))))
|
|
|
|
(tray-set-menu!
|
|
tray
|
|
(list
|
|
(list "Open"
|
|
(λ () (send frame show #t)))
|
|
'separator
|
|
(list "Exit"
|
|
(λ ()
|
|
(tray-close tray)
|
|
(send frame show #f)))))
|
|
|
|
(send frame show #t)
|
|
```
|
|
|
|
`mk-tray` and `tray-set-icon!` accept both Windows `.ico` files and `.png`
|
|
files. PNG transparency is preserved when the image is converted to the native
|
|
Windows tray icon.
|
|
|
|
`tray-set-menu!` also accepts a `popup-menu%` object directly, or `#f` to
|
|
remove the context menu.
|
|
|
|
At the moment non-Windows platforms report that the operation is unsupported.
|