如何在MFC中显示和隐藏选项卡控件 [英] how to show and hide tab control in mfc

查看:214
本文介绍了如何在MFC中显示和隐藏选项卡控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示和隐藏changeTab上的控件.
我在尝试..
在头文件中

I want to show and hide the controls on changeTab.
I am trying..
In header file

struct ITEM
    {
        //HWND h;
        CWnd* wnd;      //our control
        int nID;
        int iTab;       //which tab it belongs to
        BOOL bTabStop;  //does this control allow tabstop
    };


在C ++文件中


In c++ file

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);
		}
	}
}


当我单击Tab 1时,即iTab = 1,它显示Tab 1项,但隐藏Tab 0项.


When I click Tab 1 i.e. iTab=1,It shows Tab 1 item but does hide Tab 0 items.

推荐答案

最简单的方法是为每个标签页创建一个无边界的对话框.在需要的地方创建并放置它们,然后在"ShowTab"函数中显示/隐藏它们.
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.


使用cpropertpage和cmfcpropertysheet
use cpropertpage and cmfcpropertysheet


这篇关于如何在MFC中显示和隐藏选项卡控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆