Click here to Skip to main content
12,754,334 members (29,987 online)
Rate this:
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 1:36am
Rate this: bad
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.
Rate this: bad
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()

VariableA = 100 - VariableB;



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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2017
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