Home > Software engineering >  MFC failed to get the edit box content, how to do?
MFC failed to get the edit box content, how to do?

Time:10-04

I call getline () to obtain the content, is the single line edit box, execution to getline will make a mistake, online tried many methods, the change of various types of buffer, I found that when performing getline, uninitialized CEdit object, the object of the member variables are empty, and then pop up debugging failed prompt dialog box, and why cstrings and the second parameter type is not in conformity with the can?

CodePudding user response:

In the DDX_... Inside the function to add a variable CEW to control the mapping of yet?

CodePudding user response:

DDX_Control (symbol, IDC_EDIT1, CEW);

CodePudding user response:

Getwindowtext give it a try

CodePudding user response:

The
reference 1/f, adlay response:
in the DDX_... Inside the function to add a variable CEW to control the mapping of yet?

added

CodePudding user response:

reference psp7456 reply: 3/f
getwindowtext try

I want to use MFC, I found the call any CEdit function all appear the same mistake,

CodePudding user response:

refer to the second floor VisualEleven response:
DDX_Control (symbol, IDC_EDIT1, CEW);

Write up

CodePudding user response:

 

Int GetEditLine (CEdit & amp; M_Edit, int iTargetLine, cstrings & amp; SzLineVal)
{
Int iRet=0;
SzLineVal. Empty ();
If (m_Edit m_hWnd & amp; & M_Edit. GetLineCount () & gt; ITargetLine)
{
Int iLen=m_Edit. LineLength (iTargetLine) + 1;
IRet=m_Edit. GetLine (iTargetLine, szLineVal GetBuffer (iLen), iLen);
SzLineVal. ReleaseBuffer ();
}
TRACE (_T (" Edit line=% d \ "% s \ " n "), iTargetLine, LPCTSTR szLineVal);

Return iRet;
}

CodePudding user response:

DDX_Control (symbol, IDC_EDIT1, CEW);

CodePudding user response:

Front floor has say very understand, is your CEdit controls may not be associated CEdit variables.

Cross the border and GetLine error, may be an index

CodePudding user response:

"Is the single line edit box"
NIndex

Specifies the line number to retrieve the from a multiple - line edit control. The line Numbers are zero - -based; A value of 0 specifies the first line. This parameter is ignored by a single - line edit contro l.
  • Related