473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CEdit new lines show up as boxes

36
I'm reading text from a file and storing it in a string. When I use ShowWindowText, new lines show up as boxes. I used the \r\n trick but I want to save any changes (like notepad) and it'll store at the end of every line.

What would I need to do?
Apr 4 '07 #1
14 3833
Banfa
9,065 Expert Mod 8TB
Make sure you edit box has these styles

ES_AUTOHSCROLL
ES_AUTOVSCROLL
ES_MULTILINE
ES_WANTRETURN

These will appear as Styles options of the properties page of the dialogue box editor.
Apr 4 '07 #2
jj555s
36
I have them all
Apr 4 '07 #3
Banfa
9,065 Expert Mod 8TB
Erm there shouldn't be anything else, when you read the text from the edit box it should be putting newlines etc at the end of the lines read.
Apr 4 '07 #4
jj555s
36
example:
(from text file to window box)
revdagffs
gfsgsfgsfg


made some changes:
revdagffs
gfsgsfgsfgsfgfsg
sgfsgfgsf

(save from window box to string, reload window box)

revdagffs

gfsgsfgsfgsfgfsg

sgfsgfgsf
....


again



revdagffs


gfsgsfgsfgsfgfsg


sgfsgfgsf

dsgdsgfs
Apr 4 '07 #5
jj555s
36
It will display boxes if I dont add \r\n but then it will save extra newlines.
Apr 4 '07 #6
Banfa
9,065 Expert Mod 8TB
Arr I see.

I do not think the problem is in the Edit box but in the file handling.

I suspect you are reading and writing the file as a text? I think when you do this you get '\r\n' at the end of the lines read form the edit control, when you save this to as a text file it gets converted to '\r\n\n' and you get extra newlines.

Try handling your files as binary files (i.e. with no newline conversion).
Apr 4 '07 #7
jj555s
36
I'm not sure how to do that.
Apr 4 '07 #8
jj555s
36
Right now I'm using CStdioFile

and

while(myFile.ReadString(ReadFile) == TRUE)

it will read line by line until it reaches the end of the file
Apr 4 '07 #9
Banfa
9,065 Expert Mod 8TB
When you construct the CStdioFile object you can specify how you want to open the file, text or binary using the flags CStdioFile::CStdioFile.

Then rather than using ReadString use the Read member inherited from CFile. Which takes a buffer pointer and a length. If the file is not too large you can use the GetLength member inherited from CFile to get the file size and allocate a single buffer to hold the whole thing and load it in 1 go.
Apr 4 '07 #10
jj555s
36
Well that's a problem, I am reading a file that can variate from small to large so having it read a fixed amount may not work for me.
Apr 4 '07 #11
Banfa
9,065 Expert Mod 8TB
Don't be defeatist, this is not a problem. Ultimately you are stuffing the file contents into the Edit box so just allocated a smaller buffer (something on the stack then there is no chance of a memory allocation failure) and read the file in a chunk at a time and keep adding it to the edit box (which is what I assume you are doing now line by line).
Apr 5 '07 #12
jj555s
36
Sorry but I'm not quite sure where you're getting at. What is your method that you're thinking of exactly?
Apr 5 '07 #13
Banfa
9,065 Expert Mod 8TB
Pseudo Coded As

Expand|Select|Wrap|Line Numbers
  1. char buffer[size];
  2.  
  3. while(data in file to read)
  4. {
  5.    Read(buffer, size);
  6.  
  7.    Add To Edit Box buffer)
  8. }
  9.  
Apr 5 '07 #14
jj555s
36
Hey I ended up using a Replace("\r\n", "\n"); and it works now. Thanks though.
Apr 5 '07 #15

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

Similar topics

2
by: Richard | last post by:
I am attempting to write a program that does the following. Opens up a dialog box with an editbox, checkbox, and button. Initially, the checkbox and the button are disabled. A file is read and...
7
by: ragi | last post by:
I need put small animated gifs (like emoticons) into CEdit control in place of blinkinh caret. Thanks for help.
2
by: garrry | last post by:
Here is the situation (in VisualC++6 environment): 1. some number is enterd into a CEdit window by user 2. the application has to obtain that number and do some calculations with it (just...
1
by: hamm.charlesw | last post by:
I have a small app that filters out illegal characters typed into a CEdit by doing a GetWindowText(), followed by the filtering, followed by a SetWindowText(), all within a routine fired from an...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
1
by: rag84dec | last post by:
Hi, I am trying to write an MFC code which has the Dialog which has a menu option Edit which has an option "Copy File content"... Now i want to get the text entered in the Edit box.What function...
1
by: rag84dec | last post by:
HI, I have an MFC code which has a dialog and a menu.One menu option is Edit which has "Copy File content".There are 2 CEdit boxs.IDC_EDIT2 and IDC_EDIT3.I am reading the text in the Edit boxes. ...
2
by: stefaan | last post by:
Hi all, I have a CEdit window in my application which I use as a sort of output console for text generated by my program. Each subsection writes to its own string buffer and every 2 seconds I...
0
xarzu
by: xarzu | last post by:
How do you change the enabled state of an CEdit control? There does not seem to be any CEdit or CWnd member function that will do it. In MSDN, there mentions something about a Control Table. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.