views:

384

answers:

3

how to copy textbox->Text content in a char array? i m working in vc++.

A: 

The "How Do I?" videos from MSDN should help. In this case How Do I: Transfer Data Between Variables and Dialog Controls?

Cristian Adam
+1  A: 

Use CWnd::GetWindowText()

CString str;
CWnd* pWnd = GetDlgItem(IDC_WHATEVER);
pWnd->GetWindowText(str);

Puts the contents of the control into the CString or you can use the array version:

TCHAR sz[10];
int nRet = pWnd->GetWindowText(sz, 10);
mocj
A: 

Your query is unclear, so I'll have to assume things.

Assuming you are using MFC, add a control type variable to your edit box (say m_Edit), and use m_Edit.GetWindowText() to get the text.

Or if you're using plain Win32, use the GetWindowText() Win32 API.

On an additional note, like another user pointed out, stop using things like fixed-size character arrays to store strings if you are using c++. Use something like std::string or use CString if you're using MFC. By doing so, you can manipulate strings much easily and your code will be less error prone.

Cheers, Rajesh. MVP, Visual C++

Rajesh R Subramanian