Tab Control issue

This is a discussion on Tab Control issue within the Windows Programming forums, part of the Platform Specific Boards category; Is there a special message that I am not aware of being sent to my main window procedure that indicates ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    132

    Tab Control issue

    Is there a special message that I am not aware of being sent to my main window procedure that indicates a tab on a tab control being clicked on? (One of the tabs?) I've tried WM_LBUTTONUP messages, but no reaction when I click the tabs.

    The tab control was created using the WS_CHILD style and is attached the main window of my program. I've looked on MSDN except that I can't seem to find a message sent for such an occurance, though I may be mistaken.

    Any help would be greatly appreciated.
    Tyouk

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    132
    Okay I somewhat figured this out by digging deeper into the MSDN archives there. Now the code is as follows (so far):

    Code:
    case WM_NOTIFY:
    			if( sizeof(*(lParam)) == sizeof(NMMOUSE) )
    			{
    				pnmm = (NMMOUSE *)(LPARAM)lParam;
    				if( pnmm->hdr.code == NM_CLICK )
    				{
    					ZeroMemory(&tcHitTest, sizeof(TCHITTESTINFO));
    					tcHitTest.pt.x = pnmm->pt.x;
    					tcHitTest.pt.y = pnmm->pt.y;
    					tab = TabCtrl_HitTest(hTC_Wnd, &tcHitTest);
    				}
    			}
    			else
    			{
    				pnmh = (NMHDR *)(LPARAM)lParam;
    				if( pnmh->code == NM_CLICK )
    				{
    					ZeroMemory(&tcHitTest, sizeof(TCHITTESTINFO));
    					tcHitTest.pt.x = ; // TODO: determine how to get this value
    					tcHitTest.pt.y = ; // TODO: determine how to get this value
    					tab = TabCtrl_HitTest(hTC_Wnd, &tcHitTest);
    				}
    			}
    
    			// check to see which tab (if any) were clicked
    			if( tab != -1 )
    			{
    				if( tab == 0 )
    					MessageBox(NULL, "EzBooks tab was hit.", "HitTest", MB_OK);
    				else if( tab == 1 )
    					MessageBox(NULL, "Income tab was hit.", "HitTest", MB_OK);
    				else if( tab == 2 )
    					MessageBox(NULL, "Expenses tab was hit.", "HitTest", MB_OK);
    				else if( tab == 3 )
    					MessageBox(NULL, "Payroll tab was hit.", "HitTest", MB_OK);
    				else if( tab == 4 )
    					MessageBox(NULL, "Assets tab was hit.", "HitTest", MB_OK);
    				else if( tab == 5 )
    					MessageBox(NULL, "Reports tab was hit.", "HitTest", MB_OK);
    				else
    					MessageBox(NULL, "Unknown tab was hit.", "HitTest Unknown", MB_OK);
    			}
    			break;
    Now it's still not giving me any message boxes (the last if statement). Am I even on the right track, or am I completely off? Please let me know. (I determined that as per the specs on the NM_CLICK notification, that since lParam could infact be a larger structure then NMHDR struct, this larger struct would have an NMHDR struct as the first param of the larger struct... thus the NMMOUSE struct was a logic choice considering that it involves mouse clicks as well as has an NMHDR struct as it's first param. Thus why I check to see the size of the struct first, now I was never the best on pointers so please correct me if my comparison between the two is incorrect sizeof(*(lParam)) == sizeof(NMMOUSE)?

    Thanks for any help,
    Tyouk

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Is there a special message ... that indicates a tab on a tab control being clicked on?<<

    Check for the TCN_SELCHANGE notification and then use TCM_GETCURSEL or the TabCtrl_GetCurSel macro to determine which tab is selected.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    132
    Thanks, fixed my problems.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. Tab order in Tab Control
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 05-09-2005, 12:08 AM
  3. tab control
    By tyouk in forum Windows Programming
    Replies: 6
    Last Post: 02-07-2005, 11:47 PM
  4. Disable a tab in control tab?
    By Iron Mike in forum Windows Programming
    Replies: 1
    Last Post: 07-23-2003, 11:50 AM
  5. Using Tab control to change between dialogs
    By Eado in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 04:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21