home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-pascal / macintoshp-1.2-demos.sit.hqx / chap23pascal_demo / chap05pascal_demoPPC / Controls2PascalPPC.p < prev    next >
Text File  |  1997-01-07  |  13KB  |  550 lines

  1. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  2. // Controls2PascalPPC.p
  3. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  4. // 
  5. // This program:
  6. //
  7. // •    Opens a noGrowDocProc window with a horizontal scrollbar.
  8. //
  9. // •    Allows the user to horizontally scroll a picture within the window using the
  10. //        scroll box, the scroll arrows and the gray area.
  11. //
  12. // The program utilises the following resources:
  13. //
  14. // •    An 'MBAR' resource, and 'MENU' resources for Apple, File and Edit (preload, 
  15. //        non-purgeable).  
  16. //
  17. // •    A 'WIND' resource (purgeable) (initially visible).  
  18. //
  19. // •    An 'CNTL' resource for the horizontal scroll bar (purgeable).  
  20. //
  21. // •    A 'PICT' resource containing the picture to be scrolled (non-purgeable).  
  22. //
  23. // •    A 'SIZE' resource with the acceptSuspendResumeEvents and 
  24. //        doesActivateOnFGSwitch flags set.      
  25. //
  26. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
  27.  
  28. program Controls2Pascal(input, output);
  29.  
  30. { ………………………………………………………………………………………………………………… include the following Universal Interfaces }
  31.  
  32. uses
  33.  
  34.     Windows, Fonts, Quickdraw, Events, Types, Memory, Processes, Controls, Menus, 
  35.     TextEdit, Dialogs, ToolUtils, OSUtils, Devices, Segload;
  36.  
  37. { ………………………………………………………………………………………………………………………………………………… define the following constants }
  38.  
  39. const
  40.  
  41. rMenubar = 128;
  42. rNewWindow = 128;
  43. rPicture = 128;
  44.  
  45. mApple = 128;
  46.      iAbout = 1;
  47. mFile = 129;
  48.      iQuit = 11;
  49. mEdit = 130;
  50.  
  51. cHScrollbar = 128;
  52.  
  53. kMaxLong = $7FFFFFFF;
  54.  
  55. { ………………………………………………………………………………………………………………………………………………………………………………… user-defined types }
  56.  
  57. type
  58.  
  59. DocRec = record
  60.     hScrollbarHdl : ControlHandle;
  61.     end;
  62.     
  63. DocRecHandle = ^^DocRec;
  64.  
  65. { ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
  66.  
  67. var
  68.  
  69. gDone : boolean;
  70. gInBackground : boolean;
  71. gPictRect : Rect;
  72. gPictureHdl : PicHandle;
  73. menubarHdl : Handle;
  74. menuHdl : MenuHandle;
  75. myWindowPtr : WindowPtr;
  76. docRecHdl : DocRecHandle;
  77. eventRec : EventRecord;
  78.  
  79. actionProcedureRD : ControlActionUPP;                                      { For PowerPC }
  80.  
  81. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoInitManagers }
  82.  
  83. procedure DoInitManagers;
  84.  
  85.     begin
  86.     MaxApplZone;
  87.     MoreMasters;
  88.  
  89.     InitGraf(@qd.thePort);
  90.     InitFonts;
  91.     InitWindows;
  92.     InitMenus;
  93.     TEInit;
  94.     InitDialogs(nil);
  95.  
  96.     InitCursor;    
  97.     FlushEvents(everyEvent, 0);
  98.     end;
  99.         {of procedure DoInitManagers}
  100.  
  101. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoMoveScrollBox }
  102.  
  103. procedure DoMoveScrollBox(controlHdl : ControlHandle; scrollDistance : integer);
  104.  
  105.     var
  106.     oldControlValue, controlValue, controlMax : integer;
  107.  
  108.     begin
  109.     oldControlValue := GetControlValue(controlHdl);
  110.     controlMax := GetControlMaximum(controlHdl);
  111.  
  112.     controlValue := oldControlValue - scrollDistance;
  113.     
  114.     if (controlValue < 0)
  115.         then    controlValue := 0
  116.         else     if (controlValue > controlMax)
  117.                     then controlValue := controlMax;
  118.  
  119.     SetControlValue(controlHdl, controlValue);
  120.     end;
  121.         {of procedure DoMoveScrollBox}
  122.  
  123. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ ActionProcedure }
  124.  
  125. procedure ActionProcedure(controlHdl : ControlHandle; partCode : ControlPartCode);
  126.  
  127.     var
  128.     myWindowPtr : WindowPtr;
  129.     docRecHdl : DocRecHandle;
  130.     scrollDistance : integer;
  131.     controlValue : integer;
  132.     updateRegion : RgnHandle;
  133.  
  134.     begin
  135.     if (partCode > 0) then
  136.         begin
  137.         myWindowPtr := controlHdl^^.contrlOwner;
  138.         docRecHdl := DocRecHandle(GetWRefCon(myWindowPtr));
  139.  
  140.         case (partCode) of
  141.  
  142.             kControlUpButtonPart, kControlDownButtonPart:
  143.                 begin
  144.                 scrollDistance := 2;
  145.                 end;
  146.  
  147.             kControlPageUpPart, kControlPageDownPart:
  148.                 begin
  149.                 scrollDistance := (myWindowPtr^.portRect.right 
  150.                                                     - myWindowPtr^.portRect.left) - 10;
  151.                 end;
  152.             end;
  153.                 {of case statement}
  154.  
  155.         if ((partCode = kControlDownButtonPart) or (partCode = kControlPageDownPart))
  156.             then scrollDistance := -scrollDistance;
  157.  
  158.         controlValue := GetControlValue(controlHdl);
  159.         if (((controlValue = GetControlMaximum(controlHdl)) and (scrollDistance < 0)) or 
  160.              ((controlValue = GetControlMinimum(controlHdl)) and (scrollDistance > 0)))
  161.                  then Exit(ActionProcedure);
  162.  
  163.         DoMoveScrollBox(controlHdl, scrollDistance);
  164.  
  165.         updateRegion := NewRgn;
  166.         ScrollRect(gPictRect, scrollDistance, 0, updateRegion);
  167.         InvalRgn(updateRegion);
  168.         DisposeRgn(updateRegion);
  169.  
  170.         if((scrollDistance = 2) or (scrollDistance = -2)) then 
  171.             BeginUpdate(myWindowPtr);
  172.  
  173.         SetOrigin(GetControlValue(docRecHdl^^.hScrollbarHdl), 0);
  174.         DrawPicture(gPictureHdl, gPictRect);
  175.         SetOrigin(0, 0);
  176.  
  177.         if((scrollDistance = 2) or (scrollDistance = -2)) then 
  178.             EndUpdate(myWindowPtr);
  179.         end;
  180.     end;
  181.         {of procedure ActionProcedure}
  182.  
  183. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoScrollBars }
  184.  
  185. procedure DoScrollBars(partCode : ControlPartCode; myWindowPtr : WindowPtr;
  186.                         controlHdl : ControlHandle; mouseXY : Point);
  187.  
  188.     var
  189.     docRecHdl : DocRecHandle;
  190.     oldControlValue : integer;
  191.     scrollDistance : integer;
  192.     updateRegion : RgnHandle;
  193.     ignored : integer;
  194.  
  195.     begin
  196.     docRecHdl := DocRecHandle(GetWRefCon(myWindowPtr));
  197.  
  198.  
  199.     case (partCode) of
  200.  
  201.         kControlIndicatorPart:
  202.             begin
  203.             oldControlValue := GetControlValue(controlHdl);
  204.             if (TrackControl(controlHdl, mouseXY, nil) > 0) then
  205.                 begin
  206.                 scrollDistance := oldControlValue - GetControlValue(controlHdl);
  207.                 if (scrollDistance <> 0) then
  208.                     begin
  209.                     if (controlHdl = docRecHdl^^.hScrollbarHdl)
  210.                         then    begin
  211.                                 updateRegion := NewRgn;
  212.                                 ScrollRect(gPictRect, scrollDistance, 0, updateRegion);
  213.                                 InvalRgn(updateRegion);
  214.                                 DisposeRgn(updateRegion);
  215.                                 end
  216.  
  217.                         else    begin
  218.                                 {Vertical scroll bar scroll box handling here.}
  219.                                 end;
  220.                     end;
  221.                 end;
  222.             end;
  223.  
  224.         kControlUpButtonPart, kControlDownButtonPart, kControlPageUpPart, 
  225.                 kControlPageDownPart:
  226.                 
  227.             begin
  228.             if (controlHdl = docRecHdl^^.hScrollbarHdl)
  229.                 then ignored := TrackControl(controlHdl, mouseXY, actionProcedureRD)   { PowerPC }
  230.                 else    begin
  231.                        {Vertical scroll via horizontal scrolling action procedure here.}
  232.                         end;
  233.             end;
  234.         
  235.         end;
  236.             {of case statement}
  237.  
  238.     end;
  239.         {of procedure DoScrollBars}
  240.         
  241. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoIncontent }
  242.  
  243. procedure  DoInContent(eventRec : EventRecord; myWindowPtr : WindowPtr);
  244.  
  245.     var
  246.     mouseXY : Point;
  247.     partCode : ControlPartCode;
  248.     controlHdl : ControlHandle;
  249.  
  250.     begin
  251.     partCode := 0;
  252.     mouseXY := eventRec.where;
  253.     GlobalToLocal(mouseXY);
  254.     
  255.     partCode := FindControl(mouseXY, myWindowPtr, controlHdl);
  256.     if (partCode <> 0) then
  257.         DoScrollBars(partCode, myWindowPtr, controlHdl, mouseXY);
  258.     end;
  259.         {of procedure DoInContent}
  260.  
  261. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoUpdate }
  262.  
  263. procedure  DoUpdate(eventRec : EventRecord);
  264.  
  265.     var
  266.     myWindowPtr : WindowPtr;
  267.     docRecHdl : DocRecHandle;
  268.  
  269.     begin
  270.     myWindowPtr := WindowPtr(eventRec.message);
  271.     docRecHdl := DocRecHandle(GetWRefCon(myWindowPtr));
  272.  
  273.     BeginUpdate(myWindowPtr);
  274.  
  275.     if not (EmptyRgn(myWindowPtr^.visRgn)) then
  276.         begin
  277.         SetPort(myWindowPtr);
  278.         UpdateControls(myWindowPtr, myWindowPtr^.visRgn);
  279.  
  280.         SetOrigin(GetControlValue(docRecHdl^^.hScrollbarHdl),0);
  281.         DrawPicture(gPictureHdl, gPictRect);
  282.         SetOrigin(0, 0);
  283.         end;
  284.  
  285.     EndUpdate(myWindowPtr);
  286.     end;
  287.         {of procedure DoUpdate}
  288.  
  289. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoActivateWindow }
  290.  
  291. procedure DoActivateWindow(myWindowPtr : WindowPtr; becomingActive : boolean);
  292.  
  293.     var
  294.     docRecHdl : DocRecHandle;
  295.  
  296.     begin
  297.     docRecHdl := DocRecHandle(GetWRefCon(myWindowPtr));
  298.  
  299.     if (becomingActive)
  300.         then    HiliteControl(docRecHdl^^.hScrollbarHdl, 0)
  301.         else    HiliteControl(docRecHdl^^.hScrollbarHdl, 255);
  302.         
  303.     end;
  304.         {of procedure DoActivateWindow}
  305.  
  306. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoActivate }
  307.  
  308. procedure DoActivate(eventRec : EventRecord);
  309.  
  310.     var
  311.     myWindowPtr : WindowPtr;
  312.     becomingActive : boolean;
  313.  
  314.     begin
  315.     myWindowPtr := WindowPtr(eventRec.message);
  316.  
  317.     becomingActive := (BAnd(eventRec.modifiers, activeFlag) <> 0);
  318.  
  319.     DoActivateWindow(myWindowPtr, becomingActive);
  320.     end;
  321.         {of procedure DoActivate}
  322.  
  323. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoOSEvent }
  324.  
  325. procedure DoOSEvent(eventRec : EventRecord);
  326.  
  327.     begin
  328.     case BAnd(BSR(eventRec.message, 24), $000000FF) of
  329.  
  330.         suspendResumeMessage:
  331.             begin
  332.             gInBackground := boolean(BAnd(eventRec.message, resumeFlag));
  333.             DoActivateWindow(FrontWindow, gInBackground);
  334.             end;
  335.                 
  336.         mouseMovedMessage:
  337.             begin
  338.             end;
  339.         
  340.         end;
  341.             {of case statement}
  342.     end;
  343.         {of procedure DoOSEvent}
  344.  
  345. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoMenuChoice }
  346.  
  347. procedure DoMenuChoice(menuChoice : longint);
  348.  
  349.     var
  350.     menuID, menuItem : integer;
  351.     itemName : string;
  352.     daDriverRefNum : integer;
  353.     
  354.     begin
  355.     menuID := HiWord(menuChoice);
  356.     menuItem := LoWord(menuChoice);
  357.  
  358.     if (menuID = 0) then
  359.         Exit(DoMenuChoice);
  360.  
  361.     case (menuID) of
  362.  
  363.         mApple:
  364.             begin
  365.             if (menuItem = iAbout) 
  366.                 then     SysBeep(10)
  367.                 else    begin
  368.                         GetMenuItemText(GetMenuHandle(mApple), menuItem, itemName);
  369.                         daDriverRefNum := OpenDeskAcc(itemName);
  370.                         end;
  371.             end;
  372.  
  373.         mFile:
  374.             begin
  375.             if (menuItem = iQuit) then
  376.                 gDone := true;
  377.             end;
  378.         
  379.         end;
  380.             {of case statement}
  381.  
  382.     HiliteMenu(0);
  383.     end;
  384.         {of procedure DoMenuChoice}
  385.  
  386. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoMouseDown }
  387.  
  388. procedure DoMouseDown(eventRec : EventRecord);
  389.  
  390.     var
  391.     myWindowPtr : WindowPtr;
  392.     partCode : integer;
  393.     
  394.     begin
  395.     partCode := FindWindow(eventRec.where, myWindowPtr);
  396.     
  397.     case (partCode) of
  398.  
  399.         inMenuBar:
  400.             begin
  401.             DoMenuChoice(MenuSelect(eventRec.where));
  402.             end;
  403.  
  404.         inSysWindow:
  405.             begin
  406.             SystemClick(eventRec, myWindowPtr);
  407.             end;
  408.  
  409.         inContent:
  410.             begin
  411.             if(myWindowPtr <> FrontWindow)
  412.                 then    SelectWindow(myWindowPtr)
  413.                 else    DoInContent(eventRec, myWindowPtr);
  414.             end;
  415.  
  416.         inDrag:
  417.             begin
  418.             DragWindow(myWindowPtr, eventRec.where, qd.screenBits.bounds);
  419.             end;
  420.  
  421.         inGoAway:
  422.             begin
  423.             if (TrackGoAway(myWindowPtr,eventRec.where)) then
  424.                 gDone := true;
  425.             end;
  426.  
  427.         end;
  428.             {of case statement}
  429.     end;
  430.         {of procedure DoMouseDown}
  431.             
  432. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoEvents }
  433.  
  434. procedure DoEvents(eventRec : EventRecord);
  435.  
  436.     begin
  437.     case (eventRec.what) of
  438.         mouseDown:
  439.             begin
  440.             DoMouseDown(eventRec);
  441.             end;
  442.  
  443.         updateEvt:
  444.             begin
  445.             DoUpdate(eventRec);
  446.             end;
  447.  
  448.         activateEvt:
  449.             begin
  450.             DoActivate(eventRec);
  451.             end;
  452.  
  453.         osEvt:
  454.             begin
  455.             DoOSEvent(eventRec);
  456.             HiliteMenu(0);
  457.             end;
  458.         end;
  459.             {of case statement}
  460.     end;
  461.         {of procedure DoEvents}
  462.  
  463.  
  464. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoGetControl }
  465.  
  466. procedure DoGetControl(myWindowPtr : WindowPtr);
  467.  
  468.     var
  469.     docRecHdl : DocRecHandle;
  470.     
  471.     begin
  472.     docRecHdl := DocRecHandle(GetWRefCon(myWindowPtr));
  473.  
  474.     docRecHdl^^.hScrollbarHdl := GetNewControl(cHScrollbar, myWindowPtr);
  475.     end;
  476.         {of procedure DoGetControl}
  477.  
  478. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoGetPicture }
  479.  
  480. procedure  DoGetPicture;
  481.  
  482.     begin
  483.     gPictureHdl := GetPicture(rPicture);
  484.  
  485.     gPictRect := gPictureHdl^^.picFrame;
  486.     gPictRect.right :=  gPictRect.right - gPictRect.left;
  487.     gPictRect.left := 0;
  488.     gPictRect.bottom := gPictRect.bottom - gPictRect.top;
  489.     gPictRect.top := 0;
  490.     end;
  491.         {of procedure DoGetPicture}
  492.  
  493. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ start of main program }
  494.  
  495. begin
  496.  
  497.     { …………………………………………………………………………………………………………………………………………………………………… initialize managers }
  498.  
  499.     DoInitManagers;
  500.  
  501.     { …………………………………………………………………………………………………………………………………………………… create routine descriptor }
  502.     
  503.     actionProcedureRD := NewControlActionProc(ProcPtr(@ActionProcedure));  { For PowerPC }
  504.  
  505.     { …………………………………………………………………………………………………………………………………………………… set up menu bar and menus }
  506.     
  507.     menubarHdl := GetNewMBar(rMenubar);
  508.     if (menubarHdl = nil) then
  509.         ExitToShell;
  510.     SetMenuBar(menubarHdl);
  511.     DrawMenuBar;
  512.  
  513.     menuHdl := GetMenuHandle(mApple);
  514.     if (menuHdl = nil)
  515.         then    ExitToShell
  516.         else    AppendResMenu(menuHdl,'DRVR');
  517.  
  518.     { …………………………………………………………………………………………………………………………………………………………………………………… open a window }
  519.  
  520.     myWindowPtr := GetNewWindow(rNewWindow, nil, WindowPtr(-1));
  521.     if (myWindowPtr = nil) then
  522.         ExitToShell;
  523.  
  524.     SetPort(myWindowPtr);
  525.  
  526.     { ………………… get block for document record, assign handle to window record refCon field }
  527.  
  528.     docRecHdl := DocRecHandle(NewHandle(sizeof(DocRec)));
  529.     SetWRefCon(myWindowPtr, longint(docRecHdl));
  530.  
  531.     { ……………………………………………………………………………………………………………………………………………………………………………………… get controls }
  532.  
  533.     DoGetControl(myWindowPtr);
  534.  
  535.     { ………………………………………………………………………………………………………………………………………………………………………………………… get picture }
  536.  
  537.     DoGetPicture;
  538.  
  539.     { ……………………………………………………………………………………………………………………………………………………………………………… enter eventLoop }
  540.  
  541.     gDone := false;
  542.  
  543.     while not (gDone) do
  544.         if (WaitNextEvent(everyEvent, eventRec, kMaxLong, nil)) then
  545.             DoEvents(eventRec);
  546.  
  547.  
  548. end.
  549.     
  550. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }