C, Win32 API: l need help with tab control [Solved]
-
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.
-
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.
-
You need to set the text length.
tie.cchTextMax = wcslen(subject1tab);
Is TC_ITEM the same as TCITEM? TCITEM structure (Windows)[^]
@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.
-
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.
-
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.
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
-
@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.