Re: Displaying a Text File in an Edit Box
From: Michael K. O'Neill (MikeAThon2000_at_nospam.hotmail.com)
Date: 12/02/04
- Next message: Jiantao, Pu: "error LNK2001: unresolved external symbol ___pioinfo"
- Previous message: Ashok K Kumar: "Re: manual Control Messages in MFC"
- In reply to: Jay: "Re: Displaying a Text File in an Edit Box"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 2 Dec 2004 10:00:04 -0800
Quote from MSDN on the
CStdioFile::ReadString function: "The CString version of this function
removes the '\n' if present; the LPTSTR version does not."
So, the ReadString function is the culprit in removing the newline
character.
Try something like
void CMyDialog::ReadFile()
{
CStdioFile In;
if (!In.Open("Trade.Dat",CFile::modeRead))
{
return; //could not open file
}
CString Temp;
strTrade = "";
while (In.ReadString(Temp.GetBuffer(8096), 8096))
{
Temp.ReleaseBuffer(-1);
strTrade += Temp;
}
In.Close();
UpdateData(FALSE);
}
"Jay" <itsjayceecee@hotmail.com> wrote in message
news:eEKZDIA2EHA.412@TK2MSFTNGP14.phx.gbl...
> AliR
> Does exactly what i asked for !!!
> Only problem is I didnt realise (until I got your code running)
> that it would read my text file in one long line.
>
> The text file is in a "report format" with headings , new lines etc
> Is there a way to "mirror image" the file in an edit box.
> I did try to use system("notepad TRADE.DAT") but it caused all
> sorts of problems because I am running a Dialog based app with
> all the Dialogs in modal state.
>
> Any other (not too complicated ) suggestions would be helpful.
>
> Thanks in advance
>
> Jay
>
>
>
>
> "AliR" <AliR@mailserver.com> wrote in message
> news:8csrd.39476$Al3.13629@newssvr30.news.prodigy.com...
> > void CMyDialog::ReadFile()
> > {
> > CStdioFile In;
> >
> > if (!In.Open("Trade.Dat",CFile::modeRead))
> > {
> > return; //could not open file
> > }
> >
> > CString Temp;
> > strTrade = "";
> > while (In.ReadString(Temp))
> > {
> > strTrade += Temp;
> > }
> > In.Close();
> >
> > UpdateData(FALSE);
> > }
> >
> > Or you can do it like this
> > void CMyDialog::ReadFile()
> > {
> > CStdioFile In;
> >
> > if (!In.Open("Trade.Dat",CFile::modeRead))
> > {
> > return; //could not open file
> > }
> >
> > CString Temp;
> > CString Buffer = "";
> > while (In.ReadString(Temp))
> > {
> > Buffer += Temp;
> > }
> > In.Close();
> > GetDlgItem(ID_SHOW_TRADE)->SetWindowText(Buffer);
> > }
> >
> > AliR
> >
> >
> > "Jay" <itsjayceecee@hotmail.com> wrote in message
> > news:%23vd4I$%231EHA.3408@tk2msftngp13.phx.gbl...
> >> Hi All
> >> Is it possible to display the contents of a Text file in an Edit box.
> >>
> >> Edit Box name is ID_SHOW_TRADE
> >> Variable for this edit box is a CString called strTrade
> >> The file name is TRADE.DAT & is saved in Text format.
> >>
> >> Help would be much appreciated
> >> Jay.
> >>
> >>
> >
> >
>
>
- Next message: Jiantao, Pu: "error LNK2001: unresolved external symbol ___pioinfo"
- Previous message: Ashok K Kumar: "Re: manual Control Messages in MFC"
- In reply to: Jay: "Re: Displaying a Text File in an Edit Box"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|