Article ID: 139593
Article Last Modified on 11/21/2006
void DDX_CBString(CDataExchange *pDX, int
nIDC, CString& value);
if (nLen != -1)
to this line:
if (nLen!= -1 && nLen!=0xFFFF)
void AFXAPI CMyTryDlg::DDX_CBString(CDataExchange* pDX, int nIDC,
CString& value)
{
HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
if (pDX->m_bSaveAndValidate)
{
// Get current edit item text (or drop list static)
int nLen = ::GetWindowTextLength(hWndCtrl);
if (nLen != -1 && nLen != 0xFFFF)
{
// Get known length
::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen),
nLen+1);
}
else
{
// GetWindowTextLength does not work for drop lists assume
// max of 255 characters
::GetWindowText(hWndCtrl, value.GetBuffer(255), 255+1);
}
value.ReleaseBuffer();
}
else
{
// Set current selection based on model string
if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1,
(LPARAM)(LPCTSTR)value) == CB_ERR)
{
// Set the edit text (will be ignored if DROPDOWNLIST)
AfxSetWindowText(hWndCtrl, value);
}
}
}
Keywords: kbbug kbdlg kbprogramming kbui KB139593