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 )
| Parameter | Type | Description |
|---|---|---|
| oParent | TVMenu | Parent menu (required) |
| cText | Character | Item caption text |
| cBmp1 | Character/Numeric | Bitmap file path, resource name, or bitmap handle |
| lGroup | Logical | Is a group heading (default: .f.) |
| nClrText | Numeric | Custom text color (nil = parent default) |
| nClrPane | Numeric | Custom background color |
| nTextAlign | Character | "LEFT", "CENTER", "RIGHT", "MULTILINE" |
| nImgAlign | Character | "IMAGELEFT" (default), "IMAGECENTER", "IMAGERIGHT" |
| separator | Character | "LINE", "SEPARADOR", "INSET", "DOTDOT" |
| bAction | Codeblock | Item action codeblock |
| oPopup | TPopup | Associated popup menu |
| bWhen | Codeblock | When clause (returns .t. to enable) |
Methods
| Method | Returns | Description |
|---|---|---|
SetImage(cBmp, lIcon) | nil | Set image from file, resource, object, or numeric handle |
SetBold(lBold) | Logical | Toggle bold text |
SetDialog(cResName) | nil | Associate a dialog resource |
lOption() | Logical | Is this the currently selected item |
EvalWhen() | Logical | Evaluate when-clause |
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cCaption | Character | Display text |
hBmp | Numeric | Bitmap handle |
nImage | Numeric | Image list index |
bAction | Codeblock | Item action |
lDisable | Logical | Item is disabled/grayed |
lGroup | Logical | Is group heading |
nSeparator | Numeric | Separator type (0=none, 1-4=styles) |
oPopup | TPopup | Associated 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.