Click here to Skip to main content
Sign Up to vote bad
good
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:36


2 solutions

Yes (as far as I can tell) you can do it.
You may use the DoDAtaExchange mechanism[^] to perform such task.
  Permalink  
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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 239
1 OriginalGriff 173
2 Maciej Los 135
3 Mahesh Bailwal 104
4 Aarti Meswania 98
0 Sergey Alexandrovich Kryukov 10,214
1 OriginalGriff 7,819
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid