Hi,

I have 2 dialog boxes. In the first dialog i'm getting input from the user to add two numbers and in the other dialog I'm printing the value.
i.e., when i click on the add button on the first dialog , the current dialog shoud close and it must open the dialog that displays result. and again when i click on the OK button on the second dialog, it should close the current dialog and call the first dialog again.

I'm able to call the second dialog from first one, but i dont know how to close and reopen it again.

can somebody help me..........

Dialog 1

void CMfctestDlg::Sum() 
{
	UpdateData (true);
	this->SetWindowText("Result");
	Result *obj = new Result;
	obj->Create(IDD_DIALOG1, this);
	obj->ShowWindow(SW_SHOW);
	obj->Final_Result (m_arg1, m_arg2);
		
}

Dialog 2

void Result::Final_Result(int i, int j)
{
	m_result = i + j;
	UpdateData (false);
}

Recommended Answers

All 5 Replies

I just do it like this:

void CMfctestDlg::Sum() 
{
    UpdateData (true);
    this->SetWindowText("Result");
    Result obj;
    obj.Final_Result (m_arg1, m_arg2);
    obj.DoModal();
	
}

I just do it like this:

void CMfctestDlg::Sum() 
{
    UpdateData (true);
    this->SetWindowText("Result");
    Result obj;
    obj.Final_Result (m_arg1, m_arg2);
    obj.DoModal();
	
}

I'm getting Debug assertion Failed error when i use the above code.....
As a part of big project i want to close or hide the main dialog when the other dialogs are called......and when the current dialog is closed , the main dialog should come into picture.......

i dont know how to achieve this........need your help

You don't really close the current dialog --just hide it with ShowWindow(SW_HIDE)

I don't know why you are getting that assert error.

You don't really close the current dialog --just hide it with ShowWindow(SW_HIDE)

I don't know why you are getting that assert error.

hi ,

when the EndDialog(IDC_ID) is added its working fine with DoModal.....

but when the other dialog opens it doesn't open in the center, instead it opens to the sides.....

is there any way to open a dialog to specific co-ordinates

thank you.......

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.