Reference Manual

  • 15.0
  • 07/23/2021
  • Public Content
Contents

Using Tab Controls

The Tab control is like the dividers in a notebook or the labels on a file cabinet. By using a Tab control, an application can define multiple pages for the same area of a dialog box. Each page is associated with a particular Tab and only one page is displayed at a time.
The control index
DLG_NUMITEMS
determines how many Tabs are contained in the Tab control. For each Tab, you specify the label of the Tab using
DLGSETCHAR
and an index value from 1 to the number of Tabs set with
DLG_NUMITEMS
. Each Tab has an associated dialog box that is displayed when the Tab is selected. You specify the dialog box using
DLGSETINT
with the dialog name and an index value corresponding to the the Tab. For example, the code below defines three Tabs in a Tab control. The Tab with the label "Family" is associated with the dialog box named IDD_TAB_DIALOG1, and so on.
! Set initial Tabs lret = DlgSet(gdlg, IDC_TAB, 3) lret = DlgSet(gdlg, IDC_TAB, "Family", 1) lret = DlgSet(gdlg, IDC_TAB, "Style", 2) lret = DlgSet(gdlg, IDC_TAB, "Size", 3) lret = DlgSet(gdlg, IDC_TAB, IDD_TAB_DIALOG1, 1) lret = DlgSet(gdlg, IDC_TAB, IDD_TAB_DIALOG2, 2) lret = DlgSet(gdlg, IDC_TAB, IDD_TAB_DIALOG3, 3)
You define each of the Tab dialogs using the resource editor just as you do for the dialog box that contains the Tab control. In the Properties Window, you must make the following style settings for each Tab dialog:
  1. Set the "Style" to "Child"
  2. Set "Border" to "None"
  3. Set "Title Bar" to "False."
Before displaying the dialog box that contains the Tab control (using
DLGMODAL
or
DLGMODELESS
):
  1. Call
    DLGSETSUB
    to define a DLG_INIT callback for the dialog box
  2. Call
    DLGINIT
    for each Tab dialog
In the DLG_INIT callback of the dialog box that contains the Tab control, if the callbacktype is DLG_INIT, call
DLGMODELESS
for each of the Tab dialog boxes. Specify
SW_HIDE
as the second parameter, and the window handle of the Tab control as the third parameter. After calling
DLGMODELESS
, call
DLGSET
with the
DLG_STATE
index to set the initial Tab. For example:
! When the Main dialog box is first displayed, call DlgModeless to ! display the Tab dialog boxes. Note the use of SW_HIDE. The ! Dialog Functions will "show" the proper Tab dialog box. if (callbacktype == dlg_init) then hwnd = GetDlgItem(dlg % hwnd, IDC_TAB) lret = DlgModeless(gdlg_tab1, SW_HIDE, hwnd) lret = DlgModeless(gdlg_tab2, SW_HIDE, hwnd) lret = DlgModeless(gdlg_tab3, SW_HIDE, hwnd) ! Note that we must set the default Tab after the calls to ! DlgModeless. Otherwise, no Tab dialog box will be displayed ! initially. lret = DlgSet(dlg, IDC_TAB, 1, dlg_state)
Call
DLGUNINIT
for each Tab dialog when you are done with it.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.