读书人

error C2039: #039;SetLimitText#039; : is no

发布时间: 2012-06-22 16:16:32 作者: rapoo

error C2039: 'SetLimitText' : is not a member of 'CWnd'问题如何解决??
代码如下
BOOL CEmployeesAdd::OnInitDialog()
{
CDialog::OnInitDialog();


// TODO: Add extra initialization here
((CEdit*)GetDlgItem(IDD_EmpAdd_PID)->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PNAME))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PSEX))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PNATIONAL))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PPHONE))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PBIRTHDAY))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PADDRESS))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PIDCARD))->SetLimitText(50);
((CEdit*)GetDlgItem(IDD_EmpAdd_PSCHOOL))->SetLimitText(50);
if (m_bAddp)
{
//更新对话框属性
SetWindowText(_T("添加员工基本信息"));
}
else
{
// 更新对话框属性
SetWindowText(_T("修改员工基本信息"));
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

ompiling...
EmployeesAdd.cpp
E:\test\EmployeesAdd.cpp(67) : error C2039: 'SetLimitText' : is not a member of 'CWnd'
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd'
E:\test\EmployeesAdd.cpp(67) : error C2143: syntax error : missing ')' before ';'
求大神解决啊!

[解决办法]
CEdit::SetLimitText
void SetLimitText( UINT nMax );

Parameters

nMax

The new text limit, in bytes.

Remarks

Call this member function to set the text limit for this CEdit object. The text limit is the maximum amount of text, in bytes, that the edit control can accept.

Changing the text limit restricts only the text the user can enter. It has no effect on any text already in the edit control, nor does it affect the length of the text copied to the edit control by the SetWindowText member function in CWnd. If an application uses the SetWindowText function to place more text into an edit control than is specified in the call to LimitText, the user can delete any of the text within the edit control. However, the text limit will prevent the user from replacing the existing text with new text, unless deleting the current selection causes the text to fall below the text limit.

This function replaces LimitText in Win32.

For more information, seeEM_SETLIMITTEXT in the Win32 documentation.

CEdit Overview | Class Members | Hierarchy Chart

See Also CEdit::GetLimitText, CEdit::LimitText

[解决办法]
代码不够全。但是根据MSDN:SetLimitText确实是CEdit的成员函数
[解决办法]
楼主少了一个)。

((CEdit*)GetDlgItem(IDD_EmpAdd_PID)->SetLimitText(50);应该是
((CEdit*)GetDlgItem(IDD_EmpAdd_PID))->SetLimitText(50);

读书人网 >C++

热点推荐