I'm a new guy with ATL. So forgive me to ask this question.
Problem description:
One CEdit
control is added into a ATL dialog class. It's attached in the dialog initialize function.
//Define the edit control
ATLControls::CEdit m_txtInput;
//In the OnInitDialog function
m_txtInput.Attach(GetDlgItem(IDC_INPUT_LINE));
m_txtInput.SetWindowText(_T("New directory"));
//In the public memeber function of the dialog GetInput()
//I have tried three kinds of method to get the text. But all of them are throw an
//assert exception, IsWindow() failed.
//1.
GetDlgItemText(IDC_INPUT_LINE, input);
//2.
ZeroMemory(m_lptstrInput, MAX_PATH);
m_txtInput.GetLine(0, m_lptstrInput, MAX_PATH);
//3.
BSTR input;
m_txtInput.GetWindowText(input);
Here is a topic about how to get text from CEdit
but it is not working.
Why the CEdit
control could be set text with the function SetWindowText()
but can't get the text by the function GetWindowText()
? It's really confuse me. Thanks a lot if someone could explain it for me.