CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    214

    C++ Winapi - Tab Control

    I have a button that creates a new tab in the tab control, and in the function I have:

    Code:
    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

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: C++ Winapi - Tab Control

    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

  3. #3
    Join Date
    Apr 2008
    Posts
    214

    Re: C++ Winapi - Tab Control

    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.

    Code:
    //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));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured