TVItem

Source: source/classes/vitem.prg

Standalone class (not inheriting TControl)

TVItem represents a single item within a TVMenu panel. Each TVItem holds a text caption, optional bitmap/icon, action codeblock, and display properties. When created, a TVItem automatically adds itself to its parent TVMenu's aItems array. TVItem supports multiple separator styles, group headings, popup menus, when-clauses, and custom coloring.

New() Constructor

TVItem():New( oParent, cText, cBmp1, cBmp2, lGroup, nClrText, nClrPane,;
              nTextAlign, nImgAlign, nHeight, nLeft, separator, nWidth,;
              lUnder, nLeftImg, nClrPane2, lVGrad, bAction, oPopup,;
              nClrPSel, nClrTSel, lMirGrad, nSteps, cToolTip,;
              nColorSep, lIcon, nTop, bWhen, nClrPSel2 )
ParameterTypeDescription
oParentTVMenuParent menu (required)
cTextCharacterItem caption text
cBmp1Character/NumericBitmap file path, resource name, or bitmap handle
lGroupLogicalIs a group heading (default: .f.)
nClrTextNumericCustom text color (nil = parent default)
nClrPaneNumericCustom background color
nTextAlignCharacter"LEFT", "CENTER", "RIGHT", "MULTILINE"
nImgAlignCharacter"IMAGELEFT" (default), "IMAGECENTER", "IMAGERIGHT"
separatorCharacter"LINE", "SEPARADOR", "INSET", "DOTDOT"
bActionCodeblockItem action codeblock
oPopupTPopupAssociated popup menu
bWhenCodeblockWhen clause (returns .t. to enable)

Methods

MethodReturnsDescription
SetImage(cBmp, lIcon)nilSet image from file, resource, object, or numeric handle
SetBold(lBold)LogicalToggle bold text
SetDialog(cResName)nilAssociate a dialog resource
lOption()LogicalIs this the currently selected item
EvalWhen()LogicalEvaluate when-clause

Key DATA Members

DATATypeDescription
cCaptionCharacterDisplay text
hBmpNumericBitmap handle
nImageNumericImage list index
bActionCodeblockItem action
lDisableLogicalItem is disabled/grayed
lGroupLogicalIs group heading
nSeparatorNumericSeparator type (0=none, 1-4=styles)
oPopupTPopupAssociated popup menu

Example

local oItem

// Simple text item
oItem := TVItem():New( oMenu, "Documents" )

// Item with bitmap handle
oItem := TVItem():New( oMenu, "Home" )
oItem:SetImage( hMyBitmap )

// Separator
oItem := TVItem():New( oMenu, "" )
oItem:nSeparator := 2

// Group heading
oItem := TVItem():New( oMenu, "Settings" )
oItem:lGroup := .t.

See Also