• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

how do i access controls (e.g. EDIT control) on a child dialog from the parent dialog.

Im working on a parent dialog with a tabcontrol. Im using 3 child dialogs for the 3 tabs. Each of the child dialogs has EDIT controls and COMOBOXES. The parent dialog has 2 buttons, OK and CANCEL. CANCEL is for exiting the application and works fine. In button OK, I would like to get all the values entered in the child dialog controls in the 3 tabs. The code snippet include below is for this button and shows the error: Debug Assertion Failed! I have tried in vain to fix this problem.

Can someone please tell me how i can get the text values of the controls on the child dialogs from the parent dialog?
void CMyTabExampleDlg::OnOK() 
{
	// TODO: Add extra validation here
	MessageBox("aaa");
	MessageBox("bbb");	
	m_Tab1.UpdateData(TRUE);
	MessageBox("ccc");
	MessageBox(m_Tab1.m_EDITPNO);
	MessageBox("ddd");
	
 
}

Open in new window

0
VbMonk
Asked:
VbMonk
  • 3
  • 3
1 Solution
 
DanRollinsCommented:
Normally, one would use CPropertySheet and CPropertyPage objects with that kind of setup.  These provide the functionality that you describe and also provide handy functions for accessing the property pages data.
What is the message that comes up with the assertion?
 
0
 
VbMonkAuthor Commented:
thanx sage, for the response. I gonna have to try the property sheets. Do you have sample code or website with an example you can refer me to?
0
 
DanRollinsCommented:
The Microsoft site is always a good place to start:
    CPropertySheet Class  
    http://msdn.microsoft.com/en-us/library/d3fkt014(VS.80).aspx
Codeguru has lots of examples -- most of them extend the class to do special things with it, but they always include a working example:
    http://www.codeguru.com/cpp/controls/propertysheet/propertysheetbuttons/article.php/c577/
    http://www.codeguru.com/cpp/controls/propertysheet/article.php/c593/
    http://www.codeguru.com/cpp/controls/propertysheet/sizing/article.php/c599/
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
VbMonkAuthor Commented:
hey, thanx a lot.
btw, im using visual studio 6 C++. I hope I wont get any problems.
0
 
VbMonkAuthor Commented:
Ive tried the propertysheet and propertypages but i dont seem to get it to get text from controls (comboboxes, edit boxes, check boxes etc). Please help me with some example of how to get this data. At the moment im using this piece of code which crashes on p->GetdlgItemText......Im doing this inside A cpp file of one of the propertypages. Please help!!
void CPage1::OnRunSchedule() 
{
	// TODO: Add your command handler code here
	UpdateData(true);
	CPage1 p1;
	CPage1 *p;
	CString s;
	MessageBox("aaa");
	p->GetDlgItemText(IDC_EDITPNO,s);
	MessageBox(s);

Open in new window

0
 
DanRollinsCommented:
MFC makes this easy.  Use the ClassWizard (Ctrl+W).  Select a CPropertyPage-derived object and click the Member Variables tab.  Now you can create a variable that relates to a control ID and MCE will transfer the user input into that variable.   Also, by pre-setting the variable before showing the page, MFC will preset default values into the controls for you.
 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now