home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / oop.swg / 0017_STATUDLG.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  4KB  |  158 lines

  1.  Program StatusDialogDemo;
  2.  
  3.  Uses
  4.    Crt,Objects,Drivers,Views,Dialogs,App;
  5.  
  6.  Type
  7.    PDemo = ^TDemo;
  8.    TDemo = Object (TApplication)
  9.      Constructor Init;
  10.      end;
  11.  
  12.    PStatusDialog = ^TStatusDialog;
  13.    TStatusDialog = Object (TDialog)
  14.      Message,Value: PStaticText;
  15.      Constructor Init;
  16.      Procedure Update (Status: Word; AValue: Word); Virtual;
  17.      end;
  18.  
  19.  Constructor TDemo.Init;
  20.  
  21.  Var
  22.    D: PStatusDialog;
  23.    I: Integer;
  24.    E: TEvent;
  25.  
  26.  begin
  27.  TApplication.Init;
  28.  D := New (PStatusDialog,Init);
  29.  Desktop^.Insert (D);
  30.  For I := 1 to 10 do
  31.    begin
  32.    D^.Update (cmValid,I * 10);
  33.    if CtrlBreakHit then
  34.      begin
  35.      CtrlBreakHit := False;
  36.      GetEvent (E);  { eat the Ctrl-Break }
  37.      D^.Update (cmCancel,I * 10);
  38.      Repeat GetEvent (E) Until (E.What = evKeyDown)
  39.        or (E.What = evMouseDown);
  40.      Desktop^.Delete (D);
  41.      Dispose (D,Done);
  42.      Exit;
  43.      end;
  44.    Delay (1000);  { simulate processing }
  45.    end;
  46.  D^.Update (cmOK,100);
  47.  Repeat GetEvent (E) Until (E.What = evKeyDown)
  48.    or (E.What = evMouseDown);
  49.  Desktop^.Delete (D);
  50.  Dispose (D,Done);
  51.  end;
  52.  
  53.  Constructor TStatusDialog.Init;
  54.  
  55.  Var
  56.    R: TRect;
  57.  
  58.  begin
  59.  R.Assign (20,6,60,12);
  60.  TDialog.Init(R,'Processing...');
  61.  Flags := Flags and not wfClose;
  62.  R.Assign (10,2,30,3);
  63.  Insert (New (PStaticText,Init (R,'Completed Record xxx')));
  64.  R.Assign (27,2,30,3);
  65.  Value := New (PStaticText,Init (R,'  0'));
  66.  Insert (Value);
  67.  R.Assign (2,4,38,5);
  68.  Message := New (PStaticText,Init (R,
  69.    '     Press Ctrl-Break to cancel     '));
  70.  Insert (Message);
  71.  end;
  72.  
  73.  Procedure TStatusDialog.Update (Status: Word; AValue: Word);
  74.  
  75.  Var
  76.    ValStr: String[3];
  77.  
  78.  begin
  79.  Case Status of
  80.    cmCancel: begin
  81.      DisposeStr (Message^.Text);
  82.      Message^.Text := NewStr ('     Cancelled - press any key      ');
  83.      Message^.DrawView;
  84.      end;
  85.    cmOK: begin
  86.      DisposeStr (Message^.Text);
  87.      Message^.Text := NewStr ('     Completed - press any key      ');
  88.      Message^.DrawView;
  89.      end;
  90.    end;
  91.  Str (AValue:3,ValStr);
  92.  DisposeStr (Value^.Text);
  93.  Value^.Text := NewStr (ValStr);
  94.  Value^.DrawView;
  95.  end;
  96.  
  97.  Var
  98.    Demo: TDemo;
  99.  
  100.  begin
  101.  Demo.Init;
  102.  Demo.Run;
  103.  Demo.Done;
  104.  end.
  105.  
  106.  {
  107. GH>        Can someone explain how exactly to display a
  108. GH>parameterized Text field into a dialog Window?  This is what I
  109.  
  110. Here is a dialog that I hope does what you want.  It comes from Shazam,
  111. a TV dialog editor and code generator.  Also a great learning tool.
  112. YOu can get it as SZ2.zip from Compuserve or from Jonathan Stein
  113. directly at PO Box 346, Perrysburg OH 43552 fax 419-874-4922.
  114.  
  115.  Function MakeDialog : PDialog ; Var Dlg                       :
  116.    PDialog ; R                         : TRect ; Control , Labl , Histry
  117.    : PView ; begin R.Assign ( 0 , 10 , 37 , 23 ) ; New ( Dlg , Init ( R
  118.    , 'About #2' ) ) ;
  119.  
  120.    R.Assign ( 10 , 2 , 26 , 3 ) ;
  121.    Control                   := New ( PStaticText , Init ( R ,
  122.    'A Sample Program' ) ) ;
  123.    Dlg^.Insert ( Control ) ;
  124.  
  125.    R.Assign ( 13 , 4 , 20 , 5 ) ;
  126.    Control                   := New ( PStaticText , Init ( R ,
  127.    'Version' ) ) ;
  128.    Dlg^.Insert ( Control ) ;
  129.  
  130.    R.Assign ( 21 , 4 , 28 , 5 ) ;
  131.    Control := New ( PParamText , Init ( R , '%-s    ' , 1 ) )
  132.    Dlg^.Insert ( Control ) ;
  133.  
  134.    R.Assign ( 8 , 6 , 29 , 7 ) ;
  135.    Control                   := New ( PStaticText , Init ( R ,
  136.    '(C) Copyright 19xx by' ) ) ;
  137.    Dlg^.Insert ( Control ) ;
  138.  
  139.    R.Assign ( 8 , 8 , 29 , 9 ) ;
  140.    Control                   := New ( PStaticText , Init ( R ,
  141.    'Anybody, Incorporated' ) ) ;
  142.    Dlg^.Insert ( Control ) ;
  143.  
  144.    R.Assign ( 14 , 10 , 24 , 12 ) ;
  145.    Control := New ( PButton , Init ( R , ' O~K~ ' , cmOK , bfDefault));
  146.    Control^.HelpCtx          := hcAbout2 ;
  147.    Dlg^.Insert ( Control ) ;
  148.  
  149.    Dlg^.SelectNext ( False ) ;
  150.    MakeDialog                   := Dlg ;
  151. end ;
  152.  
  153. Var
  154.    DataRec                   : Record
  155.    ParamField1               : PString ; { ParamText }
  156.                                end ;
  157.  
  158.   }