This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Saving text to files from EDIT class


Hi,
I've problem with saving text files.
Can you tell me what's wrong with this code:
 
hEdit - EDIT window 
 
int saveFile(char *filename)
{
    char buff[256];
    int i;
    int size;
    int lines = SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);
    int fh = open(filename, O_WRONLY | O_CREAT);
    for(i = 0; i < lines; i++)
    {
        ((int *)buff)[0] = 254;
        size = SendMessage(hEdit, EM_GETLINE, i, (LPARAM)buff);
        buff[size] = 0x0d;      // CR
        buff[size+1] = 0x0a;    // LF
        write(fh, buff, size+1);
    }
    close(fh);
  
Thanx,
 
Daniel Mironowicz             miron-the-master@usa.net

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]