Connecting Tech Pros Worldwide Forums | Help | Site Map

MFC help

Member
 
Join Date: Mar 2007
Posts: 36
#1: Mar 23 '07
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.

Roonie's Avatar
Member
 
Join Date: Mar 2007
Location: port of stuart, fl
Posts: 101
#2: Mar 23 '07

re: MFC help


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)
Reply