I am using mfc and I have a *.rc file containing a number of dialogs. I have modified one of the dialogs to include a tab control (dragged from the dialog editor in design mode). When the file is opened in textpad, that dialog now looks like this:

--------------------------------------------------------------------------------------------------------

IDD_ABOUTBOX DIALOGEX 0, 0, 467, 402
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
    WS_SYSMENU
CAPTION "About"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    LTEXT           "",IDC_STATIC_TITLE,15,11,199,9,SS_NOPREFIX
    LTEXT           "Version 1.00.01 (Alpha)",IDC_STATIC_VERSION,14,23,70,8
    LTEXT           "Copyright © 1995-2007 Corporation. All rights reserved",
                    IDC_STATIC,14,34,210,18
    LTEXT           "",IDC_SYSTEM_INFO,15,56,211,74
    GROUPBOX        "Patch Summary",IDC_PATCH_SUMMARY,15,145,420,226,0,
                    WS_EX_TRANSPARENT
    CONTROL         148,IDC_LOGO_IMAGE,"Static",SS_BITMAP | SS_CENTERIMAGE,
                    408,4,55,55,WS_EX_TRANSPARENT
    DEFPUSHBUTTON   "&OK",IDOK,413,384,50,14,WS_GROUP
    CONTROL         "",IDC_PATCH_SUMMARY_TAB,"SysTabControl32",0x0,17,
                    157,416,211
END

--------------------------------------------------------------------------------------------------------

The following are the DoDataExchange() and OnInitDialog() fns for the dialog. I know I have to create a property sheet for each tab, and I think I have to add something along the lines of DDX_Control(pDX, IDC_PATCH_SUMMARY_TAB, ). How do modify the tab control and what should be the final parameter of DDX_Control?

--------------------------------------------------------------------------------------------------------

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_LOGO_IMAGE, m_Image);
	DDX_Text(pDX, IDC_STATIC_TITLE, m_strTitle);
	DDX_Text(pDX, IDC_STATIC_VERSION, m_strVersion);
	DDX_Text(pDX, IDC_SYSTEM_INFO, m_strSystemInfo);
	//}}AFX_DATA_MAP
}

//OnInitDialog. Setup the list for snap-in version information.
BOOL CAboutDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	CString strAppName;
	m_strTitle = gpNamespaceMgr->GetSuiteProductName() + L" " + gpNamespaceMgr->GetSuiteProductVersion();
	m_strVersion = L"Version " + CString((LPCTSTR) IDS_VSOC_VERSION);
	if(gpMainMap)
	{
		CPSApplication* pApplication =
				(CPSApplication*)gpMainMap->GetRuntimetObject(
									_T("\\VigilEnt Asset Map\\"));
		if(pApplication)
		{
			CCoreServices * pCore = pApplication->GetCoreServices();
			if(pCore)
				m_strSystemInfo = pCore->GetVersionInfo();
		}
	}

	CString strTemp = L"About " + gpNamespaceMgr->GetSuiteProductName();
	SetWindowText(strTemp);
	UpdateData(FALSE);
	return TRUE;
}

--------------------------------------------------------------------------------------------------------

Thanks!

Recommended Answers

All 4 Replies

go to www.codeprject.com and search for tab control examples. They have a lot of mfc code that you can look at to see how its done.

go to www.codeprject.com and search for tab control examples. They have a lot of mfc code that you can look at to see how its done.

Thanks Ancient Dragon, that was a big help. However, I am still having trouble. I want the each tab of the tab control to display another dialog in the rc file. The following is my code:

int idx = 0;
	TC_ITEM TabCtrlItem;
	TabCtrlItem.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;

	TabCtrlItem.pszText = L"Console";
	TabCtrlItem.iImage = 0;
	TabCtrlItem.lParam = IDD_PATCH_SUMMARY;
	m_ctrlTab.InsertItem(0, &TabCtrlItem);

	TabCtrlItem.pszText = L"Core Services";
	TabCtrlItem.iImage = 1;
	TabCtrlItem.lParam = IDD_PATCH_SUMMARY;
	m_ctrlTab.InsertItem(1, &TabCtrlItem);

	TabCtrlItem.pszText = L"Database";
	TabCtrlItem.iImage = 2;
	TabCtrlItem.lParam = IDD_PATCH_SUMMARY;
	m_ctrlTab.InsertItem(2, &TabCtrlItem);

	m_ctrlTab.SetCurSel(0);

When I bring up the parent dialog, the Tabs show up with the correct titles, as specified by psztext, but they are blank. IDD_PATCH_SUMMARY is not visible. Any suggestions? Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.