TToast
Source: source/classes/ttoast.prg
Inherits from: TWindow
TToast provides desktop toast notifications in the Windows 8/10 style. Notifications appear as layered windows that auto-position at the screen corner, auto-dismiss after a configurable timeout, and support header, body, footer text along with optional bitmap images. The control uses alpha blending for smooth transparency effects and drop shadows.
Key DATA Members
| DATA | Type | Default | Description |
|---|---|---|---|
cHeader | Character | Header text (bold, top section) | |
cBody | Character | Body/main message text | |
cFoot | Character | Footer text | |
cBmpLeft | Character | "" | Path to left-side bitmap image |
nClrPane | Numeric | RGB(20,20,20) | Background color (dark on Win8+) |
nClrPane2 | Numeric | Secondary background color (gradient) | |
nLevel | Numeric | 255 | Opacity level (0-255, 255=opaque) |
nTimer | Numeric | 5000 | Auto-dismiss timeout in milliseconds |
lAlert | Logical | .T. | Enable alert behavior (auto-show and dismiss) |
lUpPos | Logical | .F. | Show at top of screen instead of bottom |
lLeftPos | Logical | .F. | Show at left side instead of right |
bReturn | Block | { || .T. } | Codeblock executed when notification is closed |
lBtnClose | Logical | .T. | Show close button |
lShadow | Logical | .T. | Show drop shadow |
Methods
| Method | Description |
|---|---|
NewToast( nType, cText, cBmp, nWidth, nHeight, oWnd, nClrPane, nClrPane2, nClrText, nLev, nTime, lUp, bRet, lLeftP, lAlert, lShadow, nOffY, nOffX, nFont ) | Create and display a toast notification. This is the primary entry point. |
New( nTop, nLeft, nWidth, nHeight, oWnd, lDisenio, nClrPane, nClrPane2, nClrText, nWRadio, nHRadio, nLev, lShadow, lAlert, nTime, lUp, cFace, nFont, bRet, lLeftP, l2007 ) | Standard TWindow constructor for custom toast creation |
ActivaAlert() | Show the toast notification on screen. Called automatically by NewToast. |
Default( lShowDlg ) | Apply default layout and positioning. Calculates control areas and positions the window. |
BuildTimer( lEnd ) | Start or stop the auto-dismiss timer |
Destroy() | Destroy the toast window and release resources |
Paint() | Render the toast background, text sections, and images |
SetSize( nWidth, nHeight ) | Resize the toast window |
Example: Toast Notification
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Toast Demo" SIZE 400, 300
@ 20, 20 BUTTON "Show Toast" SIZE 120, 30 OF oWnd ;
ACTION ShowToast()
ACTIVATE WINDOW oWnd CENTERED
return nil
function ShowToast()
// Show a notification at the bottom-right corner
// Auto-dismisses after 5000 ms (default)
TToast():NewToast( ;
1, ; // Notification type
"System Update##"; + ; // Header (separated by ##)
"Your system has been updated successfully." + ;
"##Please restart to apply changes.", ; // Body
"..\bitmaps\info.bmp", ; // Optional icon
320, 120, ; // Width, Height
, , , , 5000, .F. ) // 5 sec timeout, bottom position
return nil
Notes
- TToast uses the
NewToast()static-like method as its primary API. It creates, positions, and shows the notification window in one call. - The text format uses
##as a separator: the first part becomes the header, the second part the body, and the third (optional) part the footer text. - On Windows 8 and later, the default style is dark with Segoe MDL2 Assets font. On older systems, it falls back to a light theme with Tahoma.
- Opacity is controlled via
nLevel(0-255). The window usesWS_EX_LAYEREDandLWA_ALPHAfor alpha blending. - Toasts stack automatically: each new toast positions itself above the previous one. The class-level
aTToastarray tracks all active notifications. - Clicking the toast invokes
bReturn. The close button (if enabled) dismisses the notification immediately.