Click to See Complete Forum and Search --> : Message from a dialog


Dafydd
July 12th, 1999, 05:25 AM
Hi,

Is it possible to get a button in a dialog to return a value to the view in a similar way to the OK and CANCEL buttons in a dialog?

I have placed a button in a dialog, called IDC_BUTTON_1 for example, and I would like to be able to do something like:

int response = dlg.DoModal();

if (responce == IDBUTTON1)
{
// Button 1 has been pressed.
}

if (response == IDOK)
{
// The OK button was pressed.
}

in the View i.e. once the button is pressed the dialog finishes (exactly as if OK had been pressed) and the View is given an opportunity to proceed with appropriate calculations.

Can anybody point me in the right direction to do this?

Thanks in advance

Dave

Le Sant Yves
July 12th, 1999, 05:57 AM
Hi

Your button should close the dialog, using EnDialog:

void CMyDialog::OnButton1()
{
// your stuff
EndDialog(IDC_BUTTON1);
}




this assumes that IDC_BUTTON1 exists, that is typically the ID associated to your button.
It is EndDialog that send the relevant message

HTH

Yves Le Sant
Metrology and Measurement Unit
Fundamental and Experimental Aerodynamics Departement
ONERA Meudon
(Office National d'Etudes et de Recherches Aérospatiales)
FRANCE