home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Programming / crys046.lzh / CRYSTAL0.46 / TST / XSAMPLE / XSAMPLE.M2 < prev    next >
Encoding:
Text File  |  1993-04-03  |  15.7 KB  |  579 lines

  1. (***************************************************************************)
  2. (* GEM sample application                                                  *)
  3. (* adapted from apskel.c by Ron Zdybl, Atari Corp.                         *)
  4. (*                                                                         *)
  5. (* UK 01/24/1993                                                           *)
  6. (***************************************************************************)
  7.  
  8. MODULE XSample;
  9.  
  10. FROM AES        IMPORT Root,Nil,ObjectIndex,ObjectPtr,TreeIndex,
  11.                        TreePtr,StringPtr,
  12.                        ObjectState,Selected,State15,Checked,
  13.                        HideTree,Key,SpecialKey,MouseButton,MBLeft;
  14. FROM ApplMgr    IMPORT ApplInit,ApplExit,ApplWrite;
  15. FROM EvntMgr    IMPORT EvntEvent,MEvent,MuMesag,MuKeybd,MuButton,Event,
  16.                        MessageBlock,Messages;
  17. FROM ObjcMgr    IMPORT ObjcDraw,MaxDepth,ObjcOffset,ObjcFind,ObjcChange;
  18. FROM FormMgr    IMPORT FmDStart,FmDGrow,FmDShrink,FmDFinish,FormDial,
  19.                        FormCenter,FormDo;
  20. FROM MenuMgr    IMPORT MenuBar,MenuICheck,MenuText,MenuTNormal;
  21. FROM GrafMgr    IMPORT GrafHandle,GrafDragBox,
  22.                        GrafMKState,GrafGrowBox,GrafShrinkBox;
  23. FROM RsrcMgr    IMPORT RsrcLoad,RsrcFree;
  24. FROM WindMgr    IMPORT NoWindow,Desk,WindCreate,WindOpen,WindClose,
  25.                        WindFind,WindDelete,WindCalc,WCBorder,WCWork,
  26.                        Wind,Name,Close,Full,Move,Info,Size,HSlide,VSlide;
  27. FROM RcMgr      IMPORT GRect,GPnt,RcSnap,RcIntersect,RcEqual;
  28. FROM MenuTool   IMPORT MenuKey,NewMenuAction,MenuAction;
  29. FROM ObjcTool   IMPORT ObjectXYWH,INCLObjectState,EXCLObjectState,
  30.                        INCLObjectFlags,EXCLObjectFlags,TreeWalk,
  31.                        IndirectObject;
  32. FROM FormTool   IMPORT OK,Alert,Mask;
  33. FROM RsrcTool   IMPORT GetTreePtr,GetFreeStringPtr;
  34. FROM GrafTool   IMPORT ShowMouse,HideMouse,BusyMouse,MouseForm,FlatHand,
  35.                        PointingHand,ArrowMouse,LastMouse,RubberBox;
  36. FROM WindTool   IMPORT GetWorkXYWH,GetFirstXYWH,GetNextXYWH,SetTop,
  37.                        SetName,SetInfo,SetCurrXYWH,GetCurrXYWH,
  38.                        GetFullXYWH,GetPrevXYWH,
  39.                        BeginUpdate,EndUpdate,
  40.                        BeginMouseControl,EndMouseControl,
  41.                        RedrawWindow;
  42. FROM DeskTool   IMPORT OpenDesk,CloseDesk,DrawDeskObject;
  43. FROM VDI        IMPORT XY,White,Black,Blue;
  44. FROM VAttribute IMPORT VSFInterior,FISPattern,VSFStyle,VSFColor;
  45. FROM VOutput    IMPORT VBar,VEllipse;
  46. FROM VDITool    IMPORT OpenVirtualWorkstation,CloseVirtualWorkstation,
  47.                        SetClip,GRectToArray;
  48. FROM INTRINSIC  IMPORT VOID,PTR;
  49. FROM PORTAB     IMPORT UNSIGNEDWORD,SIGNEDWORD;
  50.  
  51. IMPORT FlyingLook,SetObject,GetObject;
  52.  
  53. (* Resource Indices *)
  54.  
  55. CONST
  56.  
  57.     MENU     =   0;    (* Menuebaum *)
  58.     TINFO    =   3;    (* TITLE in Baum MENU *)
  59.     TFILE    =   4;    (* TITLE in Baum MENU *)
  60.     TEDIT    =   5;    (* TITLE in Baum MENU *)
  61.     TOPTION  =   6;    (* TITLE in Baum MENU *)
  62.     IINFO    =   9;    (* STRING in Baum MENU *)
  63.     INEW     =  18;    (* STRING in Baum MENU *)
  64.     IOPEN    =  19;    (* STRING in Baum MENU *)
  65.     ISAVE    =  21;    (* STRING in Baum MENU *)
  66.     IQUIT    =  28;    (* STRING in Baum MENU *)
  67.     IUNDO    =  30;    (* STRING in Baum MENU *)
  68.     ICUT     =  32;    (* STRING in Baum MENU *)
  69.     ICOPY    =  33;    (* STRING in Baum MENU *)
  70.     IPASTE   =  34;    (* STRING in Baum MENU *)
  71.     IDELETE  =  36;    (* STRING in Baum MENU *)
  72.     IWARNING =  38;    (* STRING in Baum MENU *)
  73.     IHELP    =  39;    (* STRING in Baum MENU *)
  74.     IELL     =  41;    (* STRING in Baum MENU *)
  75.     IRS232   =  42;    (* STRING in Baum MENU *)
  76.     IFORMAT  =  43;    (* STRING in Baum MENU *)
  77.  
  78.     DESK     =   1;    (* Formular/Dialog *)
  79.     DISKA    =   3;    (* ICON in Baum DESK *)
  80.     DISKB    =   4;    (* ICON in Baum DESK *)
  81.     FOLDER   =   5;    (* ICON in Baum DESK *)
  82.     COLICON  =   6;    (* ICON in Baum DESK *)
  83.  
  84.     INFO     =   2;    (* Formular/Dialog *)
  85.     INFOK    =   1;    (* BUTTON in Baum INFO *)
  86.     INFTITLE =   4;    (* STRING in Baum INFO *)
  87.  
  88.     RS232    =   6;    (* Formular/Dialog *)
  89.     RSOK     =   1;    (* BUTTON in Baum RS232 *)
  90.     RSCANCEL =   2;    (* BUTTON in Baum RS232 *)
  91.     RSTITLE  =  24;    (* STRING in Baum RS232 *)
  92.  
  93.     ELLEDIT  =   7;    (* Formular/Dialog *)
  94.     ELLCANCL =   3;    (* BUTTON in Baum ELLEDIT *)
  95.     ELLOK    =   4;    (* BUTTON in Baum ELLEDIT *)
  96.  
  97.     PGFORMAT =   8;    (* Formular/Dialog *)
  98.  
  99.     FORMAT   =   9;    (* Formular/Dialog *)
  100.  
  101.     MSRUNIT  =  10;    (* Formular/Dialog *)
  102.  
  103.     OUTPUTTO =  11;    (* Formular/Dialog *)
  104.  
  105.     WNAME    =   0;    (* Freier String *)
  106.  
  107.     WINFO    =   1;    (* Freier String *)
  108.  
  109.     HELPON   =   2;    (* Freier String *)
  110.  
  111.     HELPOFF  =   3;    (* Freier String *)
  112.  
  113.     NOWIND   =   4;    (* Alert String *)
  114.  
  115.     NOVWORK  =   5;    (* Alert String *)
  116.  
  117.     QUIT     =   6;    (* Alert String *)
  118.  
  119.     DOUBLECL =   7;    (* Alert String *)
  120.  
  121. CONST RscName   = "XSAMPLE.RSC";
  122.       MyFeature = Wind{Name,Close,Full,Move,Info,Size,HSlide,VSlide};
  123.  
  124. VAR ApplId    : SIGNEDWORD;
  125.     VirtScreen: UNSIGNEDWORD;
  126.  
  127.     MyMenu    : TreePtr;
  128.     MyDesk    : TreePtr;
  129.     MyName    : StringPtr;
  130.     MyInfo    : StringPtr;
  131.     HelpItem  : StringPtr;
  132.  
  133.     MyWindow  : SIGNEDWORD;
  134.  
  135.     Work      : GRect;
  136.     XEll      : UNSIGNEDWORD;
  137.     YEll      : UNSIGNEDWORD;
  138.     WEll      : UNSIGNEDWORD;
  139.     HEll      : UNSIGNEDWORD;
  140.  
  141.     CharWidth : UNSIGNEDWORD;
  142.     CharHeight: UNSIGNEDWORD;
  143.     BoxWidth  : UNSIGNEDWORD;
  144.     BoxHeight : UNSIGNEDWORD;
  145.  
  146.     MinWidth  : SIGNEDWORD;
  147.     MinHeight : SIGNEDWORD;
  148.  
  149. PROCEDURE OpenWindow(VAR Window: SIGNEDWORD): BOOLEAN;
  150.  
  151. VAR Start: GRect;
  152.     Full : GRect;
  153.  
  154. BEGIN
  155.   GetWorkXYWH(Desk,Full);
  156.   Window:= WindCreate(MyFeature,Full);
  157.   IF Window # NoWindow THEN
  158.  
  159.     MyName:= GetFreeStringPtr(WNAME);
  160.     SetName(Window,MyName^);
  161.  
  162.     MyInfo:= GetFreeStringPtr(WINFO);
  163.     SetInfo(Window,MyInfo^);
  164.  
  165.     WITH Full DO
  166.       Start.GX:= GX + GW DIV 2;
  167.       Start.GY:= GY + GH DIV 2;
  168.       Start.GW:= BoxWidth;
  169.       Start.GH:= BoxHeight;
  170.     END;
  171.  
  172.     GrafGrowBox(Start,Full);
  173.     WindOpen(Window,Full);
  174.   END;
  175.   RETURN Window # NoWindow;
  176. END OpenWindow;
  177.  
  178. PROCEDURE CloseWindow(Window: SIGNEDWORD);
  179.  
  180. VAR Start: GRect;
  181.     End  : GRect;
  182.     Full : GRect;
  183.  
  184. BEGIN
  185.   GetCurrXYWH(Window,Start);
  186.   GetWorkXYWH(Desk,Full);
  187.  
  188.   WITH Full DO
  189.     End.GX:= GW DIV 2;
  190.     End.GY:= GH DIV 2;
  191.     End.GW:= BoxWidth;
  192.     End.GH:= BoxHeight;
  193.   END;
  194.  
  195.   WindClose(Window);
  196.   GrafShrinkBox(End,Start);
  197.   WindDelete(Window);
  198. END CloseWindow;
  199.  
  200. PROCEDURE DrawSample(VAR Rect: GRect);
  201.  
  202. VAR Points: ARRAY[0..3] OF XY;
  203.     Work  : GRect;
  204.  
  205. BEGIN
  206.   SetClip(VirtScreen,Rect);
  207.   VSFInterior(VirtScreen,FISPattern);
  208.   VSFStyle(VirtScreen,8);
  209.   VSFColor(VirtScreen,White);
  210.   GetWorkXYWH(MyWindow,Work);
  211.   GRectToArray(Work,Points);
  212.   VBar(VirtScreen,Points);
  213.  
  214.   XEll:= Work.GX;
  215.   YEll:= Work.GY;
  216.   VSFInterior(VirtScreen,FISPattern);
  217.   VSFStyle(VirtScreen,8);
  218.   VSFColor(VirtScreen,Blue);
  219.   VEllipse(VirtScreen,XEll + WEll DIV 2,
  220.                       YEll + HEll DIV 2,
  221.                       WEll DIV 2,
  222.                       HEll DIV 2);
  223. END DrawSample;
  224.  
  225. PROCEDURE DoRedraw(    Window: SIGNEDWORD;
  226.                    VAR Clip  : GRect);
  227. BEGIN
  228.   RedrawWindow(Window,Clip,DrawSample);
  229. END DoRedraw;
  230.  
  231. PROCEDURE DoSize(Window: SIGNEDWORD; VAR Rect: GRect);
  232. BEGIN
  233.   WITH Rect DO
  234.     IF GW < MinWidth THEN
  235.       GW:= MinWidth;
  236.     END;
  237.     IF GH < MinHeight THEN
  238.       GH:= MinHeight;
  239.     END;
  240.   END;
  241.   SetCurrXYWH(Window,Rect);
  242. END DoSize;
  243.  
  244. PROCEDURE DoFull(Window: SIGNEDWORD);
  245.  
  246. VAR Prev: GRect;
  247.     Curr: GRect;
  248.     Full: GRect;
  249.  
  250. BEGIN
  251.   GetFullXYWH(Window,Full);
  252.   GetCurrXYWH(Window,Curr);
  253.   GetPrevXYWH(Window,Prev);
  254.   IF RcEqual(Curr,Full) THEN
  255.     GrafShrinkBox(Prev,Full);
  256.     SetCurrXYWH(Window,Prev);
  257.   ELSE
  258.     GrafGrowBox(Curr,Full);
  259.     SetCurrXYWH(Window,Full);
  260.   END;
  261. END DoFull;
  262.  
  263. PROCEDURE DoClose(Window: SIGNEDWORD);
  264.  
  265. VAR MyMessage: MessageBlock;
  266.  
  267. BEGIN
  268.   WITH MyMessage DO
  269.     Type  := MnSelected;
  270.     Id    := ApplId;
  271.     Length:= 0;
  272.     Title := TFILE;
  273.     Item  := IQUIT;
  274.   END;
  275.   ApplWrite(ApplId,16,MyMessage);
  276. END DoClose;
  277.  
  278. PROCEDURE DoForm(Menu  : TreePtr;
  279.                  Title : ObjectIndex;
  280.                  TreeNo: TreeIndex;
  281.                  Start : ObjectIndex): ObjectIndex;
  282.  
  283. VAR Tree  : TreePtr;
  284.     From  : GRect;
  285.     To    : GRect;
  286.     Return: SIGNEDWORD;
  287.  
  288. BEGIN
  289.   BeginUpdate;
  290.   ObjectXYWH(Menu,Title,From);
  291.   Tree:= GetTreePtr(TreeNo);
  292.   FormCenter(Tree,To);
  293.   FormDial(FmDStart,To,To);
  294.   FormDial(FmDGrow,From,To);
  295.   ObjcDraw(Tree,Root,MaxDepth,To);
  296.   Return:= Mask(FormDo(Tree,Start));
  297.   FormCenter(Tree,To);
  298.   ObjcChange(Tree,Return,1,To,
  299.              GetObject.State(Tree,Return) - ObjectState{Selected},FALSE);
  300.   FormDial(FmDShrink,From,To);
  301.   FormDial(FmDFinish,To,To);
  302.   EndUpdate;
  303.   RETURN Return;
  304. END DoForm;
  305.  
  306. PROCEDURE DoInfo(Menu: TreePtr; Title: ObjectIndex);
  307. BEGIN
  308.   VOID(DoForm(Menu,Title,INFO,0));
  309. END DoInfo;
  310.  
  311. PROCEDURE DoEllipse(Menu: TreePtr; Title: ObjectIndex);
  312. BEGIN
  313.   VOID(DoForm(Menu,Title,ELLEDIT,0));
  314. END DoEllipse;
  315.  
  316. PROCEDURE DoRS232(Menu: TreePtr; Title: ObjectIndex);
  317. BEGIN
  318.   VOID(DoForm(Menu,Title,RS232,0));
  319. END DoRS232;
  320.  
  321. PROCEDURE DoFormat(Menu: TreePtr; Title: ObjectIndex);
  322. BEGIN
  323.   VOID(DoForm(Menu,Title,PGFORMAT,0));
  324. END DoFormat;
  325.  
  326. PROCEDURE ToggleHelp(Menu: TreePtr; Title: ObjectIndex);
  327. BEGIN
  328.   IF State15 IN GetObject.State(Menu,IHELP) THEN
  329.     HelpItem:= GetFreeStringPtr(HELPOFF);
  330.     EXCLObjectState(Menu,IHELP,State15);
  331.   ELSE
  332.     HelpItem:= GetFreeStringPtr(HELPON);
  333.     INCLObjectState(Menu,IHELP,State15);
  334.   END;
  335.   MenuText(Menu,IHELP,HelpItem^);
  336. END ToggleHelp;
  337.  
  338. PROCEDURE ToggleWarning(Menu: TreePtr; Title: ObjectIndex);
  339. BEGIN
  340.   MenuICheck(Menu,IWARNING,NOT(Checked IN GetObject.State(Menu,IWARNING)));
  341. END ToggleWarning;
  342.  
  343. PROCEDURE DoNothing(Menu: TreePtr; Title: ObjectIndex);
  344. BEGIN
  345. END DoNothing;
  346.  
  347. PROCEDURE DoMenu(Title: ObjectIndex; Item: ObjectIndex);
  348. BEGIN
  349.   ArrowMouse;
  350.   MenuAction(MyMenu,Title,Item);
  351.   MenuTNormal(MyMenu,Title,TRUE);
  352. END DoMenu;
  353.  
  354. PROCEDURE DeselectAll(Tree: TreePtr; Index: ObjectIndex): BOOLEAN;
  355. BEGIN
  356.   IF Selected IN GetObject.State(Tree,Index) THEN
  357.     EXCLObjectState(Tree,Index,Selected);
  358.     DrawDeskObject(Tree,Index);
  359.   END;
  360.   RETURN TRUE;
  361. END DeselectAll;
  362.  
  363. PROCEDURE DoClick(Clicks: UNSIGNEDWORD; Pos: GPnt);
  364.  
  365. VAR MyIcon        : ObjectPtr;
  366.     Index         : ObjectIndex;
  367.     Special       : SpecialKey;
  368.     PressedButtons: MouseButton;
  369.     Box           : GRect;
  370.     Rect          : GRect;
  371.  
  372.   PROCEDURE MoveObject(Tree: TreePtr; Ob: ObjectIndex);
  373.  
  374.   VAR DeskRect: GRect;
  375.       OldPos  : GPnt;
  376.       NewPos  : GPnt;
  377.  
  378.   BEGIN
  379.     ObjcOffset(Tree,Ob,OldPos.GX,OldPos.GY);
  380.     ObjectXYWH(Tree,Root,DeskRect);
  381.  
  382.     BeginUpdate;
  383.     BeginMouseControl;
  384.  
  385.     MouseForm(FlatHand);
  386.  
  387.     GrafDragBox(GetObject.Width(Tree,Ob),
  388.                 GetObject.Height(Tree,Ob),
  389.                 OldPos.GX,OldPos.GY,
  390.                 DeskRect,NewPos);
  391.  
  392.     LastMouse;
  393.  
  394.     EndMouseControl;
  395.     EndUpdate;
  396.  
  397.     IF WindFind(NewPos) = Desk THEN
  398.       INCLObjectFlags(Tree,Ob,HideTree);
  399.       DrawDeskObject(Tree,Ob);
  400.       SetObject.X(Tree,Ob,RcSnap(GetObject.X(Tree,Ob) + NewPos.GX - OldPos.GX,80));
  401.       SetObject.Y(Tree,Ob,RcSnap(GetObject.Y(Tree,Ob) + NewPos.GY - OldPos.GY,48));
  402.       EXCLObjectFlags(Tree,Ob,HideTree);
  403.       DrawDeskObject(Tree,Ob);
  404.     END;
  405.   END MoveObject;
  406.  
  407. BEGIN
  408.   BeginUpdate;
  409.   BeginMouseControl;
  410.   IF WindFind(Pos) = Desk THEN
  411.     MyIcon:= ObjcFind(MyDesk,Root,1,Pos);
  412.  
  413.     IF Clicks = 2 THEN
  414.       IF MyIcon >= DISKA THEN
  415.         INCLObjectState(MyDesk,MyIcon,Selected);
  416.         DrawDeskObject(MyDesk,MyIcon);
  417.         Alert(DOUBLECL);
  418.         EXCLObjectState(MyDesk,MyIcon,Selected);
  419.         DrawDeskObject(MyDesk,MyIcon);
  420.       END;
  421.     ELSIF Clicks = 1 THEN
  422.       GrafMKState(Pos,PressedButtons,Special);
  423.  
  424.       IF MBLeft IN PressedButtons THEN
  425.         TreeWalk(MyDesk,DISKA,Nil,DeselectAll);
  426.         IF MyIcon >= DISKA THEN
  427.           INCLObjectState(MyDesk,MyIcon,Selected);
  428.           DrawDeskObject(MyDesk,MyIcon);
  429.           MoveObject(MyDesk,MyIcon);
  430.         ELSE
  431.           RubberBox(Pos,Box);
  432.           FOR Index:= DISKA TO COLICON DO
  433.             ObjectXYWH(MyDesk,Index,Rect);
  434.             IF RcIntersect(Box,Rect) THEN
  435.               INCLObjectState(MyDesk,Index,Selected);
  436.               DrawDeskObject(MyDesk,Index);
  437.             END;
  438.           END;
  439.         END;
  440.       ELSE
  441.         IF MyIcon >= DISKA THEN
  442.           SetObject.State(MyDesk,MyIcon,GetObject.State(MyDesk,MyIcon) / ObjectState{Selected});
  443.           DrawDeskObject(MyDesk,MyIcon);
  444.         ELSE
  445.           TreeWalk(MyDesk,DISKA,Nil,DeselectAll);
  446.         END;
  447.       END;
  448.     END;
  449.   END;
  450.   EndMouseControl;
  451.   EndUpdate;
  452. END DoClick;
  453.  
  454. PROCEDURE EventLoop;
  455.  
  456. VAR EventBlock: MEvent;
  457.     MyEvent   : Event;
  458.     MyMessage : MessageBlock;
  459.     Clicks    : UNSIGNEDWORD;
  460.  
  461. BEGIN
  462.   WITH EventBlock DO
  463.     EFlags:= Event{MuMesag,MuKeybd,MuButton};
  464.     EMePBuf:= PTR(MyMessage);
  465.     EBClk:= 2;
  466.     EBMsk:= MouseButton{MBLeft};
  467.     EBSt:= MouseButton{MBLeft};
  468.  
  469.     WITH MyMessage DO
  470.       LOOP
  471.         MyEvent:= EvntEvent(EventBlock);
  472.  
  473.         IF MuMesag IN MyEvent THEN
  474.           CASE Type OF
  475.             WMRedraw:
  476.               DoRedraw(Handle,Rect);
  477.           | WMNewTop,WMTopped:
  478.               SetTop(Handle);
  479.           | WMSized:
  480.               DoSize(Handle,Rect);
  481.           | WMMoved:
  482.               SetCurrXYWH(Handle,Rect);
  483.           | WMFulled:
  484.               DoFull(Handle);
  485.           | WMClosed:
  486.               DoClose(Handle);
  487.           | MnSelected:
  488.               DoMenu(Title,Item);
  489.           ELSE
  490.             ;
  491.           END;
  492.         END;
  493.  
  494.         IF MuButton IN MyEvent THEN
  495.           DoClick(EBR,EMXY);
  496.         END;
  497.  
  498.         IF MuKeybd IN MyEvent THEN
  499.           IF NOT MenuKey(MyMenu,EKR,EKS) THEN
  500.             (* DoKey(EKR,EKS); *)
  501.           END;
  502.         END;
  503.  
  504.         IF (Type = MnSelected) AND (Item = IQUIT) THEN
  505.           IF OK(QUIT) THEN
  506.             EXIT;
  507.           ELSE
  508.             Type:= ApMsg;
  509.           END;
  510.         END;
  511.  
  512.       END;
  513.     END;
  514.   END;
  515. END EventLoop;
  516.  
  517. BEGIN
  518.   ApplId:= ApplInit();
  519.  
  520.   IF ApplId >= 0 THEN
  521.     BeginUpdate;
  522.     BusyMouse;
  523.  
  524.     IF RsrcLoad(RscName) THEN
  525.       IF OpenVirtualWorkstation(VirtScreen) THEN
  526.         MyMenu:= GetTreePtr(MENU);
  527.  
  528.         NewMenuAction(MyMenu,IINFO,DoInfo);
  529.         NewMenuAction(MyMenu,IHELP,ToggleHelp);
  530.         NewMenuAction(MyMenu,IELL,DoEllipse);
  531.         NewMenuAction(MyMenu,IRS232,DoRS232);
  532.         NewMenuAction(MyMenu,IFORMAT,DoFormat);
  533.         NewMenuAction(MyMenu,IWARNING,ToggleWarning);
  534.         NewMenuAction(MyMenu,IQUIT,DoNothing);
  535.  
  536.         VOID(MenuBar(MyMenu,1));
  537.  
  538.         MyDesk:= GetTreePtr(DESK);
  539.         OpenDesk(MyDesk,Root);
  540.  
  541.         VOID(GrafHandle(CharWidth,CharHeight,BoxWidth,BoxHeight));
  542.         MinWidth:= 2 * BoxWidth;
  543.         MinHeight:= 2 * BoxHeight;
  544.  
  545.         IF OpenWindow(MyWindow) THEN
  546.           ArrowMouse;
  547.           EndUpdate;
  548.  
  549.           GetWorkXYWH(MyWindow,Work);
  550.           WITH Work DO
  551.             XEll:= GX;
  552.             YEll:= GY;
  553.             WEll:= GW;
  554.             HEll:= GH;
  555.           END;
  556.  
  557.           EventLoop;
  558.  
  559.           CloseWindow(MyWindow);
  560.         ELSE
  561.           Alert(NOWIND);
  562.         END;
  563.  
  564.         CloseDesk;
  565.         VOID(MenuBar(MyMenu,0));
  566.         CloseVirtualWorkstation(VirtScreen);
  567.       ELSE
  568.         Alert(NOVWORK);
  569.       END;
  570.  
  571.       RsrcFree;
  572.     ELSE
  573.       EndUpdate;
  574.     END;
  575.     ApplExit;
  576.   END;
  577. END XSample.
  578.  
  579.