Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MFC app with a dialog with two edit controls which both have variables, eg. VariableA and VariableB. I want to initialize VariableA as value of 80, so when the dialog box displays the edit control it shows 80, but if the user changes variableB it must then automatically change VariableA = (100 - VariableB).

I hope this makes sense.
Posted

Yes (as far as I can tell) you can do it.
You may use the DoDAtaExchange mechanism[^] to perform such task.
 
Share this answer
 
Thanks for the response however I think I figured it out.

In my CMyDlg.cpp

I initialized the variableA = 80

I then used ON_EN_UPDATE for the Edit control.


void CMyDlg::OnEnUpdateEDITVARIABLEA()
{
UpdateData();

VariableA = 100 - VariableB;


UpdateData(FALSE);

}

This way the edit control shows 80 for VariableA when I open up the dialog, but when I change VariableB it shows the value of 100 - VariableB.
 
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