Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I've learned more from your forums in 3 days than 3 months at school and on the job combined..."

Geography

Where in the world do Tek-Tips members come from?
Vachaun22 (Programmer)
1 Oct 09 11:07
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:

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.
Vachaun22 (Programmer)
1 Oct 09 11:49
Nevermind, in my infinite wisdom I selected the extended combobox when building the dialog window which doesn't support AddString().

It works now.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close