Can’t display text in dialog box in original format 
Author Message
 Can’t display text in dialog box in original format

In a program Im writing the user enters text in the edit window of a
dialog box and the text is saved to a text file. Later in the program
another dialog box displays the users input from the text file into an
edit window. The problem is that the text is not displayed in the same
format that it was originally in when the user typed it into the first
dialog box.

When the user has entered several sentences on separate lines and the
text is displayed all the sentences run together to form one paragraph.
It looks like the new line chars at the end of the sentences do not
create new lines. The new line chars are displayed as black rectangles
sandwiched between the sentences.

Also the text is word wrapping in the edit window correctly. I placed
checks in the boxes for Vertical scroll and Auto Vscroll in the edit
window properties of the dialog box.
Im using MS Developer Studio VC++ standard edition 4.0

How can I get the text to display in the same format it was in when the
user typed it?

Any help would be much appreciated. Thanks in advance.

Ken




Mon, 31 Mar 2003 03:00:00 GMT  
 Can’t display text in dialog box in original format


Fri, 19 Jun 1992 00:00:00 GMT  
 Can’t display text in dialog box in original format

Quote:

> In a program I'm writing the user enters text in the edit window of a
> dialog box and the text is saved to a text file. Later in the program
> another dialog box displays the users input from the text file into an
> edit window. The problem is that the text is not displayed in the same
> format that it was originally in when the user typed it into the first
> dialog box.

> When the user has entered several sentences on separate lines and the
> text is displayed all the sentences run together to form one paragraph.
> It looks like the new line chars at the end of the sentences do not
> create new lines. The new line chars are displayed as black rectangles
> sandwiched between the sentences.

For historical reasons, the line separator for DOS and Windows text
files is a sequence of two characters - ASCII CR (code 13) and LF
(code 10).  In standard C, the line separator for text files is a
single character, '\n', which for an environment that uses ASCII or an
ASCII-derived character set will be ASCII LF (code 10).  The C library
translates between this single-character in-memory representation and
the two-character on-disk representation for you.

Windows was originally written in assembler and was not designed to
work with standard C, so edit controls were designed to be usable with
the raw data from text files, rather than C's in-memory
representation.  Therefore they only recognise CR, LF as a line
separator, and display a bare LF as if it is an ordinary character.
Thus an LF displays as the font's "missing character" symbol, which is
usually a filled rectangle.

Quote:
> Also the text is word wrapping in the edit window correctly. I placed
> checks in the boxes for Vertical scroll and Auto Vscroll in the edit
> window properties of the dialog box.
> I'm using MS Developer Studio VC++ standard edition 4.0

> How can I get the text to display in the same format it was in when the
> user typed it?

If you use an edit control as a file editor, you should either (a)
read and write the files as if they are binary files ("rb" and "wb"
modes), or (b) use the Win32 file functions instead (which never
translate line separators).

--
Any opinions expressed are my own and not necessarily those of Roundpoint.



Fri, 25 Apr 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. uneditable formatted text in a dialog box

2. Format Dialog Box text?

3. Format Dialog Box Text?

4. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

5. Display text in dialog box with TextOut()

6. Formatting Displayed text

7. How can I format the text that goes into a richeditctrl before it is displayed

8. float format showing within a DDX text box

9. Formatting text in Edit Box

10. format text in edit box?

11. float format showing within a DDX text box

12. formatting text sent to an Edit Box?

 

 
Powered by phpBB® Forum Software