TVistaMenu
Source: source/classes/vistamnu.prg
Inherits from: TControl
TVistaMenu provides a modern vertical menu panel with Vista-style visual rendering. Each item displays text and an optional icon, with configurable highlight colors for the hovered selection. The control is suitable for navigation panels and sidebar menus.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aItems | Array | Array of menu item definitions |
oOver | Numeric | Index of the item currently under the mouse |
nOptionFocus | Numeric | Index of the currently focused item (keyboard navigation) |
nClrPaneOver | Numeric | Background color of the hovered item |
nClrTextOver | Numeric | Text color of the hovered item |
nClrBorderOver | Numeric | Border color of the hovered item |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, nW, nH, oWnd, oFont, oFont2 ) | Create a new vista menu control |
Redefine( nId, oWnd, oFont, oFont2 ) | Redefine from a dialog resource |
AddItem( cText, cImage, bAction ) | Add a menu item with text, image path and action |
InsertItem( n, cText, cImage, bAction ) | Insert a menu item at the specified position |
DelItem( n ) | Delete a menu item at the given position |
GoUp() | Move keyboard focus to the previous item |
GoDown() | Move keyboard focus to the next item |
Example: Vertical Menu with Icons
#include "FiveWin.ch"
function Main()
local oWnd, oVMenu
DEFINE WINDOW oWnd TITLE "TVistaMenu Demo" SIZE 400, 400
@ 10, 10 VISTAMENU oVMenu ;
OF oWnd ;
SIZE 180, 300 ;
FONT oWnd:oFont
oVMenu:AddItem( "&Dashboard", "images/dash.bmp", { || MsgInfo( "Dashboard" ) } )
oVMenu:AddItem( "&Customers", "images/cust.bmp", { || MsgInfo( "Customers" ) } )
oVMenu:AddItem( "&Orders", "images/ord.bmp", { || MsgInfo( "Orders" ) } )
oVMenu:AddItem( "&Reports", "images/rpt.bmp", { || MsgInfo( "Reports" ) } )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The
cImageparameter inAddItem()accepts a file path to a bitmap or icon resource. If the image cannot be loaded, the item displays text only. - Use
nClrPaneOver,nClrTextOver, andnClrBorderOverto customize the hover highlight appearance. - Keyboard navigation is handled via
GoUp()andGoDown(), typically mapped to the UP and DOWN arrow keys in the parent window. - The
&character in item text defines keyboard accelerators (e.g., "&Dashboard" activates on Alt+D). - TVistaMenu inherits from TControl, so it supports all standard control positioning, sizing, and event handling.