| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | help |
G'Day Daryl,
-=> Quoting Daryl Willis to All <=-
DW> Help I realy need to know how in text/dos mode 45*80
DW> screen Borland C++ 3.1 How can I save a section of
DW> screen to display a message then remove message and
DW> replace original screen.
/* Dammit, i did have a good little class to do this, i can't find it,
** i can't even remember what i made it for. Senility hit me 25-30
** years too early, or perhaps i'm just more advanced than most..
** Anyway i whipped this up for you, i think it's good, it started off
** as a simple example but once i get going:) it'd be better as a class.
** Sorry couldn't be stuffed with the docs, but if you have probs let
** me know. PS: Andrew's Vidmanager might do this quicker. Come to
** think of it,i can't find that either. Should clean the HDs. :)
*/
/* WARNING ! Contact with ANSI/ISO will seriously effect this code :-)*/
#include
#include
#include
#include
struct mb
{
int oldfore;
int oldback;
int x,y,xx,yy;
char *buffer;
};
int Save_Win(int,int,int,int,struct mb*);
int Restore_Win(struct mb*);
void Pop_Win(struct mb*,char*,int,int,int);
main()
{
int i;
char *msg = "This is a POP UP window\n\r Enjoy ! :-)\n\r\
Or Press a key..:-(";
int x=5,y=10,xx=30,yy=15;
clrscr();
for(i = 1;i<24;i++)
printf("\n1234567890123456789012345678901234567890");
struct mb* pop;
Save_Win(x,y,xx,yy,pop);
Pop_Win(pop,msg,CYAN,BLACK,32);
while(!kbhit());
Restore_Win(pop);
return 0;
}
int Save_Win(int x,int y,int xx,int yy,mb* buff)
{
struct text_info info; int st;
char *localbuff;
buff->buffer = (char*) malloc((yy-y+1) * (xx-x+1) + 1);
if(!buff->buffer) return -1;
st = gettext(x,y,xx,yy,buff->buffer);
if(!st) return -1;
buff->x = x;buff->y = y;
buff->xx = xx;buff->yy = yy;
gettextinfo(&info);
buff->oldfore = info.attribute % 16;
buff->oldback = (info.attribute - buff->oldfore) /16;
return 0;
}
int Restore_Win(mb* buff)
{
int fore,back;
if(!buff->buffer) return -1;
textcolor(buff->oldfore);textbackground(buff->oldback);
puttext(buff->x,buff->y,buff->xx,buff->yy,buff->buffer);
window(1,1,80,25);
return 0;
}
void Pop_Win(mb* buff,char *txt,int fore,int back,int frame)
{
int i;
if(frame)
{
textcolor(back);textbackground(fore);
gotoxy(buff->x,buff->y);
cprintf("%*c",buff->xx - buff->x + 1,frame);
gotoxy(buff->x,buff->yy);
cprintf("%*c",buff->xx - buff->x + 1,frame);
for(i=buff->y;i yy;i++)
{
gotoxy(buff->x,i);putch(frame);
gotoxy(buff->xx, i);putch(frame);
}
textcolor(fore);textbackground(back);
window(buff->x+1,buff->y+1,buff->xx-1,buff->yy-1);
}
else
{
window(buff->x,buff->y,buff->xx,buff->yy);
textcolor(fore);textbackground(back);
}
clrscr();
cprintf("%s",txt);
}
L8r Frank (fadam{at}ozemail.com.au).
--- Maximus 3.01
* Origin: The Software Parlour (3:635/544)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413 SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/544 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.