Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C, Win32 API: l need help with tab control [Solved]

C, Win32 API: l need help with tab control [Solved]

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12105981
    wrote on last edited by
    #1

    Good day. Please am writing an application, though things are going good. But am stucked in the area where l need to copy the text of what the user selected from a combo box and use that text to initialize the text field of the TC_ITEM struct to show on the tab control. l had tried many tactics. Code snippet below:

    static WCHAR subject1tab[MAX_LOADSTRING]; //max_loadstring =100

    INITCOMMONCONTROLSEX icce = {0};
    TC_ITEM tie={0};
    icce.dwICC=ICC_TAB_CLASSES;
    icce.dwSize=sizeof(INITCOMMONCONTROLSEX);
    InitCommonControlsEx(&icce);

    tie.mask = TCIF_TEXT;
    subjecthwnd=GetDlgItem(hwnd,IDC_UNICALPTUME_SUBJECT1);//I used GetDlgItem to get the handle of the combobox, from whih the text is to be copied from.

    GetWindowText(subjecthwnd,subject1tab,100);//Copy the text of what the user selected from the combobox

    tie.pszText=subject1tab;

    SendMessage(SubjectTabs,TCM_INSERTITEM,(WPARAM)0,(LPARAM)&tie);//add a tab

    So please can someone help me on how to get the text string of selection from a combobox and use it to initialize a tab. Thanks in advance.

    L D 3 Replies Last reply
    0
    • U User 12105981

      Good day. Please am writing an application, though things are going good. But am stucked in the area where l need to copy the text of what the user selected from a combo box and use that text to initialize the text field of the TC_ITEM struct to show on the tab control. l had tried many tactics. Code snippet below:

      static WCHAR subject1tab[MAX_LOADSTRING]; //max_loadstring =100

      INITCOMMONCONTROLSEX icce = {0};
      TC_ITEM tie={0};
      icce.dwICC=ICC_TAB_CLASSES;
      icce.dwSize=sizeof(INITCOMMONCONTROLSEX);
      InitCommonControlsEx(&icce);

      tie.mask = TCIF_TEXT;
      subjecthwnd=GetDlgItem(hwnd,IDC_UNICALPTUME_SUBJECT1);//I used GetDlgItem to get the handle of the combobox, from whih the text is to be copied from.

      GetWindowText(subjecthwnd,subject1tab,100);//Copy the text of what the user selected from the combobox

      tie.pszText=subject1tab;

      SendMessage(SubjectTabs,TCM_INSERTITEM,(WPARAM)0,(LPARAM)&tie);//add a tab

      So please can someone help me on how to get the text string of selection from a combobox and use it to initialize a tab. Thanks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to set the text length.

      tie.cchTextMax = wcslen(subject1tab);

      Is TC_ITEM the same as TCITEM? TCITEM structure (Windows)[^]

      U 1 Reply Last reply
      0
      • L Lost User

        You need to set the text length.

        tie.cchTextMax = wcslen(subject1tab);

        Is TC_ITEM the same as TCITEM? TCITEM structure (Windows)[^]

        U Offline
        U Offline
        User 12105981
        wrote on last edited by
        #3

        @blingg: TC_ITEM is same as TCITEM but according to MSDN, TCITEM supercedes TC_ITEM. However, l have done the corrections, still it doesn't work. l also used SendMessage, still yet no avail. l don't know what's wrong.

        L 1 Reply Last reply
        0
        • U User 12105981

          Good day. Please am writing an application, though things are going good. But am stucked in the area where l need to copy the text of what the user selected from a combo box and use that text to initialize the text field of the TC_ITEM struct to show on the tab control. l had tried many tactics. Code snippet below:

          static WCHAR subject1tab[MAX_LOADSTRING]; //max_loadstring =100

          INITCOMMONCONTROLSEX icce = {0};
          TC_ITEM tie={0};
          icce.dwICC=ICC_TAB_CLASSES;
          icce.dwSize=sizeof(INITCOMMONCONTROLSEX);
          InitCommonControlsEx(&icce);

          tie.mask = TCIF_TEXT;
          subjecthwnd=GetDlgItem(hwnd,IDC_UNICALPTUME_SUBJECT1);//I used GetDlgItem to get the handle of the combobox, from whih the text is to be copied from.

          GetWindowText(subjecthwnd,subject1tab,100);//Copy the text of what the user selected from the combobox

          tie.pszText=subject1tab;

          SendMessage(SubjectTabs,TCM_INSERTITEM,(WPARAM)0,(LPARAM)&tie);//add a tab

          So please can someone help me on how to get the text string of selection from a combobox and use it to initialize a tab. Thanks in advance.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You first need to check that you are actually retrieving some text from your control. Is this code inside the dialog that holds the combobox? You also need to set the text length in your TCITEM before sending the TCM_INSERTITEM message.

          1 Reply Last reply
          0
          • U User 12105981

            Good day. Please am writing an application, though things are going good. But am stucked in the area where l need to copy the text of what the user selected from a combo box and use that text to initialize the text field of the TC_ITEM struct to show on the tab control. l had tried many tactics. Code snippet below:

            static WCHAR subject1tab[MAX_LOADSTRING]; //max_loadstring =100

            INITCOMMONCONTROLSEX icce = {0};
            TC_ITEM tie={0};
            icce.dwICC=ICC_TAB_CLASSES;
            icce.dwSize=sizeof(INITCOMMONCONTROLSEX);
            InitCommonControlsEx(&icce);

            tie.mask = TCIF_TEXT;
            subjecthwnd=GetDlgItem(hwnd,IDC_UNICALPTUME_SUBJECT1);//I used GetDlgItem to get the handle of the combobox, from whih the text is to be copied from.

            GetWindowText(subjecthwnd,subject1tab,100);//Copy the text of what the user selected from the combobox

            tie.pszText=subject1tab;

            SendMessage(SubjectTabs,TCM_INSERTITEM,(WPARAM)0,(LPARAM)&tie);//add a tab

            So please can someone help me on how to get the text string of selection from a combobox and use it to initialize a tab. Thanks in advance.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Member 12139442 wrote:

            So please can someone help me on how to get the text string of selection from a combobox and use it to initialize a tab.

            So which do you need help with? They are mutually exclusive things. If subject1tab contains the correct, expected value, then retrieving text from a combobox has nothing to do with your issue.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            1 Reply Last reply
            0
            • U User 12105981

              @blingg: TC_ITEM is same as TCITEM but according to MSDN, TCITEM supercedes TC_ITEM. However, l have done the corrections, still it doesn't work. l also used SendMessage, still yet no avail. l don't know what's wrong.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Set tie.iImage to -1 and make sure SubjectTab is a valid tab control HWND.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups