home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI452.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
2KB
|
67 lines
PRODUCT : TURBO C NUMBER : 452
VERSION : 2.O
OS : PC-DOS
DATE : FEBRUARY 2, 1989 PAGE : 1/1
TITLE : ERASING CHARACTERS (OR "TEXT")
The following program demonstrates two methods of removing
previously displayed characters. The first method uses the bar
function to erase the desired area of the screen. The second
method involves overwriting the font in the current background
color. Both methods are effective, and the choice of methods
would be based on the needs of the particular application.
#include <graphics.h>
#include <dos.h>
main()
{
int driver = DETECT; /* autodetect driver */
int mode;
int oldcolor;
int x=10;
int y=10;
char string1[] = "Hello";
char string2[] = "world";
char string3[] = "Goodbye";
initgraph(&driver, &mode, "");
outtextxy(x, y, string1); /* print a string */
sleep(1); /* wait a second */
/*** erase text by drawing a bar ***/
setfillstyle(SOLID_FILL, getbkcolor());
bar(x, y, x+textwidth(string1), y+textheight(string1));
outtextxy(x, y, string2); /* print another string */
sleep(1); /* wait another second */
/*** erase the string by overwriting ***/
oldcolor = getcolor(); /* save current color */
setcolor( getbkcolor() ); /* set to background color */
outtextxy(x, y, string2); /* erase string */
setcolor(oldcolor); /* restore color */
outtextxy(x, y, string3); /* print one more string */
sleep(1); /* wait one more second */
closegraph();
return 0;
}