TMsgBar / TMsgItem

Sources: source/classes/msgbar.prg, source/classes/tmsgitem.prg

TMsgBar inherits from TControl; TMsgItem is a helper class

TMsgBar is a themed status bar replacement that supports embedded interactive items (clock, date, keyboard indicators, and custom action buttons). It offers Office 2007/2010/2015 visual styles and centered text alignment. TMsgItem defines individual embeddable items within a TMsgBar.

TMsgBar Key DATA Members

DATATypeDescription
cMsgDefCharacterDefault message text
aItemsArrayArray of TMsgItem objects embedded in the bar
l2007LogicalOffice 2007 theme style
l2010LogicalOffice 2010 theme style
l2015LogicalOffice 2015 theme style
lCenteredLogicalCenter the message text horizontally
oClockObjectEmbedded clock item (TMsgItem)
oDateObjectEmbedded date item (TMsgItem)
oKeyCapsObjectCaps Lock indicator item
oKeyNumObjectNum Lock indicator item

TMsgBar Methods

MethodDescription
New( oWnd, cPrompt, lCentered, lClock, lDate, lKbd )Create a themed message bar
SetMsg( c )Set the main message text
AddItem( oItem )Add a TMsgItem to the bar
ClockOn()Show the embedded clock
DateOn()Show the embedded date
KeybOn()Show keyboard status indicators (Caps, Num)

TMsgItem Key DATA Members

DATATypeDescription
cMsgCharacterItem caption text
nWidthNumericItem width in pixels
bActionBlockCode block executed on click
hBitmap1HandleBitmap handle for the "on" state
hBitmap2HandleBitmap handle for the "off" state
lActiveLogicalCurrent active/checked state

TMsgItem Methods

MethodDescription
New( oBar, cMsg, nW, oFont, nClrT, nClrB, lAdd, bAction )Create a new message bar item
SetText( c )Update the item caption text
SetBitmap( cOn, cOff )Set the on/off state bitmaps
ShowPopup( oMenu )Show a popup menu when the item is clicked

Example: Message Bar with Clock and Custom Item

#include "FiveWin.ch"

function Main()

   local oWnd, oMsgBar, oItem

   DEFINE WINDOW oWnd TITLE "TMsgBar Demo" SIZE 600, 400

   DEFINE MSGBAR oMsgBar OF oWnd PROMPT "Ready" ;
      2010 CLOCK DATE KEYBOARD

   // Add a custom clickable item
   oItem := TMsgItem():New( oMsgBar, "Records: 0", 120 )
   oItem:bAction := {|| MsgInfo( "Status clicked!" ) }
   oMsgBar:AddItem( oItem )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also