TToast

Fonte: 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

DATATypeDefaultDescription
cHeaderCharacterHeader text (bold, top section)
cBodyCharacterBody/main message text
cFootCharacterFooter text
cBmpLeftCharacter""Path to left-side bitmap image
nClrPaneNumericRGB(20,20,20)Background color (dark on Win8+)
nClrPane2NumericSecondary background color (gradient)
nLevelNumeric255Opacity level (0-255, 255=opaque)
nTimerNumeric5000Auto-dismiss timeout in milliseconds
lAlertLogical.T.Enable alert behavior (auto-show and dismiss)
lUpPosLogical.F.Show at top of screen instead of bottom
lLeftPosLogical.F.Show at left side instead of right
bReturnBlock{ || .T. }Codeblock executed when notification is closed
lBtnCloseLogical.T.Show close button
lShadowLogical.T.Show drop shadow

Methods

MethodDescription
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

Veja Também