TabCtrl Control

Purpose

Creates a Tab control in the current active form, window, or dialog.

Syntax

TabCtrl text$, id%, x, y, w, h[, style%]

text$:control text
id%:control identifier
x,y,w,h:iexp
style%:the control styles

Description

A tab control is analogous to the dividers in a notebook or the labels in a file cabinet. By using a tab control, an application can define multiple pages for the same area of a window or dialog box. Each page consists of a certain type of information or a group of controls that the application displays when the user selects the corresponding tab.

When the user selects a tab, a tab control sends its parent window notification messages in the form of WM_NOTIFY messages, which should be handled in the _Message or _MessageProc event sub of the parent Form.

Example

This example is very basic: for more information of TabStrip controls see this Windows Dev Centre page.

Const TCM_FIRST = &H1300

Const TCM_SETITEM = TCM_FIRST + 6

Const TCM_INSERTITEM = TCM_FIRST + 7

Const TCM_GETITEMCOUNT = TCM_FIRST + 4

Const TCIF_TEXT = 1

Const TCIF_IMAGE = 2

'

Dialog # 1, 10, 10, 400, 400, "Dialog", WS_SYSMENU

TabCtrl "", 10, 20, 20, 150, 150

EndDialog

Dim tc1 As TCITEM, tc$ = "Tab 1"

tc1.mask = TCIF_TEXT

tc1.pszText = V:tc$

~SendMessage(DlgItem(1, 10), TCM_INSERTITEM, 1, tc1)

tc$ = "Tab 2"

~SendMessage(DlgItem(1, 10), TCM_INSERTITEM, 2, tc1)

ShowDialog # 1

'

Do

Sleep

Until Dlg_1 Is Nothing

 

Sub Dlg_1_Close(Cancel?)

Cancel? = False

EndSub

 

Sub frm_MessageProc(hWnd%, Mess%, wParam%, lParam%, retval%, ValidRet?)

Dim hdr As Pointer NMHDR

Switch Mess

Case WM_NOTIFY

Pointer(hdr) = lParam

Print hdr.idfrom

EndSwitch

EndSub

// Type Declarations

Type NMHDR

hwndFrom As Long

idfrom As Long

code As Long

EndType

Type TCITEM

- Long mask, dwState, dwStateMask, pszText, cchTextMax, iImage, lParam

EndType

Remarks

This command is particular useful for a dialog box in a GLL, because a GLL doesn't support OCX controls.

With the general Control statement any control type can be created.

See Also

Control, AnimateCtrl, AutoCheckBox, AutoRadioButton, CheckBox, ComboBox, CText, Dialog, DefPushButton, EditText, GroupBox, HeaderCtrl, ListBox, ListViewCtrl, LText, ProgressCtrl, PushButton, RadioButton, RichEditCtrl, RText, ScrollBar, StatusCtrl, TabCtrl, ToolBarCtrl, TrackBarCtrl, TreeViewCtrl, UpDownCtrl

{Created by Sjouke Hamstra; Last updated: 24/10/2014 by James Gaite}