Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I make some function.
When user type value on edit control, the value is filtered my some condition.
I change codes. I just show on some parts of my codes.
Can you check my codes and give better way?

C++
void CSerialTestDlg::SetGainData()
{  

  std::wstring a=L"";  
  std::wstring a2=L"";
  std::wstring a3=L"";
 
  CString cstr="";
  CString cstrB="";
  CString cstrC="";
  
  int iLength=0;

  int *GainData = new int[3];
  memset(GainData,0x00,sizeof(int)*3);

  iLength=  Edit_VGain.GetWindowTextLengthA();
  a.resize(iLength);
  cstr = a.c_str();
  Edit_VGain.GetWindowTextA(cstr);

  iLength=  Edit_AGain.GetWindowTextLengthA();
  a2.resize(iLength);
  cstrB = a2.c_str();
  Edit_AGain.GetWindowTextA(cstrB);

  iLength=  Edit_BoardID.GetWindowTextLengthA();
  a3.resize(iLength);
  cstrC = a3.c_str();
  Edit_BoardID.GetWindowTextA(cstrC);

  delete GainData;


}
Posted
Comments
karthik Udhayakumar 27-May-14 0:46am    
Hello Sun mi,
pls use the "improve question" widget to explain better what you want to achieve..and better way for what:)

Here is your improved code:

C++
void CSerialTestDlg::SetGainData()
{  
  CString cstr="";
  CString cstrB="";
  CString cstrC="";

  Edit_VGain.GetWindowTextA(cstr);
  Edit_AGain.GetWindowTextA(cstrB);
  Edit_BoardID.GetWindowTextA(cstrC);
}

Does exactly the same as far as I can see.
 
Share this answer
 
Hi !

Why not simply use the
C++
Edit.GetWindowText(MyStr)
where
C++
MyStr 
is of type
C++
CString 
to get the string in the edit box ?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900