home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 11.ddi / OWLDEMOS.ZIP / SCROLAPP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  1.9 KB  |  66 lines

  1. {************************************************}
  2. {                                                }
  3. {   Demo program                                 }
  4. {   Copyright (c) 1991 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program Scroll;
  9.  
  10. uses WinTypes, WinProcs, Strings, OWindows;
  11.  
  12. type
  13.  
  14.   { Declare TScrollApp, a TApplication descendant }
  15.   TScrollApp = object(TApplication)
  16.     procedure InitMainWindow; virtual;
  17.   end;
  18.  
  19.   { Declare TScrollWindow, a TWindow descendant }
  20.   PScrollWindow = ^TScrollWindow;
  21.   TScrollWindow = object(TWindow)
  22.     constructor Init(ATitle: PChar);
  23.     procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct); virtual;
  24.   end;
  25.  
  26. { Construct the TScrollApp's MainWindow of type TScrollWindow }
  27. procedure TScrollApp.InitMainWindow;
  28. begin
  29.   MainWindow := New(PScrollWindow, Init('Boxes'));
  30. end;
  31.  
  32. { Constructor for a TScrollWindow, sets scroll styles and constructs
  33.   the Scroller object. }
  34. constructor TScrollWindow.Init(ATitle: PChar);
  35. begin
  36.   TWindow.Init(nil, ATitle);
  37.   Attr.Style := Attr.Style or ws_VScroll or ws_HScroll;
  38.   Scroller := New(PScroller, Init(@Self, 8, 15, 80, 60));
  39. end;
  40.  
  41. { Responds to an incoming "paint" message by redrawing boxes.  Note
  42.   that the Scroller's BeginView method, which sets the viewport origin
  43.   relative to the present scroll position, has already been called. }
  44. procedure TScrollWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
  45. var
  46.   X1, Y1, I: Integer;
  47. begin 
  48.   for I := 0 to 49 do
  49.   begin
  50.     X1 := 10 + I * 8;
  51.     Y1 := 30 + I * 5;
  52.     Rectangle(PaintDC, X1, Y1, X1 + X1, X1 + Y1 * 2);
  53.   end;
  54. end;
  55.  
  56. { Declare a variable of type TScrollApp } 
  57. var
  58.   ScrollApp: TScrollApp;
  59.  
  60. { Run the ScrollApp }
  61. begin
  62.   ScrollApp.Init('ScrollApp');
  63.   ScrollApp.Run;
  64.   ScrollApp.Done;
  65. end.
  66.