views:

43

answers:

2

I'm playing a little bit with PocketC by doing a simple text editor. But with this code to read and to display the contents of the file on the EDIT control:

int filehandle;
int file_len;
string file_mode;

initComponents()
{
    createctrl("EDIT", "test", 2, 1, 0, 24, 70, 25, TEXTBOX);
    wndshow(TEXTBOX, SW_SHOW);
    guigetfocus();
}

main()
{
    filehandle = fileopen(OpenFileDlg("Plain Text Files (*.txt)|*.txt; All Files (*.*)|*.*"), 0, FILE_READWRITE);
    file_len = filegetlen(filehandle);

    if(filehandle == -1)
    {
        MessageBox("File Could Not Be Found!", "Error", 3, 1);
    }

    initComponents();
    editset(TEXTBOX, fileread(filehandle, file_len));
}

It's all ok, but my test file, now have returns:

Hello, World!
PocketC
Test Of My Editor

Then when I open this file on the editor, instead of returns, I just see two squares(that means that it's a unknown character for that control), but if I change the control to a STATIC, it does he returns ok, but I can't edit the text if I use a STATIC. Then I want to know what I need to do to do the returns instead of showing those squares.

Also, this field(EDIT), is like a TextField, I can't do returns on it, then I want to know how to change this too.

+1  A: 

I don't know anything about PocketC, but in general, you get that behavior if the line break characters used in the data do not match the OS's native line breaks. For instance, if the data uses CRLF where the OS expects bare CR or bare LF, or vice versa. Since you are seeing two squares appear, check if the file data is using LFCR, CRCR or LFLF instead of CRLF.

Remy Lebeau - TeamB
Remember that I've created the text file using notepad at the device. But how could I know which one is the file using?
Nathan Campos
Use a hex editor to view the file's raw bytes.
Remy Lebeau - TeamB
+1  A: 

I don't know PocketPC, but Windows edit controls need a ES_MULTILINE style in order to show multi-line text correctly.

Adrian McCarthy
Did you know the number of this style property at Windows?
Nathan Campos
ES_MULTILINE = 4
Remy Lebeau - TeamB
Thanks very much! It works! But where you get this informations about the controls?
Nathan Campos
Adrian McCarthy