No announcement yet.

Tab Control - Page Title

  • Filter
  • Time
  • Show
Clear All
new posts

  • Tab Control - Page Title

    Is it possible to change the title shown on a page tab after it has been created? Or do you have to effectively delete/recreate the page?

    I'm trying to plow through MSDN but can't find anything close. Attempts with varieties of SET TEXT and using handles of the page and/or Tab control seem to do nothing.

  • #2
    see the TCM_SETITEM message


    • #3
      TCM_SETITEM is what you need. I am not sure if DDT offers a command to do it?

      #Compiler PBWin 9
      #Compile Exe
      #Dim All
      #Include ""
      Type TC_ITEM
        mask As Dword
        lpReserved1 As Dword
        lpReserved2 As Dword
        lpszText As Asciiz Ptr
        cchTextMax As Dword
        iImage As Dword
        lParam As Long
      End Type
      %TCM_SETITEM = 4870
      ' Control equates
      %ID_TAB            = 1000
      %ID_TAB1_TBFIRST   = 1001
      %ID_TAB1_LBFIRST   = 1002
      %ID_TAB1_LBLAST    = 1003
      %ID_TAB1_TBLAST    = 1004
      %ID_TAB1_BNSUBMIT  = 1005
      %ID_TAB2_CBCHOICES = 1006
      %ID_TAB3_LBCHOICES = 1007
      %ID_TAB3_TEXTBOX   = 1008
      Global hDlg As Long
      Function PBMain () As Long
        Local hTab1     As Long
        Dialog New 0, "Tab Control Example", , , 300, 140, %WS_Popup Or %WS_Border Or %WS_DlgFrame Or %WS_Caption Or _
          %WS_SysMenu Or %WS_ClipSiblings Or %WS_Visible Or %DS_ModalFrame Or %DS_3DLook Or %DS_NoFailCreate Or _
          %DS_SetFont, %WS_Ex_ControlParent Or %WS_Ex_Left Or %WS_Ex_LtrReading Or %WS_Ex_RightScrollbar, To hDlg
        ' Add a Tab control to the main dialog box
        Control Add Tab, hDlg, %ID_TAB, "", 1, 1, 298, 138
        ' Build the Tab 1 dialog and it's controls
        Tab Insert Page hDlg, %ID_TAB, 1, 0, "Tab 1", To hTab1
          Control Add Button,  hTab1, %ID_TAB1_BNSUBMIT, "Change text", 20, 20, 50, 14 Call btnProc
        ' Display the main dialog box
        Dialog Show Modal hDlg
      End Function
      CallBack Function btnProc() As Long
        Local tcItem As TC_ITEM, hWnd As Dword, textAscii As Asciiz * 100
        If Cb.Msg = %WM_Command Then
          If Cb.CtlMsg = %BN_Clicked Then
              textAscii = "New Text!"
              tcItem.mask = %TCIF_Text
              tcItem.lpszText = VarPtr(textAscii)
              Control Handle hDlg, %ID_TAB To hWnd
              SendMessage(hWnd, %TCM_SETITEM, 0, VarPtr(tcItem))
          End If
        End If
      End Function
      **EDIT - too slow!


      • #4
        Chris: Steven:

        Thanks for the pointer. Especially the sample code.