Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
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 28-Sep-12 0:36am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes (as far as I can tell) you can do it.
You may use the DoDAtaExchange mechanism[^] to perform such task.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100