Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am currently having problems trying to code Tab control using Property Sheets and Property Pages. My first version of my work is a single dialog box, now due to the many components, I wish to put them in tabs instead.

I am able to get the tab dialog out without any problems thanks to the tutorials here. However it seems like the tabs (IDD_PROPPAGE_LARGE) does not have the OnInitDialog() method which is used to initialize a normal dialog box. I tried to add the code before I add the property page to the sheet but it gives an error that
the component is null.

C++
[code]
// 

// previously:
BOOL CDialogTest1::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	CEdit *pEdit1 = (CEdit*) GetDlgItem(IDC_EDIT1); // unable to get CWnd here
        pBtn1->SetWindowText(CString("XXX"));

	//init flags
	mFlaga = false;
        mFlagb = false;
        mFlagc = false;
	mMsgLen   = 0;

// .........
[/code]


The second problem i am facing is that when a component e.g. a button in a tab dialog is pressed, it will update another tab dialog's mfc component e.g. list control. is that possible?
Posted

Download the property sheet sample from here[^].

The second problem i am facing is that when a component e.g. a button in a tab dialog is pressed, it will update another tab dialog's mfc component e.g. list control. is that possible?

Yes.
 
Share this answer
 
Comments
Zsefv2 19-Sep-11 4:52am    
how do you actually do this? any links etc to demonstrate?
Malli_S 19-Sep-11 7:36am    
You can use SendMessage() mechanism to communicate the event. And on the receive of this event, the other dialog/tab will perform the required control updated.
Zsefv2 19-Sep-11 23:19pm    
ok thanks...
Generally, I use the following structure when I deal with PropertySheet

Works well.

Code example creates a property sheet styled dialog, in my case it is handled in CMainFrame class but you could equally handle it in View or Document

void CMainFrame::OnOptions()
{
	CPropertySheet psheet;
	CPropPage1 p1;		// CPropPage1 derived from CPropertyPage
	CPropPage2 p2;		// CPropPage2 derived from CPropertyPage
			
	//
	// Init is a custom method implemented in CPropPage1 and CPropPage2
	// For example, you may want to initialize data in property page objects
	//
	p1.Init();		
	p2.Init();
		
	// set the title
	psheet.SetTitle("My Options",0);

	//add all the pages into the PropertySheet
	psheet.AddPage(&p1);
	psheet.AddPage(&p2);
	
	//
	// The first call to this will cause An exception which is safely handled by OS
	// See Microsoft's explanation
	// http://support.microsoft.com/kb/q158552/
	//
	// Display the property sheet...
	if (psheet.DoModal() == IDOK)
	{
		//
		// PostProcessing is a custom method implemented in CPropPage1 and CPropPage2
		// For example, you may want to copy data from p1 and p2 to your document
		//
		p1.PostProcessing();
		p2.PostProcessing();
	}
}
 
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