Click to See Complete Forum and Search --> : C++ Winapi - Tab Control


zaryk
December 6th, 2008, 07:58 PM
I have a button that creates a new tab in the tab control, and in the function I have:


int selCur = TabCtrl_GetItemCount(progTab);
....
....
SendMessage(progTab, TCM_SETCURSEL, selCur, 0);


This selects the the newest created tab, but does not Send a message to WM_NOTIFY - TCN_SELCHANGE.

In my TCN_SELCHANGE I have it change the text of the main window, so it does not change the text for the first tab created at creation time or any added with the button. It will only change the text when i click the tabs.

What would I need to do to? any ideas

kirants
December 6th, 2008, 10:20 PM
The documentation for TCM_SETCURSEL explicitly mentions that no TCN_SEL* WM_NOTIFY messages are sent. I suggest after sending the setcursel, check it's return value and if ok, just call the same function that you would call in response to TCN_SELCHANGE

zaryk
December 7th, 2008, 08:44 PM
I go this to work....right now, it just changes the main window text to a number, but will eventually be changed to a name or something, easy change though.


//WM_CREATE:
CreateControls(hwnd);
char buffer[33];
if(count == 1){
SetWindowText(hwnd, itoa(1,buffer,10));
}
//WM_COMMAND - case id_FileNew:
CreateTabs(progTab);
char buffer[33];
int count = TabCtrl_GetItemCount(progTab);
if(count == count){
SetWindowText(hwnd, itoa(count,buffer,10));
}
//WM_NOTIFY - case TCN_SELCHANGE:
char buffer[33];
int count = TabCtrl_GetCurSel(progTab)+1;
SetWindowText(hwnd, itoa(count,buffer,10));