Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I want to show and hide the controls on changeTab.
I am trying..
In header file
CSS
struct ITEM
    {
        //HWND h;
        CWnd* wnd;      //our control
        int nID;
        int iTab;       //which tab it belongs to
        BOOL bTabStop;  //does this control allow tabstop
    };

In c++ file
C++
m_cTab.InsertItem(0,"Register new user");
	m_cTab.InsertItem(1,"Identify fingerprints");



void CMyTabCtrl::ShowTab(int iTab)
{
	
	iCtrl = -1;//reset any control which may be selected in a tab

	if(iCurrentTab == iTab)//already focused on selected tab
	{
		return;
	}
	//save old tab location so we can hide its controls
	int iOldTab = iCurrentTab;
	iCurrentTab = iTab;
		
	//check if tab is in focus, if not, put it in focus
	int t = GetCurFocus();
	if(iTab != t)
	{
		SetCurSel(iTab);
	}

	//hide old tabs controls, show the selected tab's controls
	INT_PTR iCount = obArray.GetCount();
	for(INT_PTR i=0; i<iCount; i++)
	{
		
		ITEM* pItem = (ITEM*)obArray[i];
		if(pItem->iTab == iOldTab)
		{
			pItem->wnd->ShowWindow(SW_HIDE);
		}
		else if(pItem->iTab == iCurrentTab)
		{
			pItem->wnd->ShowWindow(SW_SHOW);
		}
	}
}

When I click Tab 1 i.e. iTab=1,It shows Tab 1 item but does hide Tab 0 items.
Posted
Comments
Joan M 19-Sep-12 6:23am    
I've always found more easy to use the CPropertySheet and CPropertyPage classes, the hiding/showing work is already implemented, and it is easy to setup as each page is a dialog which has its own objects and logics...
Of course this is only a comment and my opinion, and of course it is not answering in any way the question you've posted. Sorry for that.

The easiest way to do what your trying to do would be to create a borderless dialog for each tab page. Create and place them where they need to be and then show/hide them in your "ShowTab" function.
 
Share this answer
 
use cpropertpage and cmfcpropertysheet
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900