TTabControl

Fuente: source/classes/ttabctrl.prg

Inherits from: TControl

TTabControl wraps the standard Windows SysTabControl32 common control. It displays a row of selectable tabs, each with a prompt, and notifies the application when the user clicks a tab via an action code block. TTabControl is a lightweight tab control without built-in page management — it fires an action on selection change and leaves the page-switching logic to the application. For automatic page switching, see TTabs or TPages.

Key DATA Members

DATATypeDescription
aPromptsArrayArray of character strings displayed as tab labels.
bActionBlockCode block evaluated when the user clicks a tab: { |nOption, oCtrl| ... }.
nOptionNumericIndex of the currently selected tab (1-based).
nClrTextNumericText color for tab labels (RGB value).
nClrPaneNumericBackground fill color (RGB value).
hFontNumeric (Handle)Handle of the font used for tab label text.
oFontTFontFont object used for tab label text.
cMsgCharacterMessage bar text displayed when the tab control receives focus.

Methods

MethodDescription
New( nRow, nCol, aPrompts, bAction, oWnd, nClrT, nClrP, oFont, lPixel, lDesign, nW, nH, cMsg )Create a new tab control. aPrompts is an array of tab label strings. bAction is called on tab selection.
ReDefine( nId, oWnd )Redefine from a dialog resource. Links to an existing SysTabControl32 by its control ID.
Add( cPrompt )Add a new tab at the end with the given label text.
DelItem( nItem )Remove the tab at position nItem (1-based).
SetPrompts( aPrompts )Replace all tab labels with a new array of strings.
SetOption( nOption )Programmatically select a tab by its index.
End()Destroy the control.

Commands: @ ... TAB

@ nRow, nCol TAB oTab ;
   ITEMS aItems ;
   [ SIZE nW, nH ] ;
   [ OF oDlg ] ;
   [ ACTION bAction ] ;
   [ ON CHANGE bChange ] ;
   [ COLOR nClrText, nClrPane ]

Example: 3-Tab Control with Action

#include "FiveWin.ch"

function Main()

   local oWnd, oTab
   local aPrompts := { "General", "Details", "Settings" }

   DEFINE WINDOW oWnd TITLE "TTabControl Demo" SIZE 500, 400

   @ 10, 10 TAB oTab ITEMS aPrompts ;
      SIZE 460, 50 OF oWnd ;
      ACTION MsgInfo( "Selected tab: " + Str( oTab:nOption ) )

   @ 80, 20 SAY "Content area for tab " + Str( oTab:nOption ) ;
      OF oWnd SIZE 300, 20

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También