|
-
June 1st, 1999, 05:17 PM
#1
Displaying .txt file in Edit Box Control
How can I display the contents of an .txt file in a EditBox called m_Info?
-
June 1st, 1999, 08:31 PM
#2
Re: Displaying .txt file in Edit Box Control
Did you associate the edit box to a member variable called m_Info?
Then you can set the string to m_Info and call UpdateData function as follows.
m_Info = "String you read from txt file";
UpdateData(FALSE);
Otherwise, you can use the following method.
GetDlgItem(ID_FOR_EDITBOX)->SetWindowText("String you read from txt file");
If the txt file has multiple lines, you must set multiline checkbox at the property page of the editbox.
-
June 1st, 1999, 11:05 PM
#3
Re: Displaying .txt file in Edit Box Control
That will just set the text in the editbox! I have a file called Info.txt I want to display all the text from that file in m_Info EditBox Control. Please help with this!
Thanks,
Nathan Strandberg
-
June 2nd, 1999, 12:50 AM
#4
Re: Displaying .txt file in Edit Box Control
Hey.... just copy the contents of the file on to a string.
Open the .txt file, read the contents using fgtes or whatever, and add this to the CString variable.
Then use this string to put onto the edit box.
Need anymore help???
-
June 2nd, 1999, 02:34 PM
#5
Re: Displaying .txt file in Edit Box Control
Here is pseudo-code to do this :
Open the file // call CreateFile with GENERIC_READ access.
Get the file's size // call GetFileSize
Allocate a buffer for the file
Read entire file into the buffer // call ReadFile and pass the size of the file
// and the pointer buffer as arguments - one call can do this.
Set control's text // call SetDlgItemText and pass the buffer as an arg.
Release the buffer
Close the file
I'll leave the details of implementation as an exercise for the reader.
Be aware that there is a limit to the amount of text an edit control can handle.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|