C, Win32 API: l need help with tab control

Hi friends
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.
Last edited on
GetWindowText does not always work with Comboboxes.

Try SendMessage with either CB_GETCURSEL or WM_GETTEXT.

Here is a good tutorial about comboboxes:
http://www.functionx.com/win32/controls/combobox.htm
@Thomas1965: Thanks, but l also did that but it didn't work.
Last edited on
Might be worth to check the return values from GetDlgItem and GetWindowText.
@Thomas1965: this is a good clue to getting the pothole. Solved
Topic archived. No new replies allowed.