home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MENDOW21.ZIP / EXMENDOW.PAS next >
Encoding:
Pascal/Delphi Source File  |  1986-11-14  |  9.7 KB  |  226 lines

  1. { EXMENDOW.PAS - MENDOW21.INC Turbo Pascal Example                            }
  2. { This file will create a Menu And A Window                                   }
  3.  
  4. { include the MENDOWS.INC file }
  5. (*$IMENDOWS.INC *)
  6.  
  7. { Define the Menu/Window Variables }
  8.  
  9. VAR
  10.    ExMenu         : DrawRec;          { Menu Example Rec          }
  11.    ExMenuWindow   : WindowPtr;        { Menu Example Window Ptr   }
  12.    ExOptionChosen : INTEGER;          { Menu Option Var           }
  13.    ExWindow       : WindowPtr;        { Window Example Window Ptr }
  14.  
  15. { Anciallary Varible Definitions }
  16.    I            : INTEGER;            { General Counter  }
  17.    Exit_Code    : BOOLEAN;            { Exit System Flag }
  18.  
  19. { Example Procedure 1 - Create/Delete A Window }
  20. PROCEDURE ExMenuProc1;
  21.  
  22. VAR
  23.    Proc1Window : WindowPtr;                     { Window Var        }
  24.    Proc1Code   : BOOLEAN;                       { Window Error Code }
  25.  
  26. BEGIN
  27.    Proc1Code := Make_Window(30,14,60,19,'Procedure 1 Window',Proc1Window,TRUE);
  28.                                                         { TRUE - Clear Window }
  29.    GOTOXY(2,1);                                 { Goto top of window }
  30.    WRITELN('This is test window 1');
  31.    WRITELN('Hit Enter To Continue');
  32.    READLN;
  33.    DRestoreWindow(Proc1Window,0,0);             { Erase Window From Screen }
  34. END; { ExMenuProc1 }
  35.  
  36.  
  37.  
  38. { Example Procedure 2 - Create/Delete Multiple Windows }
  39. PROCEDURE ExMenuProc2;
  40.  
  41. VAR
  42.    Proc2WindowAr : ARRAY[1..3] OF WindowPtr;    { Array For Three Windows }
  43.    Proc2CodeAr   : ARRAY[1..3] OF BOOLEAN;      { Error Code For Windows  }
  44.    I             : INTEGER;                     { Counter Variable        }
  45.  
  46. BEGIN
  47.    FOR I := 1 TO 3 DO
  48.    BEGIN
  49.       Proc2CodeAr[I] := Make_Window(10*I,1+(3*I),40+(5*I),20+I,
  50.                                     'Test Window # '+CHR(48+I),Proc2windowAr[I],
  51.                                     TRUE);
  52.                                     { Create Windows at differing offsets }
  53.       GOTOXY(2,1);
  54.       WRITELN('This is window # ',I);           { Message In Window[I]    }
  55.    END;
  56.    WRITELN('Press Enter To Delete');
  57.    WRITELN('          Each Window');
  58.    FOR I := 3 DOWNTO 1 DO
  59.    BEGIN
  60.       READLN;
  61.       DRestoreWindow(Proc2WindowAr[I],0,0);      { Delete Window[I]       }
  62.    END;
  63. END; { ExMenuProc2 }
  64.  
  65.  
  66. { Example Procedure 3 - Create Non-Erasing Menu }
  67. PROCEDURE ExMenuProc3;
  68.  
  69. VAR
  70.    ExProc3Menu   : DrawRec;                     { Menu Rec For Proc 3     }
  71.    ExProc3Window : WindowPtr;                   { Window For Proc 3 Menu  }
  72.    ExProc3Option : INTEGER;                     { Option Chosen From Menu }
  73.  
  74. BEGIN
  75. { Define Proc3 Menu Rec }
  76.    WITH ExProc3Menu DO
  77.    BEGIN
  78.       Count := 3;                               { Number Proc3 Menu Options }
  79.       Default := 1;                             { Default Proc3 Menu Option }
  80.       Title := 'Non Erasing Menu';              { Proc3 Menu Title          }
  81.  
  82.       WITH DrawRecAr[1] DO                      { First Menu Item           }
  83.       BEGIN
  84.          Col     := 17;                         { Top Left Column           }
  85.          Row     := 7;                          { Top Left Row              }
  86.          DrawDat := 'Option 1';                 { 1st Menu Option           }
  87.       END; { WITH DrawRecAr[1] }
  88.  
  89.       WITH DrawRecAr[2] DO                      { Second Menu Item          }
  90.       BEGIN
  91.          Col     := 66;                         { Bottom Right Column       }
  92.          Row     := 11;                         { Bottom Right Row          }
  93.          DrawDat := 'Option 2';                 { 2nd Menu Option           }
  94.       END; { WITH DrawRecAr[2] }
  95.  
  96.       DrawRecAr[3].DrawDat := 'Option 3';       { 3rd Menu Option           }
  97.    END; { WITH ExProc3Menu }
  98.  
  99.    ExProc3Option := Make_Menu(ExProc3Menu,ExProc3Window,FALSE);
  100.                                                        { FALSE - Don't erase }
  101.                                                        { menu on exit from   }
  102.                                                        { Make_Menu           }
  103.    GOTOXY(20,1);
  104.    WRITE('If Menu Is Not Erased,');                    {                     }
  105.    GOTOXY(20,2);                                       {  In Window Message  }
  106.    WRITE('The Window Remains Active.');                {        and          }
  107.    GOTOXY(20,3);                                       {       Pause         }
  108.    WRITE('Hit <ENTER> To Continue');                   {                     }
  109.    READLN;                                             {                     }
  110.    DRestoreWindow(ExProc3Window,0,0);                  { Restore Old Window  }
  111. END; { ExMenuProc3 }
  112.  
  113.  
  114. { Example Procedure 4 - Create Full Screen Window }
  115.  
  116. PROCEDURE ExMenuProc4;
  117.  
  118. VAR
  119.    ExProc4Window : WindowPtr;
  120.    I             : INTEGER;
  121.    Proc4Code     : BOOLEAN;
  122.  
  123. BEGIN
  124.    Proc4Code := Make_Window(1,1,80,25,'Big Window',ExProc4Window,TRUE);
  125.                                                 { Create Full Screen Window }
  126.                                                 { TRUE - Clear Window       }
  127.  
  128.    GOTOXY(1,1);                                           {                 }
  129.    WRITELN('The Entire Screen Can Be Used As A Window');  {  Full Screem    }
  130.    WRITELN('Hit <ENTER> To Continue');                    {     Draw        }
  131.    READLN;                                                {    Replete      }
  132.    FOR I := 1 TO 1000 DO                                  {     With        }
  133.       WRITE('*');                                         {    Pauses       }
  134.    WRITELN;                                               {                 }
  135.    WRITELN('Hit <ENTER> To Continue');                    {                 }
  136.    READLN;                                                {                 }
  137.    DRestoreWindow(ExProc4Window,0,0);                 { Restore Full Screen }
  138. END; { ExMenuProc4 }
  139.  
  140.  
  141. { Example Procedure 5 - Create Full Screen Window w/out Clearing }
  142.  
  143. PROCEDURE ExMenuProc5;
  144.  
  145. VAR
  146.    ExProc5Window : WindowPtr;
  147.    I             : INTEGER;
  148.    Proc5Code     : BOOLEAN;
  149.  
  150. BEGIN
  151.    Proc5Code := Make_Window(1,1,80,25,'Big Non-Cleared Window',
  152.                             ExProc5Window,FALSE);
  153.                                                 { Create Full Screen Window }
  154.                                                 { FALSE - Don't Clear Screen }
  155.                                                 { within new window          }
  156.  
  157.    GOTOXY(1,1);                                           {                 }
  158.    WRITELN('The Entire Screen Can Be Used As A Window');  {  Full Screem    }
  159.    WRITELN('Hit <ENTER> To Continue');                    {     Draw        }
  160.    READLN;                                                {    Replete      }
  161.    FOR I := 1 TO 1000 DO                                  {                 }
  162.       CASE (I MOD 2) OF                                   {                 }
  163.          0 : WRITE('@');                                  {     With        }
  164.          1 : WRITE('*');                                  {                 }
  165.       END; { CASE I MOD 2 }                               {                 }
  166.    WRITELN;                                               {                 }
  167.    WRITELN('Hit <ENTER> To Continue');                    {                 }
  168.    READLN;                                                {                 }
  169.    DRestoreWindow(ExProc5Window,0,0);                 { Restore Full Screen }
  170. END; { ExMenuProc5 }
  171.  
  172.  
  173.  
  174.  
  175. { Actual Menu/Window Examples }
  176. BEGIN
  177.    DetermineDisplay;        { Checks for C-G or Mono Monitor }
  178.  
  179. { Fill Screen with '@'s For Menu Example }
  180.    GOTOXY(1,1);             { Send Cursor to Top Of Screen   }
  181.    FOR I:= 1 TO 1919 DO     { Fill Char Screen with '@'      }
  182.       WRITE('@');
  183.  
  184. { Define Menu Record }
  185.    WITH ExMenu DO
  186.    BEGIN
  187.       Count   := 5;                            { Number of Menu Items }
  188.       Default := 3;                            { Default Menu Option  }
  189.       Title   := 'Example Menu';               { Menu Title           }
  190.  
  191.       With DrawRecAr[1] DO                     { First Menu Item      }
  192.       BEGIN
  193.          Col := 20;                            { Top Left Column      }
  194.          Row := 3;                             { Top Left Row         }
  195.          DrawDat := 'Single Window Example';   { 1st Menu Option      }
  196.       END; { WITH DrawRecAr[1] }
  197.  
  198.  
  199.       With DrawRecAr[2] DO                     { Second Menu Item     }
  200.       BEGIN
  201.          Col := 60;                            { Bottom Right Column  }
  202.          Row := 9;                             { Bottom Right Row     }
  203.          DrawDat := 'Multi Window Example';    { 2st Menu Option      }
  204.       END; { WITH DrawRecAr[2] }
  205.  
  206.       DrawRecAr[3].DrawDat := 'Non-Erase Menu Example';   { 3rd Menu Option }
  207.       DrawRecAr[4].DrawDat := 'Full Scr Window Example';  { 4th Menu Option }
  208.       DrawRecAr[5].DrawDat := 'Uncleared Window Example'; { 5th Menu Option }
  209.    END; { WITH ExMenu }
  210.  
  211. { Call Menu Cration/Option Routine }
  212.    Exit_Code := FALSE;                         { No Exit Yet }
  213.    REPEAT
  214.       ExOptionChosen := Make_Menu(ExMenu,ExMenuWindow,TRUE); { TRUE - erase }
  215.                                                           { menu on exit }
  216.       CASE ExOptionChosen OF
  217.          0 : Exit_Code := TRUE;             { ESC Pressed from Menu      }
  218.          1 : ExMenuProc1;                   { Make_Window Example        }
  219.          2 : ExMenuProc2;                   { Make Multiple Window Examp }
  220.          3 : ExMenuProc3;                   { Make Non-Erase Menu Examp  }
  221.          4 : ExMenuProc4;                   { Full Screen Window Example }
  222.          5 : ExMenuProc5;                   { Non Erase Window Example   }
  223.       END; { CASE ExOptionChosen }
  224.    UNTIL Exit_Code = TRUE;
  225. END.
  226.