Home > Software engineering >  Why two EDIT transfer value in MFC? thank you
Why two EDIT transfer value in MFC? thank you

Time:10-07

I in two different dialog interface design for two edit controls, the first interface is IDC_EDIT1, the second interface is IDC_EDIT2:
Corresponding variables: m_PARA1 m_PARA2;
I want to achieve, after input IDC_EDIT1 value, namely m_PARA1, then m_PARA2=m_PARA1;
Cstrings STR.
STR. The FORMAT (_T (" % d ", m_PARA1);
SetDlgItemText (IDC_EDIT2, STR);
Why was value less than a second in the EDIT interface, thank you.

CodePudding user response:

CEdit2. The UpdateData ();//?

CodePudding user response:

Have to refresh the data, do not shown in the EIDT2 EDIT1 of values

CodePudding user response:

When Edit a message input character triggered ON_EN_CHANGE
In the news writing
M_edit2=m_edit1;
The Updatedata (true);//refresh control value to the corresponding variable
The Updatedata (false);//copy a variable's value to the display control

CodePudding user response:

reference SWWLLX reply: 3/f
Edit a message input character trigger ON_EN_CHANGE
In the news writing
M_edit2=m_edit1;
The Updatedata (true);//refresh control value to the corresponding variable
The Updatedata (false);//copy a variable's value to control display



The following is my way, just my IDC_MaxElectric equivalent to EDIT2 controls, after EDIT1 control interface, press OK, handle the following procedures section, and close the interface, but the data did not refresh to IDC_MaxElectric, data acquisition and so on all is no problem (because USB sent to the next bit machine displayed is my input value), but is always wrong.
The UpdateData (TRUE);
Paramemters. MaxCurrent_mA=Paramemters. Offset_up;
Cstrings max_current;
Max_current. The Format (_T (" % d "), Paramemters. MaxCurrent_mA);
SetDlgItemText (IDC_MaxElectric max_current);//the default maximum 10000 ma
The UpdateData (FALSE);

CodePudding user response:

Numerical transfer between different dialog box with a message

CodePudding user response:

SetDlgItemText
The SetDlgItemText function sets The title or The text of a control in a dialog box.

BOOL SetDlgItemText (
HWND hDlg,//handle of dialog box
Int nIDDlgItem,//identifier of the control
LPCTSTR lpString//text to set
);
"Two different dialog interface" need different hDlg

CodePudding user response:

How did you get IDC_EDIT1 control value? M_PARA1 value is IDC_EDIT1 control class variables, not value your input, you need to input value is a string
Control class variables, called SetDlgItemText (), to the corresponding ID control assigned you to display the string.
Cstrings _strtemp;//IDC_EDIT1 controls to display the value of the
M_PARA1. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT1 controls show
M_PARA2. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT2 display control

CodePudding user response:

How did you get IDC_EDIT1 control value? M_PARA1 value is IDC_EDIT1 control class variables, not value your input, you need to input value is a string
Control class variables, called SetDlgItemText (), to the corresponding ID control assigned you to display the string.
Cstrings _strtemp;//IDC_EDIT1 controls to display the value of the
M_PARA1. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT1 controls show
M_PARA2. SetDlgItemText (IDC_EDIT2 _strtemp)//IDC_EDIT2 display control

CodePudding user response:

refer to 7th floor qq_29700255 response:
how did you get IDC_EDIT1 control value? M_PARA1 value is IDC_EDIT1 control class variables, not value your input, you need to input value is a string
Control class variables, called SetDlgItemText (), to the corresponding ID control assigned you to display the string.
Cstrings _strtemp;//IDC_EDIT1 controls to display the value of the
M_PARA1. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT1 controls show
M_PARA2. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT2 controls show

M_PARA2. SetDlgItemText (IDC_EDIT2 _strtemp)//IDC_EDIT2 control display, careless write wrong, sorry

CodePudding user response:

references 9 f qq_29700255 response:
Quote: refer to 7th floor qq_29700255 response:

How did you get IDC_EDIT1 control value? M_PARA1 value is IDC_EDIT1 control class variables, not value your input, you need to input value is a string
Control class variables, called SetDlgItemText (), to the corresponding ID control assigned you to display the string.
Cstrings _strtemp;//IDC_EDIT1 controls to display the value of the
M_PARA1. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT1 controls show
M_PARA2. SetDlgItemText (IDC_EDIT1 _strtemp)//IDC_EDIT2 controls show

M_PARA2. SetDlgItemText (IDC_EDIT2 _strtemp)//IDC_EDIT2 controls showed that careless mistakes, sorry


Thank you for your warmly reply, I can't add the control variable, in the wizard's grey, doesn't allow me to add oh, strange that this problem bothering me for a day, I got your answer, but I know how the basic, thank all of you,

CodePudding user response:

Statictxt control becomes a property change id can add a variable

CodePudding user response:

You two dialog box must be wrong.
Before you EDIT1 destroyed the EDIT1 value assigned to a global variable you then edit2=global variables can you understand?
Or when you are in the destruction of the dialog box to another send a custom message dialog (take parameters to) send another dialog box

CodePudding user response:

Use a message or
: : SetDlgItemText (hanle, id, STR);
  • Related