home *** CD-ROM | disk | FTP | other *** search
- #include "tsr.h"
- #include "resproto.h"
- #include "stdio.h"
- #include "conio.h"
- #include "process.h"
-
- /* R_HELLO.C */
- /* print Hello World! when Alt-H,
- Ctrl-H or Right-shift-J is pressed */
-
- /* scan codes for H and J keys used below */
- #define SCAN_H 0x23
- #define SCAN_J 0x24
-
- /* window save buffer declared globally */
- char scrnbuf[300];
-
- /* define two extra hotkeys */
- struct HKEYS more_keys[2] = {SCAN_H,CTRL_KEY,1,
- SCAN_J,RIGHT_SHIFT,2};
-
- /* unique signature function number for
- identification in tsrloaded() */
-
- /* hotkey number which is only needed for multiple hotkeys */
- extern int _hotkey_num;
-
- unsigned int r_hello = 0x1260;
-
- void resprog();
-
- void main()
- {
- int rc; /* return code variable */
- /* declare function to execute when we get
- control in TSR (when hotkey is hit) */
-
- /* test if our TSR is already loaded */
- if (!tsrloaded(r_hello))
- {
- if ((rc = inittsr(ALT_KEY, SCAN_H, resprog,
- 20, r_hello, SIG ,(void far *)NULL)) != 0)
- {
- printf("Could Not Load. Error = %d \n",
- rc);
- exit(1);
- }
- }
- }
-
- /* this function gets control when popped up */
- void resprog()
- {
- int page; /* video page */
- int mode; /* video mode */
- int key; /* key hit */
- /* retrieve video mode and video page */
- getvmod(&mode,&page);
-
- /* see if we are in 80 column text modes */
- if ( mode != 2 && mode != 3 && mode != 7 )
- {
- putch(7); /* if yes, beep and exit */
- return;
- }
-
- /* save window in center of screen */
- savwindo(10,28,15,52,scrnbuf);
-
- savcur(); /* save cursor */
-
- /* clear the window in reverse video */
- scroll_vid(0,0,7,10,28,15,52,1);
-
- loc_cur(12,34); /* locate cursor in window */
- printf("Hello World!");
- loc_cur(13,34); /* locate cursor in window */
- printf("Hotkey # = %d",_hotkey_num);
-
- key = getch(); /* wait for a key to return */
- if(key == 0) /* if extended key, get it */
- getch();
-
- rstcur(); /* put cursor back */
-
- /* restore the window in center of screen */
- rstwindo(10,28,15,52,scrnbuf);
-
- /* if Q key was hit, try to unload program */
- if ((key == 'Q') || (key == 'q')){
- key = freetsr(); /* use key for return code */
- if (key != 0){ /* if can not free beep */
- putch(7);
- putch(7);
- }
- }
-
- return;
- }
-
- void tsrpre()
- {
- tsrhotkeys(r_hello,(struct HKEYS far *)more_keys,2);
- printf("Program successfully loaded!!!!\n");
- printf("Hit Alt-H, Ctrl-H, or RightShift-J to Pop-Up\n");
- printf("Hit any key to continue.\n");
- getch();
- return;
- }
-
- void tsrpost()
- {
- /* beep once*/
- putch(7);
- return;
- }