By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,836 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

MFC help

P: 36
Could someone help me write a getline type function to store whatever it reads from a file into a combobox/edit box? im not familiar with mfc too well.
Mar 23 '07 #1
Share this Question
Share on Google+
1 Reply

P: 99
im assuming you have a cfile already?

you can read from your cfile into some sort of buffer with read() like this:
Expand|Select|Wrap|Line Numbers
  1. char szBuffer[256];
  2. myFile.Read( szBuffer, sizeof( szBuffer ) );
i believe you can also use buffers of different types, but it looks like you want alpha's.

then i think you might need to create a cstring from it, but you may be able to use a regular char[] as long as its null-terminated.

then to add your string to the combo box use the CComboBox::AddString() like this:
Expand|Select|Wrap|Line Numbers
  1. yourCBox->AddString(szBuffer);
you may need to do something with types, if so let me know. (though i think i may be out of commission for the next 24hrs)
Mar 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.