home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
desqview
/
tvgluetc.arc
/
INT15DEM.C
< prev
Wrap
C/C++ Source or Header
|
1988-02-22
|
4KB
|
170 lines
/*
** INT15DEM.C - demonstration program.
** IBM Personal Computer - TopView C Interface Header File.
** Written for Borland Turbo C v1.5.
*/
#include <dos.h>
#include <io.h>
#include <string.h>
#include "int15def.h" /* definitions */
#include "int15c.h" /* types and function prototypes */
#define STDOUT 1
#define STDERR 2
#define WR_STR(f,s) write(f,s,strlen(s)) /* write any string */
#define SO_STR(s) WR_STR(STDOUT,s) /* any string to STDOUT */
#define SE_STR(s) WR_STR(STDERR,s) /* any string to STDERR */
#define WR_STRC(f,s) write(f,s,sizeof(s)-1) /* string constant */
#define SO_STRC(s) WR_STRC(STDOUT,s) /* string con to STDOUT */
#define SE_STRC(s) WR_STRC(STDERR,s) /* string con to STDERR */
void pascal tv_tone( /* SOUND A TONE THRU TOPVIEW */
WORD frequency, /* hertz */
WORD duration /* timer ticks (18.2/second) */
)
{
REGLIST r;
r.bxreg = frequency;
r.cxreg = duration;
SubCall(SOUND,&r);
}
OBJECT pascal tv_object( /* GET A TOPVIEW OBJECT HANDLE */
WORD modifier /* which object */
)
{
PARMLIST p;
p.num_args = 0;
SendMsg(OBJECT_MSG,modifier,0,&p);
return (OBJECT)p.arg[0];
}
int pascal tv_errormsg( /* TOPVIEW ERROR MESSAGE WINDOW */
OBJECT window, /* handle of window object (0=ME) */
char *string, /* message text */
int tone, /* 1=sound a tone */
int button, /* 0=either; 1=1; 2=2; 3=either */
int rows, /* 0=default */
int columns /* 0=default */
)
{
REGLIST r;
typedef struct { WORD x:13, b:2, t:1; } TBX;
r.dxreg = window ? FP_SEG(window) : FP_SEG(tv_object(ME)) ;
r.esreg = FP_SEG((char far*)string);
r.direg = FP_OFF(string);
(*(TBX*)&r.bxreg).x = strlen(string);
(*(TBX*)&r.bxreg).b = button;
(*(TBX*)&r.bxreg).t = tone;
r.cxreg = rows | (columns << 8);
SubCall(DISPEROR,&r);
return r.bxreg;
}
void pascal tv_printc( /* CALL TOPVIEW TO PRINT A CHARACTER */
int character,
int attribute,
OBJECT window /* handle of window object (0=ME) */
)
{
REGLIST r;
r.dxreg = window ? FP_SEG(window) : FP_SEG(tv_object(ME)) ;
r.bxreg = character | (attribute << 8);
SubCall(PRINTC,&r);
}
void pascal tv_pause(void)
{
REGLIST r;
SubCall(PAUSE,&r);
}
OBJECT pascal tv_newtimer(void) /* GET A NEW TOPVIEW TIMER */
{
PARMLIST p;
p.num_args = 0;
SendMsg(NEW_MSG,TIMER_CLASS,0,&p);
p.num_args = 0;
return (OBJECT)p.arg[0];
}
void pascal tv_addtimer( /* SET A TOPVIEW TIMER INTERVAL */
OBJECT timer, /* timer object */
DWORD time /* 1/100ths of a second from now */
)
{
PARMLIST p;
p.num_args = 1;
p.arg[0] = time;
SendMsg(ADDTO_MSG,TOS,timer,&p);
}
DWORD pascal tv_lentimer( /* TIMER REMAINING IN TOPVIEW TIMER */
OBJECT timer /* timer object */
)
{
PARMLIST p;
p.num_args = 0;
SendMsg(LEN_MSG,TOS,timer,&p);
return p.arg[0];
}
DWORD pascal tv_readtimer( /* READ/WAIT FOR TOPVIEW TIMER */
OBJECT timer /* timer object */
)
{
PARMLIST p;
p.num_args = 0;
SendMsg(READ_MSG,TOS,timer,&p);
return p.arg[0];
}
void pascal tv_freetimer( /* SET A TOPVIEW TIMER INTERVAL */
OBJECT timer /* timer object */
)
{
PARMLIST p;
p.num_args = 0;
SendMsg(FREE_MSG,TOS,timer,&p);
}
void window_test(void)
{
PARMLIST p;
p.num_args = 2;
p.arg[0] = 6;
p.arg[1] = 2;
SendMsg(AT_MSG,ME,0,&p);
p.num_args = 2;
p.arg[0] = (DWORD)(void far*)"path";
p.arg[1] = 4;
SendMsg(WRITE_MSG,ME,0,&p);
tv_printc(0,0,0); /* position the hardware cursor */
#if 0
p.num_args = 0;
SendMsg(REDRAW_MSG,ME,0,&p);
#endif
}
main()
{
OBJECT t;
if (!TopVer()) {
SE_STRC("This program requires TopView\n");
return 1;
}
window_test();
tv_addtimer(t=tv_newtimer(),500); /* 5 seconds */
tv_readtimer(t); /* wait */
tv_freetimer(t);
tv_errormsg(0,"TEST ERROR MESSAGE - press ESC",1,0,0,0);
tv_tone(500,5);
tv_tone(750,2);
tv_tone(400,3);
return 0;
}