Article ID: 146617
Article Last Modified on 11/21/2006
LRESULT COleControl::OnSetText(WPARAM wParam, LPARAM lParam)
{
ASSERT(lParam == 0 || AfxIsValidString((LPCTSTR)lParam));
// Is the property changing?
if ((lParam == 0 && m_strText.IsEmpty()) ||
(lParam != 0 && m_strText == (LPCTSTR)lParam))
return 0;
.
.
.
}
When a user types text into the control, the m_strText member is not
updated. Therefore, when SetWindowText(NULL) is called on the control, the
first expression is evaluated as TRUE, even though the edit control is not
truly empty. This expression is interpreted as property not changed, and
the function exits.
LRESULT CMyOleControl::OnSetText(WPARAM wParam, LPARAM lParam)
{
ASSERT(lParam == 0 || AfxIsValidString((LPCTSTR)lParam));
// Is the property changing?
if ((lParam == 0 && InternalGetText().IsEmpty()) ||
(lParam != 0 && m_strText == (LPCTSTR)lParam))
return 0;
.
.
.
}
Calling InternalGetText() will give access to the text property, and then
calling IsEmpty() on the return from it will correctly check to see if the
edit control has been updated.
Additional query words: 4.00 4.10 vcfixlist420
Keywords: kbbug kbctrl kbfix kbnoupdate kbvc420fix KB146617