You must declare the following global variables at the beginning of the file:
HANDLE hEditBuffer; /* handle of editing buffer */
HANDLE hOldBuffer; /* handle of old buffer */
HCURSOR hHourGlass; /* handle of hourglass cursor */
HCURSOR hSaveCursor; /* handle of current cursor */
int hFile; /* handle of file */
int count; /* number of chars read or written */
PSTR pBuffer; /* address of read/write buffer */
OFSTRUCT OfStruct; /* information from OpenFile() */
struct stat FileStatus; /* information from fstat() */
PSTR pEditBuffer; /* address of edit buffer */
BOOL fChanges = FALSE; /* TRUE if file is changed */
BOOL fSaveEnabled = FALSE; /* TRUE if text is in edit buffer */
char Untitled[] = /* default window title */
"Edit File - (untitled)";
The hEditBuffer variable holds the handle of the current editing buffer. This buffer, located in the application's heap, contains the current file text. To load a file, you allocate the buffer, load the file, and then pass the buffer handle to the edit control. The hOldBuffer variable is used to replace an old buffer with a new one. The hHourGlass and hSaveCursor handles hold cursor handles for lengthy operations.
The hFile variable holds the file handle returned by the OpenFile function. The count variable holds a count of the number of characters to be read or written. The pBuffer variable is a pointer and holds the address of the character that contains the characters to be read or written. The OfStruct structure holds information about the file.
The FileStatus structure also holds information about the file. The fChanges variable is TRUE if the user has changed the contents of the file. The fSaveEnabled variable is TRUE if the user has given a valid name for the file to be saved. The Untitled variable holds the main window's title, which changes whenever a new file is loaded.