home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / amigae / e_v3.2a / rkrmsrc / workbench / appwindow.e < prev    next >
Text File  |  1977-12-31  |  3KB  |  76 lines

  1. -> appwindow.e -- Show use of an AppWindow
  2.  
  3. OPT OSVERSION=37
  4.  
  5. MODULE 'wb',
  6.        'exec/ports',
  7.        'intuition/intuition',
  8.        'workbench/startup',
  9.        'workbench/workbench'
  10.  
  11. ENUM ERR_NONE, ERR_APPWIN, ERR_LIB, ERR_PORT, ERR_WIN
  12.  
  13. RAISE ERR_APPWIN IF AddAppWindowA()=NIL,
  14.       ERR_LIB    IF OpenLibrary()=NIL,
  15.       ERR_PORT   IF CreateMsgPort()=NIL,
  16.       ERR_WIN    IF OpenWindowTagList()=NIL
  17.  
  18. PROC main() HANDLE
  19.   DEF awport=NIL:PTR TO mp, win=NIL:PTR TO window, appwin=NIL,
  20.       imsg:PTR TO intuimessage, amsg:PTR TO appmessage, argptr:PTR TO wbarg,
  21.       winsig, appwinsig, signals, id=1, userdata=0, done=FALSE, i
  22.   workbenchbase:=OpenLibrary('workbench.library', 37)
  23.   -> The CreateMsgPort() function is in Exec version 37 and later only
  24.   awport:=CreateMsgPort()
  25.   win:=OpenWindowTagList(NIL, [WA_WIDTH, 200, WA_HEIGHT, 50,
  26.                                -> E-Note: C version uses obsolete flags
  27.                                WA_IDCMP, IDCMP_CLOSEWINDOW,
  28.                                WA_FLAGS, WFLG_CLOSEGADGET OR WFLG_DRAGBAR,
  29.                                WA_TITLE, 'AppWindow',
  30.                                NIL])
  31.   appwin:=AddAppWindowA(id, userdata, win, awport, NIL)
  32.   WriteF('AppWindow added... Drag files into AppWindow\n')
  33.   winsig:=Shl(1, win.userport.sigbit)
  34.   appwinsig:=Shl(1, awport.sigbit)
  35.   REPEAT
  36.     -> Wait for IDCMP messages and AppMessages
  37.     signals:=Wait(winsig OR appwinsig)
  38.  
  39.     IF signals AND winsig  -> Got an IDCMP message
  40.       WHILE imsg:=GetMsg(win.userport)
  41.         -> E-Note: C version uses obsolete flags
  42.         IF imsg.class=IDCMP_CLOSEWINDOW THEN done:=TRUE
  43.         ReplyMsg(imsg)
  44.       ENDWHILE
  45.     ENDIF
  46.     IF signals AND appwinsig  -> Got an AppMessage
  47.       WHILE amsg:=GetMsg(awport)
  48.         WriteF('AppMsg: Type=\d, ID=\d, NumArgs=\d\n',
  49.                amsg.type, amsg.id, amsg.numargs)
  50.         argptr:=amsg.arglist
  51.         FOR i:=0 TO amsg.numargs-1
  52.           WriteF('   arg(\d): Name="\s", Lock=\h\n',
  53.                  i, argptr.name, argptr.lock)
  54.           argptr++
  55.         ENDFOR
  56.         ReplyMsg(amsg)
  57.       ENDWHILE
  58.     ENDIF
  59.   UNTIL done
  60.  
  61. EXCEPT DO
  62.   IF appwin THEN RemoveAppWindow(appwin)
  63.   IF win THEN CloseWindow(win)
  64.   IF awport
  65.     -> Make sure there are no more outstanding messages
  66.     WHILE amsg:=GetMsg(awport) DO ReplyMsg(amsg)
  67.     DeleteMsgPort(awport)
  68.   ENDIF
  69.   IF workbenchbase THEN CloseLibrary(workbenchbase)
  70.   SELECT exception
  71.   CASE ERR_APPWIN; WriteF('Error: Could not create AppWindow\n')
  72.   CASE ERR_LIB;    WriteF('Error: Could not open required library\n')
  73.   CASE ERR_PORT;   WriteF('Error: Could not create port\n')
  74.   CASE ERR_WIN;    WriteF('Error: Could not open window\n')
  75.   ENDSELECT
  76. ENDPROC