If length returns 0 from ::GetWindowTextLength the code isn't happy with creating zero length strings. Wrapping an if (length > 0) around the creation of the new string fixes this.
length
::GetWindowTextLength
if (length > 0)
// Retrieves the title or text associated with a control in a dialog box. inline CString CWnd::GetDlgItemText(UINT dlgItemID) const { assert(IsWindow()); int dlgItem = static_cast<int>(dlgItemID); int length = ::GetWindowTextLength(::GetDlgItem(*this, dlgItem)); CString str; if ( length > 0 ) { VERIFY(::GetDlgItemText(*this, dlgItem, str.GetBuffer(length), length+1)); str.ReleaseBuffer(); } return str; }
Hi John,
Thanks for bringing this to my attention.
I've submitted an update that includes the fix for GetDlgItem. You can download the latest code snapshot from the Code section here on SourceForge.
Best regards, David
Log in to post a comment.
If
lengthreturns 0 from::GetWindowTextLengththe code isn't happy with creating zero length strings. Wrapping anif (length > 0)around the creation of the new string fixes this.Hi John,
Thanks for bringing this to my attention.
I've submitted an update that includes the fix for GetDlgItem. You can download the latest code snapshot from the Code section here on SourceForge.
Best regards,
David