home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 568a.lha / APIG_v1.1 / e2_window.rexx < prev    next >
OS/2 REXX Batch file  |  1991-09-28  |  4KB  |  108 lines

  1.  
  2. /* This example simply opens a window 
  3.    displays intui-messages received                      */
  4.  
  5.  
  6. /*  add library */
  7.  
  8. x = addlib("apig.library",0,-30,0)
  9.  
  10. portname = "example2_port"   /* this is the name of the port that */
  11.                              /* intuimessages will be sent to     */
  12.                              
  13. p = openport(portname)       /* create the port                   */
  14.  
  15. call set_apig_globals()      /* initialize INTUITION constants    */
  16.  
  17. wintitle = "This is your Window title"
  18.  
  19. /* the INTUI-Events you want the window to receive                */
  20. winidcmp = CLOSEWINDOW+MOUSEMOVE+INTUITICKS+MOUSEBUTTONS+RAWKEY+NEWSIZE,
  21.            + DISKREMOVED+DISKINSERTED
  22.            
  23. /* set window flags for system gadgets and type of window you want   */
  24. winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO,
  25.            + REPORTMOUSE+ACTIVATE+RMBTRAP
  26. scr = 0
  27.  
  28. /*  open window, since scr = 0 the window opens on WorkBench screen  */
  29. win = openwindow(portname,0,0,640,200,2,4,winidcmp,winflags,wintitle,scr,1,0,0)
  30.  
  31. z = writeconsole(win,'0a'x || '0a'x || '0a'x || '0a'x)
  32. z = writeconsole(win,"This example looks for various Intui-Events" || '0a'x)
  33. z = writeconsole(win,"    looks for mouse moves, resizing the window, " || '0a'x)
  34. z = writeconsole(win,"    mousebuttons, raw key events, " || '0a'x)
  35. z = writeconsole(win,"    and inserting/removing a disk " || '0a'x)
  36.  
  37. z = tickfrequency(win,8)
  38. do forever       /* the main 'wait' loop for message arrival */
  39.  
  40.      x = waitpkt(portname)
  41.   
  42.      do forever  /* get all message packets until getpkt() returns null */
  43.      
  44.         msg = getpkt(portname)
  45.         if msg = '0000 0000'x then leave
  46.         
  47.         class = getarg(msg,0)
  48.         
  49.         select 
  50.               when class = CLOSEWINDOW then
  51.                    do
  52.                       z = writeconsole(win,"Received CLOSEWINDOW ... bye bye " || '0a'x)
  53.                       exitme = 1
  54.                    end
  55.                    
  56.               when class = MOUSEMOVE then 
  57.                          z = writeconsole(win,"Yo, MOUSE MOVED" || '0a'x)
  58.               when class = INTUITICKS then 
  59.                          z = writeconsole(win,"Yo, INTUITICK" || '0a'x)
  60.               when class = MOUSEBUTTONS then 
  61.                    do
  62.                       z = writeconsole(win,"Yo, MOUSEBUTTONS" || '0a'x)
  63.                       if getarg(msg,1) = SELECTUP then 
  64.                          z = writeconsole(win,"    SELECTUP" || '0a'x)
  65.                       if getarg(msg,1) = SELECTDOWN then 
  66.                          z = writeconsole(win,"    SELECTDOWN" || '0a'x)
  67.                       if getarg(msg,1) = MENUUP then 
  68.                          z = writeconsole(win,"    MENUUP" || '0a'x)
  69.                       if getarg(msg,1) = MENUDOWN then
  70.                          z = writeconsole(win,"    MENUDOWNTUP" || '0a'x)
  71.                    end
  72.               when class = RAWKEY then
  73.                        do
  74.                          keycode = getarg(msg,1)
  75.                          keyqual = getarg(msg,2)
  76.                          keymap  = 0            /* sorry no keymap support */
  77.                          rkey = convertrawkey(keycode,keyqual,keymap)
  78.                          z = writeconsole(win,"Yo, RAWKEY")
  79.                          z = writeconsole(win," ... key " rkey "was pressed" || '0a'x)
  80.                        end
  81.               when class = NEWSIZE then 
  82.                          z = writeconsole(win,"Yo, NEWSIZE" || '0a'x)
  83.               when class = DISKREMOVED then 
  84.                          z = writeconsole(win,"Yo, DISKREMOVED" || '0a'x)
  85.               when class = DISKINSERTED then 
  86.                          z = writeconsole(win,"Yo, DISKINSERTED" || '0a'x)
  87.               
  88.               otherwise  nop
  89.         end
  90.         
  91.         x = reply(msg,0)  
  92.         
  93.      end  
  94.      
  95.    if exitme = 1 then leave
  96.    
  97. end
  98.  
  99. do forever  /* reply to any message left over */
  100.    msg = getpkt(portname)
  101.    if msg = '0000 0000'x then leave
  102.    x = reply(msg,0)
  103. end
  104.         
  105. a = closewindow(win)
  106.   
  107. exit
  108.