Click to See Complete Forum and Search --> : dialog box and ddx


Randell H.
April 4th, 1999, 05:26 PM
I have a simple little MFC program that in the main dialog box, it contains a drop down box and 2 radio buttons. What I would like it to do for now is when I click OKAY for it to tell me the values of those variables and NOT close the application. I moved away from OKAY and created another button since OKAY closes the window but the problem is the data isnt being updated. I know you have to use DDX but I just can't get it to work.

void CDiskfix95Dlg::OnModify() {
CDiskfix95Dlg dlg;
MsgBox(MB_OK|MB_ICONINFORMATION, "Letter: %s", dlg.drive_letter);
}
MsgBox is a function posted by another person here. Somehow I need to update the info before the CDiskfix95Dlg dlg part but I havent a clue. Any help would be appreciated.

Randell H.

Randell L. Hodges

Walter I An
April 4th, 1999, 05:58 PM
I am not sure this is what you mean or want to know.

First, if you don't want the dialog box to close,
get rid of CDialog::OnOK() statement from your
OnOK routine. Abd it seems that you didn't even
override OnOK() function.
Secondly, use "UpdateData(TRUE)" before getting the
values from variables.
Finally, I don't know whether you did subclass your controls
by using class wizard. If you didn't, do so.

Good luck. :)

Walter An

anuvk
April 5th, 1999, 06:03 AM
void CDiskfix95Dlg::OnModify()
{
CDiskfix95Dlg dlg;
MsgBox(MB_OK|MB_ICONINFORMATION, "Letter: %s", dlg.drive_letter);
}
Buddy,
The above was the method u used.... There is a big mistake there
You have a dialog class CDiskfix95Dlg
U created a dialog say CDiskfix95Dlg mDial;
mDial.DoModal();
Now in OnModify u create CDiskfix95Dlg dlg;
which is totally different from the dialog u have created earlier.
This is a totally new instance of the object which u have now created in the stack
the drive_letter for m_Dial which is ur dialog and
that for dlg is totally different.

If u have added member variables from class wizard then u need just call
UpdateData()
else u can adhere to the API GetWindowText();

anu