home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 7.ddi / OWLDEMOS.ZIP / SCROLAPP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.7 KB  |  60 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4.  
  5. // Declare TScrollApp, a TApplication descendant
  6. class TScrollApp : public TApplication {
  7. public:
  8.   TScrollApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  9.     LPSTR lpCmdLine, int nCmdShow)
  10.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  11.   virtual void InitMainWindow();
  12. };
  13.  
  14. // Declare TScrollWindow, a TWindow descendant
  15. class TScrollWindow : public TWindow
  16. {
  17. public:
  18.   TScrollWindow(LPSTR ATitle);
  19.   virtual void Paint(HDC PaintDC, PAINTSTRUCT& PaintInfo);
  20. };
  21.  
  22. /* Constructor for a TScrollWindow, sets scroll styles and
  23.    constructs the Scroller object. */
  24. TScrollWindow::TScrollWindow(LPSTR ATitle) : TWindow(NULL, ATitle)
  25. {
  26.   Attr.Style |= WS_VSCROLL | WS_HSCROLL;
  27.   Scroller = new TScroller(this, 8, 15, 80, 60);
  28. }
  29.  
  30. /* Responds to an incoming "paint" message by redrawing boxes. Note
  31.    that the Scroller's BeginView method, which sets the viewport origin
  32.    relative to the present scroll position, has already been called. */
  33. void TScrollWindow::Paint(HDC PaintDC,PAINTSTRUCT&)
  34. {
  35.   int X1, Y1, I;
  36.  
  37.   for (I = 0; I <= 49; ++I)
  38.   {
  39.     X1 = 10 + I*8;
  40.     Y1 = 30 + I*5;
  41.     Rectangle(PaintDC, X1, Y1, X1 + X1, X1 + Y1 * 2);
  42.   }
  43. }
  44.  
  45. // Construct the TScrollApp's MainWindow of type TScrollWindow
  46. void TScrollApp::InitMainWindow()
  47. {
  48.   MainWindow = new TScrollWindow("Boxes");
  49. }
  50.  
  51. // Run the ScrollApp
  52. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  53.   LPSTR lpCmdLine, int nCmdShow)
  54. {
  55.   TScrollApp ScrollApp("ScrollApp", hInstance, hPrevInstance,
  56.     lpCmdLine, nCmdShow);
  57.   ScrollApp.Run();
  58.   return ScrollApp.Status;
  59. }
  60.