"screen.h"
header file
This header file
was designed in an attempt to recapture some of the screen
manipulation features that exist in the conio.h
file in Borland Turbo C++. The conio.h
header file in Visual C++ does not offer these same features.
Using this header file will eliminate having to include the function definitions
each time you wish to use these concepts. It will also allow these
functions to be easily accessed by beginning programmers, who are unfamiliar
with the use of functions.
Read before
downloading:
When you open the download file on the
right,
choose FILE/SAVE AS, name the file
screen.h,
choose Type to be
.txt.
Choose the Include directory of your Microsoft Visual C++ software.
c:/Program Files/Microsoft Visual
Studio/Vc98/Include |
Download the
screen.h file
Place it in the include directory
of Microsoft Visual C++. |
|
Pause (delay) screen output:
delay(5000);
Note: The argument (the value sent to
this function) is time in milliseconds. (5000 =
about 5 seconds). Unlike the system("PAUSE");,
no message is displayed on the screen. If you wish to delay the screen after a
cout statement, you will need to "flush" the
iostream.
(Requires header file "screen.h")
|
|
cout<< "Please wait."<<flush; //flush forces printing to the screen before delay
delay(5000); //delays for about 5 seconds
cout<< "Thank you for waiting."<<endl;
|
|
Move the cursor around the screen:
gotoxy(x,y);
Note: Move the cursor on the screen to any coordinates (x,y).
As in mathematics, x is the horizontal coordinate and y is the vertical coordinate.
Remember that the screen is 80 wide and 22 high and the point (1,1) will
be the upper left corner. You will need to "flush" the iostream between successive uses of
gotoxy( , ).
(Requires header file
"screen.h")
|
|
system ("CLS");
gotoxy(10,10);
cout<< "Kilroy was here!"<<endl;
//Kilroy was here! will be printed starting at
(10,10)
cout<< "Now, he is here!";
//Now, he is here! will be printed back at the left side of the screen
|
|
Get keyboard response - response not visible
getch( );
Note: getch( ) waits for the user to
press a key, returns this response, and moves on. It will NOT show
the response on the screen (no echo). You will not see what was typed.
It does NOT wait for the user to press the ENTER key.
(Requires header file
"screen.h")
|
|
cout<<"Press any key to continue"; //pauses
and waits for key strike
getch( );
cout<<"Press your favorite letter";
char letter = getch( ); //no response from
user seen on screen
cout<< "Your favorite letter is "<< letter;
|
|
Get keyboard response - response visible
getche( );
Note: getche( ) waits for the user to press
a key, returns this response, and moves on. It WILL show the
response on the screen (echo). You will see what was typed.
It does NOT wait for the user to press the ENTER key.
(Requires header file
"screen.h")
|
|
cout<<"Press any key to continue"; //pauses
and waits for key strike
getch( ); //response not seen
cout<<"Press your favorite letter";
char letter = getche( ); //response from
user seen on screen
cout<< "I see that you like the letter "<< letter;
|
|