TMetro
Source: source/classes/tmetro.prg
Standalone class
TMetro creates a full-screen Modern UI (Metro-style) start screen with tiled buttons, inspired by the Windows 8 Metro design language. It displays a background image, a title, current date and time, and a grid of tiled buttons that can be either normal or large (double-width). Each tile has configurable text and background colors and an optional icon image.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
oWnd | Object | The underlying popup window (WS_POPUP style) |
cTitle | Character | Title displayed at the top of the start screen |
aButtons | Array | Array of TButtonBmp objects created by AddButton() |
nBtnWidth | Numeric | Tile width in pixels (default 132) |
nBtnHeight | Numeric | Tile height in pixels (default 132) |
nOriginX | Numeric | Starting X position for tile grid (default 200) |
nOriginY | Numeric | Starting Y position for tile grid (default 200) |
hBitmap | Numeric | Handle to the background bitmap |
oFont | Object | Segoe UI Light font for display elements |
oFontB | Object | Segoe UI Light bold font for time display |
oTimer | Object | Timer for updating the clock display |
Methods
| Method | Description |
|---|---|
New( cTitle, nBtnW, nBtnH, cBgFile ) | Create a new TMetro start screen. cBgFile is a background bitmap file or resource. |
Activate() | Show the start screen maximized with background, title, date, and time |
AddButton( cCaption, nClrText, nClrPane, lLarge, cImg, bAction ) | Add a tile button with caption, colors, optional image, and action |
End() | Close the start screen and release resources |
Example: Metro Screen with Tiles
#include "FiveWin.ch"
function Main()
local oMetro
oMetro := TMetro():New( "My Application", 132, 132, "bg.bmp" )
oMetro:AddButton( "Customers", CLR_WHITE, CLR_HBLUE, .F., "cust.bmp",;
{ || MsgInfo( "Customers" ) } )
oMetro:AddButton( "Products", CLR_WHITE, CLR_HGREEN, .F., "prod.bmp",;
{ || MsgInfo( "Products" ) } )
oMetro:AddButton( "Reports", CLR_WHITE, CLR_HRED, .T., "rpt.bmp",;
{ || MsgInfo( "Reports" ) } )
oMetro:Activate()
return nil
Notes
- TMetro creates a borderless popup window that fills the entire screen. The window style uses
WS_POPUPwith no caption or border. - The background image can be loaded from a file or from a resource. If the file is not found, it falls back to resource loading.
- Large tiles (
lLarge := .T.) span two tile positions in width, providing visual emphasis for primary actions. - Tile positions are calculated automatically in a grid layout. When a row exceeds the screen width, tiles wrap to the next row.
- The clock is updated via an internal timer and displayed in the top-right area using the Segoe UI Light font.
- TMetro uses
Segoe UI Lightfont which is available on Windows 8 and later. On older systems, it falls back to a default font.