Home > Software engineering >  MFC edit box GetWindowText gain value problem
MFC edit box GetWindowText gain value problem

Time:09-18

 
Double CDlgWallDraw: : GetWallWidth ()
{
Double dWallWidth;
Cstrings strSam;
M_edtWallWidth. GetWindowText (strSam);
DWallWidth=_tstof (strSam);
Return dWallWidth;
}

This is access to value the function of the edit box, debugging ran to the GetWindowText strSam didn't change ah, there is always empty, consult,
The model window can get normal value, change to be modal is wrong

CodePudding user response:

Is there the UpdateData (TRUE);

CodePudding user response:

reference 1st floor Mr_sandman1994 response:
have the UpdateData (TRUE);


Bound controls the Updatedata type variable need?
I change to be used in the double directly with, but the GetWindowText still didn't understand,

CodePudding user response:

refer to the second floor G_carota response:
Quote: refer to 1st floor Mr_sandman1994 response:

Is there the UpdateData (TRUE);


Bound controls the Updatedata type variable need?
I change to be used in the double directly take, but the GetWindowText still didn't understand,

To bind variables also need the UpdateData (TRUE);
UpdateData(TRUE);
UpdateData(FALSE);
Want to distinguish

CodePudding user response:

M_edtWallWidth DDX_Control associated useful? To set breakpoints view
Can directly use GetDlgItemText (IDC_EDITXXX strSam); Try

CodePudding user response:

Variables associated with the wizard to create directly.

CodePudding user response:

Feel like no DDX_Control associations,
Suggest directly use ID try, GetDlgItemText (ID) - & gt; GetWindowText (strSam);

CodePudding user response:

With GetDlgItemText directly (IDC_EDITXXX strSam);

The most ugly is the UpdateData in MFC, who wrote it shit function, I go,

CodePudding user response:

Look at the 4th floor know, whether the control associated with the control variables

CodePudding user response:

Don't associated variables,
With GetDlgItemText directly (IDC_EDITXXX strSam);

CodePudding user response:

Because of bound variables, so we need to update, from interface updates to variables, from variable update interface.

CodePudding user response:

Void CTestDlg: : OnBtnAdd ()
{
Int num1, num2 num3;
Char ch1 [10], ch2 [10], ch3 [10].
GetDlgItem (IDC_EDIT1) - & gt; GetWindowText (ch1, 10);
GetDlgItem (IDC_EDIT2) - & gt; GetWindowText (ch2, 10);

Num1=atoi (ch1);
Num2=atoi (ch2);
Num3=num1 + num2;

Itoa (num3, ch3, 10);
GetDlgItem (IDC_EDIT3) - & gt; SetWindowText (ch3);
}

With reference to this case, there is no when it comes to key points, the key point is the error, the somebody else to two parameters, you give a parameter, not to value, your program no natural!

CodePudding user response:

The garbage updatedate function, or direct GetDlgItem (IDC_EDIT1) - & gt; GetWindowText (ch1, 10); To get the data!
  • Related