home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d958 / alert.lha / Alert / Includes / MyAlert.h < prev   
C/C++ Source or Header  |  1993-12-10  |  1KB  |  53 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <intuition/intuition.h>
  4. #include <clib/intuition_protos.h>
  5.  
  6. // Return TRUE or FALSE if successful and -1 if not.
  7. int MyAlert(unsigned long alertNumber,char *message);
  8.  
  9. // This is how Intuition's DisplayAlert should have been implemented!
  10. // Feel free to use this routine in you program! 8-) Ketil
  11.  
  12. int MyAlert(unsigned long alertNumber,char *msg) {
  13.                     char    *alertMsg;
  14. register    UBYTE    *p,*c;
  15. register    int        ypos=14,result=0;
  16. register    BOOL    done=FALSE;
  17.                     char    *tmp,*message=strdup(msg);
  18.  
  19.     if(alertMsg=malloc(2500))
  20.     {
  21.         c=alertMsg;
  22.         while(!done)
  23.         {
  24.             tmp=message;
  25.             message=stpchr(message,'\n');
  26.             if(message==NULL)
  27.                 done=TRUE;
  28.             ++message;
  29.  
  30.             for(p=tmp; *p!='\n'; ++p);
  31.             *p='\0';
  32.  
  33.             *((USHORT *)c)=(80-strlen(tmp))<<2;
  34.             c++;
  35.             c++;
  36.             *c++=ypos;
  37.             while(*tmp!='\0')
  38.                 *c++=*tmp++;
  39.             *c++=0;
  40.             *c++=1;
  41.             ypos=ypos+11;
  42.  
  43.         }
  44.         *(c-1)=0;
  45.         result=DisplayAlert(RECOVERY_ALERT,alertMsg,ypos);
  46.         free(alertMsg);
  47.         return result;
  48.     } else
  49.         return -1;
  50.  
  51. return 0;
  52. }
  53.