Click here to Skip to main content
16,013,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Desperate to make List Box work from a text file Pin
Ravi Bhavnani18-Feb-05 15:52
professionalRavi Bhavnani18-Feb-05 15:52 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:13
macrophobia18-Feb-05 16:13 
GeneralRe: Desperate to make List Box work from a text file Pin
Ravi Bhavnani18-Feb-05 16:24
professionalRavi Bhavnani18-Feb-05 16:24 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:41
macrophobia18-Feb-05 16:41 
GeneralRe: Desperate to make List Box work from a text file Pin
Steve Mayfield19-Feb-05 11:16
Steve Mayfield19-Feb-05 11:16 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia19-Feb-05 17:02
macrophobia19-Feb-05 17:02 
GeneralRe: Desperate to make List Box work from a text file Pin
Steve Mayfield18-Feb-05 15:59
Steve Mayfield18-Feb-05 15:59 
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 16:39
macrophobia18-Feb-05 16:39 
Big Grin | :-D Thank you for this info! Big Grin | :-D
This looks like great stuff!

Please correct me on any misinterpretations I am about to make. Blush | :O

CStdioFile m_File;<br />
CString m_strLine;

I see from the code that m_File is an object of CStdioFile and m_strLine is an object of CString...

m_File.Open("FileName", CFile::modeRead, NULL);<br />
if(m_File.m_pStream != NULL) /* File opened? */

take the CStdioFile object (m_File), call it's inherited function (Open), then check to see that the file was successfully opened.

{<br />
while(m_File.m_pStream != NULL)<br />
     {


while the file is open and not at the end of its text...

{<br />
    if(m_File.ReadString(m_strLine))<br />
     m_cListCtrl.AddTail(m_strLine);

...read from the text file and write to the listbox...


         else<br />
               {<br />
               m_File.Close();<br />
               break;<br />
               }<br />
          }<br />
}


...finally close the file and end.

Again, Thank you. But I have two small questions:

1. Does the "Filename" have to point to the full path of the text file, or can I just include it in the build as a resource file?

2. If I have created an object for my listbox (named m_choices), do I substitute that name where you have used "m_cListCtrl"?

Thank you for bearing with me. You may be saving my life! Rose | [Rose] Rose | [Rose] Big Grin | :-D Rose | [Rose] Rose | [Rose]

Travis
GeneralRe: Desperate to make List Box work from a text file Pin
macrophobia18-Feb-05 17:53
macrophobia18-Feb-05 17:53 
GeneralProcess name shows up in short dos format Pin
SassenFrassenRassen18-Feb-05 12:23
SassenFrassenRassen18-Feb-05 12:23 
GeneralRe: Process name shows up in short dos format Pin
ThatsAlok18-Feb-05 19:17
ThatsAlok18-Feb-05 19:17 
GeneralImplementing a mouse click Pin
Mohammad A Gdeisat18-Feb-05 11:05
Mohammad A Gdeisat18-Feb-05 11:05 
GeneralRe: Implementing a mouse click Pin
Michael Dunn18-Feb-05 16:19
sitebuilderMichael Dunn18-Feb-05 16:19 
QuestionView All Records in Queue Question??? Pin
s2h13198518-Feb-05 10:47
s2h13198518-Feb-05 10:47 
GeneralGDI+ Print Bug Pin
Jorgen E.18-Feb-05 9:55
Jorgen E.18-Feb-05 9:55 
GeneralRe: GDI+ Print Bug Pin
Shog918-Feb-05 11:05
sitebuilderShog918-Feb-05 11:05 
GeneralRe: GDI+ Print Bug Pin
Jorgen E.18-Feb-05 13:29
Jorgen E.18-Feb-05 13:29 
GeneralProblem with .NET framework Pin
Rustamyan18-Feb-05 7:17
Rustamyan18-Feb-05 7:17 
GeneralA want to give my Dialogs/Windows the Look of Xp Pin
shahzadbahi18-Feb-05 4:03
shahzadbahi18-Feb-05 4:03 
GeneralRe: A want to give my Dialogs/Windows the Look of Xp Pin
Ravi Bhavnani18-Feb-05 4:25
professionalRavi Bhavnani18-Feb-05 4:25 
GeneralRe: A want to give my Dialogs/Windows the Look of Xp Pin
22491718-Feb-05 17:47
22491718-Feb-05 17:47 
GeneralRe: A want to give my Dialogs/Windows the Look of Xp Pin
Ravi Bhavnani19-Feb-05 4:16
professionalRavi Bhavnani19-Feb-05 4:16 
GeneralClistCtrl problem Pin
albd18-Feb-05 3:41
albd18-Feb-05 3:41 
GeneralRe: ClistCtrl problem Pin
David Crow18-Feb-05 9:50
David Crow18-Feb-05 9:50 
GeneralFinding maximum value in an array and count the number of maximum Pin
tttyip18-Feb-05 3:39
tttyip18-Feb-05 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.