我正在使用 MFC 框架创建 vs++ 代码。我在表单中有一个名为“IDC_EDIT1”的 Cedit 框。谁能告诉我如何检查编辑框是否为空?
问问题
5991 次
3 回答
2
CEdit *editBox = (CEdit *) GetDlgItem(IDC_EDIT1);
if(editBox == NULL)
return;
CString str;
editBox->GetWindowTextW(str);
if(str.IsEmpty())
{
}
于 2012-04-09T06:45:01.950 回答
1
您可以使用 WM_GETTEXTLENGTH 消息:
int length = SendMessage(hwnd,WM_GETTEXTLENGTH,0,0);
if(length == 0)
{
MessageBox(0,"The edit box is empty.",0,0);
}
于 2012-04-09T05:14:58.263 回答
0
这是一个计算器程序,我正在检查按钮是否按下编辑框控件是否为空。
(IDC_Display
编辑控件)连接到变量m_Display
(cEdit
类型)
我取了另一个变量cString
Type ( m_TrialString
)。在下面的类定义中声明它m_Display
。
在您编写的按钮单击事件上:
void CNewCalculatorDlg::OnBnClickedButton1()
{
m_Display.GetWindowText(m_TrialString);
if (m_TrialString.IsEmpty())
AfxMessageBox(_T("The CString is EMPTY"),MB_OK);
else
AfxMessageBox(_T("The CString is NOT EMPTY"), MB_OK);
}
于 2015-07-06T13:21:56.277 回答