Reading from and Writing to Child Windows

Reading from or writing to a window resembles reading from or writing to a file. QuickWin windows behave as input/output streams. You can pass the file pointer obtained from the _fwopen function as the stream argument to standard input/ output functions.

For example, this code demonstrates writing a text prompt to a window and reading a response from the user:

FILE * fp; /* Declare a file pointer */

.

.

.

fp = _fwopen( wo, NULL, “w+” ); /* Open a window */

fprintf( fp, “Enter a filename: \n” ); /* Write to the window */

rewind( fp ); /* Reset the stream */

fscanf( fp, “%s”, &scan ); /* Read from the window */

Note:

Each time you switch from reading to writing or from writing to reading, call the rewind function to reset the stream.

See the examples of using document windows for input and output in QWDEMO.C.