BCX_TAB function

Purpose: BCX_TAB creates a tab control.


 Syntax:

 hCtl = BCX_TAB(hWndParent, _
                    CtlID%, _
                 NumPages%, _ 
                    hArray, _ 
                    Array$, _ 
                     Xpos%, _ 
                     Ypos%, _ 
                    Width%, _
                   Height%, _
                HIMAGELIST, _ 
               [,WinStyle%] _ 
             [,ExWinStyle%])

 Parameters:

  • hCtl The return value is a handle to the new tab control if the function succeeds. If the function fails, the return value is NULL.
  • hWndParent Handle to the parent window of the tab control being created.
  • CtlID% Control ID. A negative value can be entered as an argument for the CtlID% parameter to indicate that the tab control should not be subclassed. Then, in the message loop, enter:
    
     CASE WM_NOTIFY
       BCX_TABSELECT
    
    
    This will work with regular forms and dialogs. Operation of the control will behave as usual when the control id is a positive value.
  • NumPages Number of Pages/Tabs the Tab Control will have.
  • hArray An array of handles returned for each page.
  • Array$ An array of titles for each Page/Tab.
  • Xpos% Specifies the initial horizontal position of the tab control being created. Xpos% is the x-coordinate of the upper-left corner of the tab control being created relative to the upper-left corner of the parent window's client area.
  • Ypos% Specifies the initial vertical position of the tab control being created. Ypos% is the initial y-coordinate of the upper-left corner of the tab control being created relative to the upper-left corner of the parent window's client area.
  • Width% Specifies the width, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the tab control being created.
  • Height% Specifies the height, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the tab control being created.
  • HIMAGELIST An Image list to be placed on each Page/Tab(Enter NULL for none)
  • WinStyle% [OPTIONAL] If the WinStyle% parameter is used, the default Window Style for a BCX_TAB control, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS | TCS_TABS | TCS_SINGLELINE | TCS_FOCUSONBUTTONDOWN, is replaced with the value in WinStyle%. See your Win32 SDK or PSDK Reference help for more information about valid Window Styles for a SysTabControl32.
  • ExWinStyle% [OPTIONAL] The default Extended Window Style for a BCX_TAB control is 0. See your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles for a SysTabControl32.

Here is a complete example using the BCX_TAB function.


  ' *************************************************************
  ' *  Color_Tab – P.Kort(8 Jan , 2005)                         *
  ' *  Ver : 0.0.0.1                                            *
  ' *  BCX_Tab Control Example                                  *
  ' *************************************************************
   
  GUI "Color_Tab"
   
  GLOBAL ghMainFrm AS CONTROL
  GLOBAL ghMainTab AS CONTROL
  GLOBAL ghTab[3]  AS HWND
   
  SET gTabPage$[3]
    "Page 1", "Page 2", "Page 3"
  END SET
   
  CONST ID_TAB     = 500
  CONST ID_LABEL1  = 501
  CONST ID_BUTTON1 = 502
  CONST ID_BUTTON2 = 503
   
  '================================================================
  SUB FormLoad()
   
    ghMainFrm  = BCX_FORM("BCX Color Tab Demo", 0, 0, 0, 0)
   
    ghMainTab = BCX_TAB(ghMainFrm, ID_TAB, 3, ghTab, gTabPage$, 0, 0, 400, 250)
   
    BCX_LABEL("This is a Label", ghTab[0], ID_LABEL1, 20, 25, 60, 10)
    BCX_BUTTON("Button 1", ghTab[1], ID_BUTTON1, 20, 25, 60, 20)
    BCX_BUTTON("Button 2", ghTab[2], ID_BUTTON2, 20, 25, 40, 15)
   
    BCX_SET_FORM_COLOR(ghTab[0], QBCOLOR(1))
   
    'Generate a WM_SIZE message
    MoveWindow(ghMainFrm, 0, 0, 500, 400, TRUE) 'Force a WM_SIZE
    
    CENTER(ghMainFrm)
    SHOW(ghMainFrm)
   
    SetFocus(ghMainTab)
   
  END SUB
   
  '================================================================
   
  BEGIN EVENTS
    SELECT CASE CBMSG
   
    CASE WM_SIZE
      STATIC cxClient%
      STATIC cyClient%
   
      cxClient=LOWORD(lParam)
      cyClient=HIWORD(lParam)
   
      MoveWindow(ghMainTab, 2, 2, cxClient - 4, cyClient - 2, TRUE)
      EXIT FUNCTION
   
    CASE WM_NOTIFY
      DIM  ptnmhdr AS NMHDR*
      DIM  PageNo  AS long
       
      ptnmhdr = (NMHDR*)lParam
   
      IF ptnmhdr->code >= TCN_LAST && ptnmhdr->code <= TCN_FIRST THEN
        SELECT CASE ptnmhdr->idFrom
        CASE ID_TAB
          SELECT CASE ptnmhdr->code
          CASE TCN_SELCHANGE
            PageNo = SendMessage(GetDlgItem(hWnd, (UINT)ID_TAB), _
            (WPARAM)TCM_GETCURSEL, (LPARAM)0, 0)
            ShowWindow(ghTab[PageNo], SW_SHOW)
   
            SELECT CASE PageNo
            CASE 0
              BCX_SET_FORM_COLOR(ghTab[0], QBCOLOR(1))
              EXIT FUNCTION
   
            CASE 1
              BCX_SET_FORM_COLOR(ghTab[1], QBCOLOR(3))
              EXIT FUNCTION
   
            CASE 2
              BCX_SET_FORM_COLOR(ghTab[2], QBCOLOR(15))
              EXIT FUNCTION
   
            END SELECT
          END SELECT
        END SELECT
      END IF
   
    CASE WM_CLOSE
      DestroyWindow(hWnd)
      EXIT FUNCTION
   
    CASE WM_DESTROY
      PostQuitMessage(0)
      EXIT FUNCTION
   
    END SELECT
  END EVENTS

BCX_REMTAB statement

Purpose: BCX_REMTAB removes a specified tab from a tab control.


 Syntax:

 BCX_REMTAB(hTabControl, TheTabToRemove%)

 Parameters:

  • hTabControl a HWND data type handle to the tab control in which the tab is to be removed.
  • TheTabToRemove% Index, zero-based, to the tab which is to be removed.

BCX_ADDTAB statement

Purpose: BCX_ADDTAB adds a specified tab to a tab control.


 Syntax:

 BCX_ADDTAB(hTabControl, _
            TheTabToAdd%, _
                 TabText$ _
          [, ImageIndex%] _ 
         [, ShowHideTab%])

 Parameters:

  • hTabControl a HWND data type handle to the tab control in which the tab is to be added.
  • TheTabToAdd% Index, zero-based, to the tab which is to be added.
  • TabText$ Text string to be displayed on tab.
  • ImageIndex% [OPTIONAL] Integer specifying the index of an image in the tab control's image list.
  • ShowHideTab% [OPTIONAL] Integer 0 specifies that tab is hidden, 1(default) specifies that tab is shown.

BCX_TABSELECT statement

Purpose: BCX_TABSELECT is only used with BCX_TAB. BCX_TABSELECT was made available to allow using BCX_TAB within a dialog box, although it also can be used with a BCX_FORM

When calling BCX_TAB, a negative value can be entered as an argument for the CtlID% parameter(see above BCX_TAB function parameter description) to indicate that the tab control should not be subclassed. Then, in the message loop, enter:


 CASE WM_NOTIFY
   BCX_TABSELECT

This will handle the switching between BCX_TAB pages.


 Syntax:

 BCX_TABSELECT

 Parameters:

  • No parameters

Example: The following demonstrates usage of the BCX_TAB BCX_ADDTAB, BCX_REMTAB and BCX_TABSELECT procedures.


 GUI "TabTest", PIXELS
 
 GLOBAL Form1 AS HWND
 
 SUB FORMLOAD
  Form1 = BCX_FORM("Tab Test", 0, 0, 640, 480)
  BCX_BUTTON("Tab Dialog", Form1, 1000, 10, 10)
  CENTER(Form1)
  SHOW(Form1)
 END SUB
 
 
 BEGIN EVENTS
 SELECT CASE CBMSG
   CASE WM_COMMAND
   SELECT CASE CBCTL
     CASE 1000
     BCX_MDIALOG(Configure, _
      "Test Tab", Form1, 60, _
         30, 325, 230, 0, 0, _
          "ms sans serif",8)
   END SELECT
 END SELECT
 END EVENTS
 
 
 BEGIN MODAL DIALOG AS Configure
 STATIC Tabpages[32] AS HWND
 STATIC Tab1 AS HWND
 
 SHAREDSET Tablabels$[]
   "Page 1", "Page 2", "Page 3", "Page 4"
 END SET
 
 SELECT CASE CBMSG
 
   CASE WM_INITDIALOG
   Tab1 = BCX_TAB(hWnd, -300, 4, Tabpages, Tablabels$, 1, 5, 324, 198)
   BCX_BUTTON("Add Tab", hWnd, 90, 200 , 210)
   BCX_BUTTON("Remove Tab", hWnd, 100, 260 , 210)
 
   FUNCTION = TRUE
 
   CASE WM_NOTIFY
   BCX_TABSELECT
 
   CASE WM_COMMAND
   SELECT CASE CBCTL
     CASE 90
     DIM RAW pn = TabCtrl_GetItemCount(Tab1)
     IF pn = 31 THEN EXIT
     BCX_ADDTAB(Tab1, pn+1, "Page" + STR$(pn+1))
 
     CASE 100
     DIM RAW cur = TabCtrl_GetCurSel(Tab1)
     IF cur = -1 THEN EXIT
     BCX_REMTAB(Tab1, cur)
   END SELECT
 END SELECT
 END DIALOG