Dec 192017
 
Windows pkg for MSC and QC.
File EZWIND.ZIP from The Programmer’s Corner in
Category C Source Code
Windows pkg for MSC and QC.
File Name File Size Zip Size Zip Type
EZWINDOW.DOC 37913 8052 deflated
SAMPLE.TXT 1457 681 deflated
SAMPLE01.C 955 475 deflated
SAMPLE02.C 1213 557 deflated
SAMPLE03.C 1117 547 deflated
SAMPLE04.C 1480 653 deflated
SAMPLE05.C 2076 909 deflated
SAMPLE06.C 2423 1034 deflated
SAMPLE07.C 2629 1113 deflated
SAMPLE08.C 2994 1280 deflated
SAMPLE09.C 3616 1170 deflated
SAMPLE10.C 1781 794 deflated
SAMPLE11.C 3523 1475 deflated
WINDOW.H1 272 160 deflated
WINDOWL.LIB 13337 6302 deflated
WINDOWM.LIB 12313 5817 deflated
WINDOWS.LIB 11801 5751 deflated

Download File EZWIND.ZIP Here

Contents of the EZWINDOW.DOC file




EZWINDOW 1.1





GENERAL:

EZWINDOW is a full featured window and menu utility for the MicroSoft
Quick C and C 5.0 compilers. It has functions for creating windows with
different border styles as well as functions to generate horizontal and
vertical lightbar menus, sound effects, explosion and shadow box effects
and wordwrap of text within windows. It will work with CGA, MONO and
EGA video cards.
The number of windows you can use is limited only by the amount of
free memory in your computer. Active windows requires 4k of buffer space to
store the screen for restoration when the window is removed. The buffer
space is allocated dynamically so you use only as much as you need. When
a window is removed its buffer space is released.
The real value of EZWINDOW is in its ease of use. There may be more
powerful packages available but none which can be more easily learned and
used. Eleven sample programs are included which demonstrate the use of
most EZWINDOW functions. Especially in the case of the menu sample programs
it may only require simple modifications to the samples to incorporate them
into your own code.







LEGAL:

EZWINDOW is distributed as shareware - it is copyrighted by the author
and all rights are reserved. You are encouraged to try EZWINDOW and if you
find that it meets your needs, sending $10 to the author at the following
address will grant you license for continued use in your software.



Don Fordham
6888 Granero Dr.
El Paso, Texas
79912



LEARNING EZWINDOW:

The best way to learn EZWINDOW is to study the eleven sample programs
supplied. Once you have a basic understanding of each of the demonstrated
functions, you should try modifying them. In addition to the sample
programs, a function reference is included in this documentation. It is
best used as a quick reference once the operation of the functions in the
sample programs is understood.
You should also study the window.h1 header file in order to become
acquainted with the constants used by EZWINDOW.



COMPILING AND LINKING:

There are three library files supplied with EZWINDOW. They are
windows.lib for small memory model programs, windowm.lib for medium
memory model programs and windowl.lib for large memory model programs.
Depending on the memory model you want to use, simply link in the
appropriate EZWINDOW library file. For example, to compile and link
SAMPLE01.C using the small memory model you might use the following command
line:
cl /AS sample01.c windows.lib

The same program compiled using the large memory model would require
the following command line:

cl /AL sample01.c windowl.lib

In addition, don't forget that all programs using EZWINDOW require the
header file window.h1 included in the source code.



NOTE TO USERS OF B/W AND TTL MONOCHROME MONITORS:

If you are using a b/w monitor connected to a monochrome card the
colors used in the sample programs are likely to be illegible. You will
need to change to legible colors such as LTGRAY AND BLACK.
If you are using a TTL MONO system the colors will at least be legible
but may also need to be changed to present a better appearance.




EZWINDOW FUNCTION REFERENCE


/*---------------------------------------------------------------------------*/

void initwindows(char bordertype,int bordercolor,
int bordertextcolor,int backgroundcolor,int textcolor)


This must be the first EZWINDOW function called. It performs all
necessary housekeeping and establishes basic parameters for any windows
opened following this call. The parameters sent to this function are defined
in the header file window.h1 which must be included in any program using
EZWINDOW.

bordertype - This is the type of border you want surrounding your
windows. The border types are: SINGLE and DOUBLE.

bordercolor - This is the background color of the border surrounding your
windows. Very often this is set to the same color as the
overall window background.

bordertextcolor - This is the color which will be used to print the single
or double border type described above as well as any
window title you may use.

backgroundcolor - This is the background screen color inside windows.

textcolor - This is the color for text printed inside windows.


All windows following a call to this function will use these
parameters. If you want the parameters to change simply call this function
again. Any windows opened after another call to initwindows() will use
the new parameters.


/*---------------------------------------------------------------------------*/

void makewindow(char windno,char ulrow,char ulcol,char lrrow,char lrcol,
char *title,char shadow)

Either this function or the function explodewindow() below are used
to actually draw a window once a call to initwindows() has been made.
The parameters used in the call are:

windno - This is the number you assign to the window. You can use any number
less than 255 except 0. Once you have assigned a window number, all
references to this window in other functions are made by using this
number. Until a window is removed using removewindow() described
below, that number cannot be used again. Normally when multiple
windows are required to be displayed simultaneosly the windows are
assigned sequential numbers starting at 1.

ulrow - This will become the row for the upper left corner of the window.
row 1 is the top of the screen.

ulcol - This will become the column for the upper left corner of the window.
column 1 is the left edge of the screen.

lrrow - This will become the row for the lower right corner of the window.

lrcol - This will become the column for the lower right corner of the window.

title - This is a string which will be automatically centered in the top of
the window border printed in the border text color selected in the
last call to initwindows().

shadow - This determines whether a 'shadowbox' effect is placed behind the
window. A 0 says no shadow. A 1 will cause a shadow.
The shadow is always black so the full screen background color
must be something other than black for this to be visible.
Full screen background color is controlled by scrncolor() described
below.
/*---------------------------------------------------------------------------*/

void explodewindow(char windno,char ulrow,char ulcol,char lrrow,char lrcol,
char *title,char shadow)

Performs exactly the same function as makewindow() above but creates
an 'exploding' type window. That is, one which appears to grow
outward from its center. Optionally sound effects can be added by setting
the constant SOUND = ON. SOUND and ON are defined in the header file
window.h1 which must be included in any program using EZWINDOW.

On faster machines (AT's and above) with EGA monitors the explosion
effect is too fast to see.

/*---------------------------------------------------------------------------*/

void removewindow(char windno)

Remove a window by restoring the previous screen. All windows painted
after windno will also be removed. All windows painted before windno will
remain on the screen.
Once a window has been removed with this function its number (windno)
can be used again.

/*---------------------------------------------------------------------------*/

void snapshot(void)

This function 'takes a picture' of the current screen. This enables
you to clear the screen before performing window or menu activity and then
restore the screen later using the reverse function develop(). There is only
one buffer for snapshot purposes so only one screen condition can be saved
at a time.

/*---------------------------------------------------------------------------*/

void develop(void)

Used to restore a prior screen condition saved using the snapshot()
function described above.

/*---------------------------------------------------------------------------*/

void initchoicesh(char windno,char *st)

This function is used as part of the procedure for creating horizontal
'lightbar' type menus. This function horizontally and vertically alligns
menu selections within a properly sized horizontal window. St is a string
containing the menu selection for the horizontal menu. Once a menu has
been set up, getchoice() is called to allow the operator to choose.
The parameters are:

windno - The window number in which the menu choices should be
centered. The windno must have already been created by a
call to makewindow() or explodewindow() and not yet removed
by removewindow(). The size of the window should be 3 rows
or more deep and wide enough to accomodate the length of all
menu choices plus a few spaces in between each choice for
good appearance.

st - Pointer to a string containing the menu choices. All choices are
contained in a single string delimitted by commas. For example the
string "EDIT,PRINT,COPY,DELETE,QUIT" would produce a menu with five
distinct selections centered horizontally and vertically.

/*---------------------------------------------------------------------------*/

void initchoicesv(char windno,char *st)

Similar to initchoicesh() described above but used to initialize
vertical type 'lightbar' menus. Windno should be a window wide enough to
accomodate the widest menu choice or the title (whichever is longer) plus a
few spaces on each side for appearance and should be deep enough to
accomodate the number of selections either single spaced or double spaced.
The spacing will be automatically determined. Single spacing will be used
unless the window is so deep that two spaces will fit between all selections.
The window size is easilly massaged to produce the best looking display.
The parameters are identical to those described in initchoicesh() above.

/*---------------------------------------------------------------------------*/

char getchoice(char windno)


Once a menu has been initialized using either initchoicesh() or
initchoicesv() described above, this routine is called to get the
user's selection. This routine starts by highlighting the first menu
selection. Then the user is allowed to move the lighbar with the arrow
keys (up and down arrow for vertical menus, left and right for horizontal).
When the user hits the enter key this function returns the number
corresponding to the menu item highlighted at the time. The first menu
choice is 1 the n'th menu choice is n.

/*---------------------------------------------------------------------------*/

void scrncolor(int background,int text)

This function is used to change the background and text color
of the entire screen. It does not affect the colors within windows. Only
initwindows() can do that.

/*---------------------------------------------------------------------------*/

void windwrite(char windno,char *st,int row, int col)

This function allows you to write a string in a specified window without
concerning yourself with calculating full screen coordinates or even worrying
about the size of the text versus the size of the window. This function
performs automatic word wrap within the window and if the entire text won't
fit inside the window all at once it performs paging for you. The row and
column are relative to the inside of the window, not the full screen.

/*---------------------------------------------------------------------------*/

void filetowindow(int windno,char *filename,int startrow,int startcol)

This function performs the same as windwrite() above but instead
of printing only a string filetowindow() allows you to write an entire
text file to a window.

Once again automatic word wrap and paging are done for you so you can
write your text using any text editor in normal 80 column mode (more if you
want) without any regard for the eventual size of the window in which you
will print it.

The filename passed to the function must include the extension
(i.e. "sample.txt"). This function will open the file and close it
when done.

The starting row will be used only for the first page of the windowed
display. The starting column will be used for all pages of the
windowed display.

/*-------------------------------------------------------------------------*/

void cursoroff(void)

This function makes the cursor disappear from the screen.

/*---------------------------------------------------------------------------*/

void cursoron(void)

This function turns the cursor back on with the default size of
two lines.

/*---------------------------------------------------------------------------*/


void clrwindow(windno)

This function clears the screen within the window specified by
windno.

/*---------------------------------------------------------------------------*/


EZWINDOW Sample Program Listings


/* SAMPLE01.C

Turn the cursor off, paint a simple window, remove the window
and turn the cursor back on.

*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,GREEN,BLACK,BLUE,LTGRAY); /* Must always be called
before any other
EZWINDOW functions */
cursoroff(); /* turn the cursor off */

/* Create a window extending from row 7 to row 17 and from column 22 to
column 58 with a title and no shadow effect. (NOSHADOW is defined
in window.h1.) */

makewindow(1,7,22,17,58,"Hit any key to continue",NOSHADOW);

while (!kbhit()) /* Wait for any key to be struck.*/
;

removewindow(1); /* remove window 1 from the screen */

cursoron(); /* turn the cursor back on */

}


/* SAMPLE02.C

Turn the cursor off, save the previous screen using snapshot(), paint a
simple window, remove the window, restore the original screen with
develop() and turn the cursor back on.

*/
#include /* All programs using EZWINDOW must include
this header file.*/

main()
{
initwindows(DOUBLE,GREEN,BLACK,BLUE,LTGRAY); /* Must always be called
before any other
EZWINDOW functions */
snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */

/* Create a window extending from row 7 to row 17 and from column 22 to
column 58 with a title and a shadow effect. (SHADOW is defined in
window.h1.) */

makewindow(1,7,22,17,58,"Hit any key to restore old screen",SHADOW);

while (!kbhit()) /* Wait for any key to be struck.*/
;

removewindow(1); /* remove window 1 from the screen */

develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */

}

/* SAMPLE03.C

Giving the appearance of an infinite number of windows when in fact
only one window buffer is being used. Before starting a snapshot is
taken allowing the original screen to be restored when done.

*/
#include /* All programs using EZWINDOW must include
this header file.*/

char x,y;

main()

{
x=y=1;

initwindows(DOUBLE,GREEN,BLACK,BLUE,LTGRAY); /* Must always be called
before any other
EZWINDOW functions */

snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */

/* Create an infinite number of windows with random staring points.*/

while (!kbhit())
{
makewindow(1,x,y,x+10,y+22,"Hit any key to end",NOSHADOW);
x = rand() % 24;
y = rand() % 59;
}


develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */

}

/* SAMPLE04.C

changing the screen background color and creating a window with a
shadowbox effect behind it.

*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,RED,LTGRAY,GREEN,LTGRAY); /* Must always be called
before any other
EZWINDOW functions */

snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */

scrncolor(BLUE,BLACK); /* Black characters on blue background. This
only affects the basic screen. The colors
within windows are still controlled by the
parameters used in initwindows() above.*/

/* Create a window extending from row 7 to row 17 and from column 22 to
column 58 with a title and a shadow effect.*/

makewindow(1,7,22,17,58,"Hit any key to restore old screen",SHADOW);

while (!kbhit()) /* Wait for any key to be struck.*/
;

removewindow(1); /* remove window 1 from the screen */

develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */

scrncolor(BLACK,LTGRAY); /* Restore the normal text and background
colors.*/

}

/* SAMPLE05.C

Creating a horizontal lightbar type menu.
*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK); /* Must always be called
before any other
EZWINDOW functions */

snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */
scrncolor(BLUE,LTGRAY); /* set screen background color to BLUE
and background text to LTGRAY.*/

/* Create a window wide enough to hold all menu choices while
leaving a little space between choices for appearance sake.
Don't go to the trouble of exactly measuring the menu spacing,
EZWINDOW will automatically center your menu selections for you.
Making the menu 3 rows deep gives a good appearance but it can
be deeper. EZWINDOW will also center your menu selections
vertically.*/

makewindow(1,3,3,5,75,"Horizontal Menubar Example",SHADOW);

/* initchoicesh() will now center your menu selections both
horizontally and vertically. You may have to massage the
window size or position to produce the best appearance in
your own programs. This function also creates a reverse video
'menubar' and positions it on your first menu selection.*/

initchoicesh(1,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");

/* Now use getchoice() to return the selected menu option. getchoice()
allows you to use the arrow keys to move the menubar. Hitting
enter makes the selection.*/

while (getchoice(1) != 5) /* Continue getting selections until
QUIT is selected.*/
;

removewindow(1); /* remove window 1 from the screen */

develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */

}

/* SAMPLE06.C

Creating a vertical lightbar type menu.
*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK); /* Must always be called
before any other
EZWINDOW functions */
snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */
scrncolor(BLUE,LTGRAY); /* set screen background color to BLUE
and background text to LTGRAY.*/

/* To decide on the vertical size of the window first decide whether
you want single spacing or double spacing between selections. For
double spacing take the number of choices X 2 and add a space above
the first choice and below the second. In this example we have five
selections so we use a vertical window size of 12. For single spacing
use a vertical size equal to the number of menu choices + 1.

The window width should allow for the width of the widest selection
or the title, whichever is wider, plus a couple of columns for
appearance sake. The selections in the window will be automatically
centered for you horizontally. You may have to adjust the height and/or
width for the best appearence. */

makewindow(1,5,26,17,54,"Vertical Menubar Example",SHADOW);

/* initchoicesv() will now center your menu selections both
horizontally and vertically. You may have to massage the
window size or position to produce the best appearance in
your own programs. This function also creates a reverse video
'menubar' and positions it on your first menu selection.*/

initchoicesv(1,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");

/* Now use getchoice() to return the selected menu option. getchoice()
allows you to use the arrow keys to move the menubar. Hitting
enter makes the selection.*/

while (getchoice(1) != 5) /* Continue getting selections until
QUIT is selected.*/
;
removewindow(1); /* remove window 1 from the screen */
develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */

}
/* SAMPLE07.C

Adding sound effects to the menu. Here is the same vertical
menu program found in sample06.c but with sound effects.
*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK); /* Must always be called
before any other

EZWINDOW functions */
snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */
scrncolor(BLUE,LTGRAY); /* set screen background color to BLUE
and background text to LTGRAY.*/
SOUND = ON; /* This is how sound effects are turned on. SOUND and ON
are found in window.h1. */

/* To decide on the vertical size of the window first decide whether
you want single spacing or double spacing between selections. For
double spacing take the number of choices X 2 and add a space above
the first choice and below the second. In this example we have five
selections so we use a vertical window size of 12. For single spacing
use a vertical size equal to the number of menu choices + 1.

The window width should allow for the width of the widest selection
or the title, whichever is wider, plus a couple of columns for
appearance sake. The selections in the window will be automatically
centered for you horizontally. You may have to adjust the height and/or
width for the best appearence. */

makewindow(1,5,26,17,54,"Vertical Menubar Example",SHADOW);

/* initchoicesv() will now center your menu selections both
horizontally and vertically. You may have to massage the
window size or position to produce the best appearance in
your own programs. This function also creates a reverse video
'menubar' and positions it on your first menu selection.*/

initchoicesv(1,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");

/* Now use getchoice() to return the selected menu option. getchoice()
allows you to use the arrow keys to move the menubar. Hitting
enter makes the selection.*/

while (getchoice(1) != 5) /* Continue getting selections until
QUIT is selected.*/
;

removewindow(1); /* remove window 1 from the screen */
develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */
}

/* SAMPLE08.C

Creating an 'exploding' window. That is a window which starts
at its center and 'explodes' outward. Here is the same vertical menu
with sound effects as found in sample07.c but this time the window will
'explode' onto the screen. NOTE: with AT class machines and faster
the explosion is almost indistinguishable - especially with EGA
monitors. Notice that the exploding windows are created by using the
function explodewindow() instead of makewindow().
*/
#include /* All programs using EZWINDOW must include
this header file.*/
main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK); /* Must always be called
before any other
EZWINDOW functions */
snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/
cursoroff(); /* turn the cursor off till we restore screen */
scrncolor(BLUE,LTGRAY); /* set screen background color to BLUE
and background text to LTGRAY.*/

SOUND = ON; /* This is how sound effects are turned on. SOUND and ON
are found in window.h1. */

/* To decide on the vertical size of the window first decide whether
you want single spacing or double spacing between selections. For
double spacing take the number of choices X 2 and add a space above
the first choice and below the second. In this example we have five
selections so we use a vertical window size of 12. For single spacing
use a vertical size equal to the number of menu choices + 1.

The window width should allow for the width of the widest selection
or the title, whichever is wider, plus a couple of columns for
appearance sake. The selections in the window will be automatically
centered for you horizontally. You may have to adjust the height and/or
width for the best appearence. */

explodewindow(1,5,26,17,54,"Vertical Menubar Example",SHADOW);

/* initchoicesv() will now center your menu selections both
horizontally and vertically. You may have to massage the
window size or position to produce the best appearance in
your own programs. This function also creates a reverse video
'menubar' and positions it on your first menu selection.*/

initchoicesv(1,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");

/* Now use getchoice() to return the selected menu option. getchoice()
allows you to use the arrow keys to move the menubar. Hitting
enter makes the selection.*/

while (getchoice(1) != 5) /* Continue getting selections until
QUIT is selected.*/
;

removewindow(1); /* remove window 1 from the screen */
develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */
}

/* SAMPLE09.C

Putting it all together. Creating 'pull-down' type menus with explosions
and sound effects. This combines both horizontal and vertical type menus
and demonstrates having more than active window on the screen at once.
*/
#include /* All programs using EZWINDOW must include
this header file.*/
char c;

main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK); /* Must always be called
before any other
EZWINDOW functions */
snapshot(); /* store the current screen */
clrscr(); /* clear the screen.*/

cursoroff(); /* turn the cursor off till we restore screen */
scrncolor(BLUE,LTGRAY); /* set screen background color to BLUE
and background text to LTGRAY.*/

SOUND = ON;

/* Create a window wide enough to hold all menu choices while
leaving a little space between choices for appearance sake.
Don't go to the trouble of exactly measuring the menu spacing,
EZWINDOW will automatically center your menu selections for you.
Making the menu 3 rows deep gives a good appearance but it can
be deeper. EZWINDOW will also center your menu selections
vertically.*/

explodewindow(1,3,3,5,75,"Horizontal Menubar Example",SHADOW);

/* initchoicesh() will now center your menu selections both
horizontally and vertically. You may have to massage the
window size or position to produce the best appearance in
your own programs. This function also creates a reverse video
'menubar' and positions it on your first menu selection.*/

initchoicesh(1,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");

/* Now use getchoice() to return the selected menu option. getchoice()
allows you to use the arrow keys to move the menubar. Hitting
enter makes the selection.*/

while ((c = getchoice(1)) != 5) /* Continue getting selections until
QUIT is selected.*/
switch(c)
{
case 1 :
/* Create a new window starting at the bottom row of window 1 */
explodewindow(2,5,5,11,16,"",SHADOW);
initchoicesv(2,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");
while(getchoice(2) != 5)
;
removewindow(2);
break;
case 2 :
/* Create a new window starting at the bottom row of window 1 */
explodewindow(2,5,20,11,31,"",SHADOW);
initchoicesv(2,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");
while(getchoice(2) != 5)
;
removewindow(2);
break;
case 3 :
/* Create a new window starting at the bottom row of window 1 */
explodewindow(2,5,35,11,46,"",SHADOW);
initchoicesv(2,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");
while(getchoice(2) != 5)
;
removewindow(2);
break;
case 4 :
/* Create a new window starting at the bottom row of window 1 */
explodewindow(2,5,50,11,61,"",SHADOW);
initchoicesv(2,"CHOICE 1,CHOICE 2,CHOICE 3,CHOICE 4,QUIT");
while(getchoice(2) != 5)
;
removewindow(2);
break;
}
removewindow(1); /* remove window 1 from the screen */
develop(); /* restore the original screen */
cursoron(); /* turn the cursor back on */
}

/* SAMPLE10.C

Using windwrite() to write text strings to a window on screen.
This is very usefull for printing short help or error messages.
*/
#include

char *stringtoprint="This is text placed in a window using the function "
"windwrite. Notice how the word wrap is is performed "
"automatically for you. If the string won't fit in the "
"length of the window, a flashing 'more' will appear in "
"the last row.";
main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK);
scrncolor(BLUE,LTGRAY);

/* Open a window in which to place text. Don't make the window
too narrow or the word wrap will give a strange presentation.
In fact if the window is narrower than the widest word in the
string to be printed, the word wrap will be thoroughly confused.*/

makewindow(1,7,25,17,65,"Sample Text Window",SHADOW);

/* Now send a pointer to a string to windwrite(). Windwrite will
automatically do word wrap for you adjusting to the width of the
window.*/

windwrite(1,stringtoprint,1,1);/* The coordinates are relative to the
text area of the window.*/
windwrite(1,"Hit enter to continue.",9,10);
while(getche() != 13)
;
/* Here is an example of what happens if the string is too large to
fit in the height of the window.*/

makewindow(2,10,30,15,70,"Shallow Text Window",SHADOW);
windwrite(2,stringtoprint,1,1);
windwrite(2,"Hit any key to continue.",4,10);
while(!kbhit())
;

removewindow(2); /* remove windows in reverse order */
removewindow(1);
scrncolor(BLACK,LTGRAY);
}

/* SAMPLE11.C

Using filetowindow() to write text files to a window on screen.
This is particularly usefull for presenting context sensitive help
from within your program. */

#include

main()
{
initwindows(DOUBLE,GREEN,WHITE,GREEN,BLACK);
scrncolor(BLUE,LTGRAY);

/* Open a window in which to place text. Don't make the window
too narrow or the word wrap will give a strange presentation.
In fact if the window is narrower than the widest word in the
file to be printed, the word wrap will be thoroughly confused.*/

makewindow(1,7,25,17,65,"Sample Text Window",SHADOW);

/* Now send a file name to filetowindow(). filetowindow() will
open the file and print it on the screen automatically doing
word wrap for you adjusting to the width of the window.
When the entire file has been printed it will be closed for you. */

filetowindow(1,"sample.txt",1,2); /* The coordinates are relative to the
text area of the window. The starting
row is used only for the first page of
output. From then on new pages always
start at row 1. The starting column is
used for all pages. */

windwrite(1,"Hit enter to continue.",9,10);

while(getch() != 13)
;
removewindow(1);
scrncolor(BLACK,LTGRAY);
}

/*
Important note: When creating files for automatic insertion and
word wrap in windows, it is necessary for the window formatting routine
to be able to distinguish between 'hard' and 'soft' carriage returns.
Soft returns are those which you used simply to write your file in normal
80 - column format. In other words they have nothing to do with formatting
text or numbers in their eventual windowed environment. Hard carriage returns,
on the other hand, are returns you inserted because you wanted to format the
text or numbers in the window. An example of a hard return is the end of a
paragraph. Another example is in formatting columns of numbers. For example:

COL1 COL2 COL3
100 200 300
200 300 400
___ ___ ___
tot xxx xxx xxx

The type carriage return is detected by looking ahead to the next
character after a carriage return is read from the input file. If the next
character is alphanumeric then the carriage return is considered 'soft'. If
the character following the return is a space or another return, then the
return is considered hard and will be used in the window formatting of the
text. For exapmple, consider the following examples:

Ex#1:
100 200
200 300
___ ___
tot xxx xxx

Ex#2:
100 200
200 300
___ ___
tot xxx xxx

Although these two examples look almost identical, only Example# 2
will format correctly in a window. Everything will work fine until the last
line in Example# 1. It is intended that there be a hard carriage return
preceding the word 'tot'. However since 'tot' starts in column 1, the hard
return is interpretted as soft. The solution is shown in Example# 2 where
the word 'tot' starts in column 2.
This quirk is the price to be paid for the luxury of automatic word
wrapping in any size window with any ASCII text file.

*/




 December 19, 2017  Add comments

Leave a Reply