home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 648a.lha / MTRD_Library_v0.99゚ / Print.c < prev   
C/C++ Source or Header  |  1992-06-12  |  2KB  |  76 lines

  1. /*** Print Mouse Test ***/
  2.  
  3. #include "MTRD.h"
  4. #include "MTRDTypes.h"
  5.  
  6. struct MtrdBase *MtrdBase;
  7.  
  8.  
  9. struct NewWindow newwindow = {
  10.     340,20,180,60,0,1,
  11.     CLOSEWINDOW,WINDOWDRAG|WINDOWCLOSE,
  12.     NULL,NULL,(UBYTE *)"Print Mouse",
  13.     NULL,NULL,0,0,0,0,WBENCHSCREEN
  14. };
  15.  
  16. void *IntuitionBase,*GfxBase;
  17. char myBuf[20];
  18. struct FileList flist[4];
  19.  
  20.  
  21. main()
  22. {
  23.     struct MFile *File;
  24.     struct MUser *User;
  25.     int got,i,out=FALSE;
  26.     ULONG class,sig,type;
  27.     struct Window *win;
  28.     struct IntuiMessage *msg;
  29.     struct MsgPort *Port;
  30.     struct MUpdate *mu;
  31.  
  32.     IntuitionBase=OpenLibrary("intuition.library",0);
  33.     GfxBase=OpenLibrary("graphics.library",0);
  34.     MtrdBase=OpenLibrary("mtrd.library",0);
  35.     Port=CreatePort("PrintMousePort",0);
  36.     got=GetFileList(flist,4,MTT_MOUSE,GET_ALL);
  37.     for (i=0; i<got; i++)
  38.         if (flist[i].FID.SubType & MTS_CHAR)
  39.             break;
  40.     if (i<got) {
  41.         win=OpenWindow(&newwindow);
  42.         SetAPen(win->RPort,1);
  43.         SetDrMd(win->RPort,JAM2);
  44.         User=AddUser(flist[i].File,Port,myBuf,MUSF_BUFFER|MUSF_NOTIFY|MUSF_LOCKWRITE);
  45.         sig=(1<<win->UserPort->mp_SigBit)|(1<<Port->mp_SigBit);
  46.         while (!out) {
  47.             Wait(sig);
  48.             while (msg=(struct IntuiMessage *)GetMsg(win->UserPort)) {
  49.                 class=msg->Class;
  50.                 ReplyMsg((struct Message *)msg);
  51.                 if (class==CLOSEWINDOW) {
  52.                     RemUser(User);
  53.                     out=TRUE;
  54.                 }
  55.             }
  56.             while (mu=(struct MUpdate *)GetMsg(Port)) {
  57.                 type=mu->Type;
  58.                 ReplyMsg((struct Message *)mu);
  59.                 if (type==MTUP_UPDATE) {
  60.                     Move(win->RPort,20,35);
  61.                     strcat(myBuf,"   ");
  62.                     Text(win->RPort,myBuf,strlen(myBuf));
  63.                     UNLOCK(User);
  64.                 }
  65.                 if (type==MTUP_CLOSE)
  66.                     out=TRUE;
  67.             }
  68.         }
  69.         CloseWindow(win);
  70.     }
  71.     DeletePort(Port);
  72.     CloseLibrary(MtrdBase);
  73.     CloseLibrary(GfxBase);
  74.     CloseLibrary(IntuitionBase);
  75. }
  76.