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

    Question win32 tab select notification

    Hi,

    Though I have some experience in win32 API and c++, tab controls continue to elude my understanding. I understand including the comctrl32 lib and header. I know to init common controls. I can create a tab window and add tabs to it.

    I just can't seem to grasp of how to tell when a specific tab has been selected. Searching online for this, the results, I find confusing. I just need to know what to look for with winproc.

    Any help is most appreciated, Tia..

  2. #2
    Join Date
    Dec 2012
    Posts
    2

    Re: win32 tab select notification

    continuing to try figure this out, it is said that a tab control sends a message to wm_nofify with tcn_selchange, so in winproc, i have placed the code:

    Code:
    case WM_NOTIFY:
            {
                  NMHDR *nmhdr = NULL;
                  nmhdr = (NMHDR*)lParam;
                  if(hTabCtrl == nmhdr->hwndFrom)
                  {
                        MessageBox(NULL, "code entered", "info", MB_OK);
                        switch(nmhdr->code)
                        {
                              case TCN_SELCHANGE:
                              }
                                      //do stuff
                              {
                        }
                  }
    hTabCtrl is the handle to the tab control, but the messagebox never appears, so any code in there will not be run.

  3. #3
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: win32 tab select notification

    This is the code I use within WndProc to detect when a tab has been clicked. It always works fine for me. If you are having problems, does your hTabCtrl have the correct value within the case statement? Where is it being set within your code and is it a global variable? Are you seeing any WM_NOTIFY messages for code TCN_SELCHANGE at all? Why don't you test for TCN_SELCHANGE first and then use a MessageBox to display the values of hTabCtrl and nmhdr->hwndFrom? From this info you'll be able to determine what's going on in the code. As shown in my code below, you can combine your first two statements to NMHDR *nmhdr = (NMHDR*)lParam or to just LPNMHDR nmhdr = (LPNMHDR)lParam.

    Code:
    LPNMHDR	tc = (LPNMHDR)lParam;
    
    	case WM_NOTIFY:
    		//Is event for tab change
    		if ((tc->code == TCN_SELCHANGE) && (tc->hwndFrom == g_hwndTab)) {
    			GoNotify(lParam);
    			break;
    		}

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