Add New Variables

The following global variables should be declared at the beginning of the file:

HANDLE hEditBuffer; /* handle to editing buffer */

HANDLE hOldBuffer; /* old buffer handle */

HANDLE hHourGlass; /* handle to hourglass cursor */

HANDLE hSaveCursor; /* current cursor handle */

int hFile; /* file handle */

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() */

BOOL bChanges = FALSE; /* TRUE if the file is changed */

BOOL bSaveEnabled = FALSE; /* TRUE if text in the edit buffer */

PSTR pEditBuffer; /* address of the 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, 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 holds information about the file. The bChanges variable is TRUE if the user has changed the contents of the file. The bSaveEnabled 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 caption, which changes whenever a new file is loaded.