I'm using AddString() method of the CComboBox class in MFC, and I'm tracing every important step in the procedure, and the AddString() method always returns 0 and never adds anything to the combobox. Here is the code of the function:
As you can see, the function is pretty straight forward, and I'm seeing all the records from the database that should be inserted, but never are.
Any suggestions as to what might be happening?
I thought at first it might be because the window isn't created, but if that was the case, then I should get an ASSERTION I would think. And 0 should be a valid return value. At this point I'm completely at a loss.
I have the DDX_Control set up as well, so the variable is correct.
Code:
void CFuel_Refund_MFCView::LoadTractors(void)
{
m_Tractor.ResetContent();
ASSERT( m_Tractor.GetCount() == 0 );
CRecordset cRec( theApp.GetDatabase() );
if (theApp.GetDatabase()->GetTractors( cRec ))
{
if( !(cRec.IsBOF() && cRec.IsEOF())) {
TRACE("Adding tractors now\n");
cRec.MoveFirst();
CString tractor;
int item;
while (!cRec.IsEOF())
{
cRec.GetFieldValue( _T("UNIT"), tractor );
TRACE1("Adding tractor %s\n", tractor);
item = m_Tractor.AddString( tractor );
if( item == CB_ERR || item == CB_ERRSPACE ) {
TRACE("Error inserting tractor\n");
} else {
TRACE1("Item inserted at item %d\n", item);
}
cRec.MoveNext();
}
}
}
}
As you can see, the function is pretty straight forward, and I'm seeing all the records from the database that should be inserted, but never are.
Any suggestions as to what might be happening?
I thought at first it might be because the window isn't created, but if that was the case, then I should get an ASSERTION I would think. And 0 should be a valid return value. At this point I'm completely at a loss.
I have the DDX_Control set up as well, so the variable is correct.