Archived

This topic is now archived and is closed to further replies.

File -> Edit Box Thing

This topic is 5590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been developing a text editor for my program, and when it saves, it encrypts the data so it can be read by the game (with the option of simple, unencrypted, ASCII output). I can save fine, encrypted or unencrypted, but I have a problem: what good is an editor without the ability to load a file? How can I, using char*''s so that I can easily knock the value back by 14 characters, load an ENTIRE ascii file, get it into a char* or some other easily-changeable data structure, and then write the whole thing out to a multi-line edit control??? Just so everyone knows, the program tells the difference between an encrypted and unencrypted file by this string at the very first line of all encrypted files: "mq_cryptedit_zriggle". Then a newline char, then the actual file. So I need to be able to: 1.) Load the first line of text to check to see if the file is encrypted... 2.) Either way, load the rest of the file (including the first line if the file is not encrypted) into a char* or similar buffer... 3.) If needed, unencrypt the data 4.) Write the stuff to a win32 edit control... Why don''''t we just kill the guys who write annoying, useless warning messages. It''''d make our lives a hell of a lot easier

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by zackriggle
1.) Load the first line of text to check to see if the file is encrypted...


do a fopen(), then fgets() to read the first line. note that gets() will put \n into the string, so you may want to remove it right away.
quote:

2.) Either way, load the rest of the file (including the first line if the file is not encrypted) into a char* or similar buffer...


do a fseek() to the end then ftell() to get the file size. allocate a buffer with new or malloc to hold the entire file. you may want to allocate an additional character for the terminating \0. then fseek() to the beginning if the file is unencrypted or to the beginning+sizeof of the indicator string, and read the file into the allocated memory.
quote:

3.) If needed, unencrypt the data


you can now decrypt data from the allocated memory.
quote:

4.) Write the stuff to a win32 edit control...


wm_settext or setwindowtext should work, or take a look at em_replacesel if they don''t.

Share this post


Link to post
Share on other sites