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

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program SBarTest;
  9.  
  10. uses WinTypes, WinProcs, Strings, OWindows, ODialogs;
  11.          
  12. const
  13.   id_ThermScroll = 100;
  14.   id_Stat1 = 101;
  15.  
  16. type
  17.  
  18.   TestApplication = object(TApplication)
  19.     procedure InitMainWindow; virtual;
  20.   end;
  21.  
  22.   PTestWindow = ^TestWindow;
  23.  
  24.   TestWindow = object(TWindow)
  25.     ThermScroll : PScrollBar;
  26.     Stat1 : PStatic;
  27.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  28.     procedure SetupWindow; virtual;
  29.     procedure HandleThermScrollMsg(var Msg: TMessage);
  30.       virtual id_First + id_ThermScroll;
  31.   end;
  32.  
  33. { Set attributes and construct child controls }
  34. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  35. begin
  36.   inherited Init(AParent, ATitle);
  37.   with Attr do
  38.   begin
  39.     X := 20;
  40.     Y := 20;
  41.     W := 380;
  42.     H := 250;
  43.   end;
  44.   ThermScroll := New(PScrollBar,
  45.     Init(@Self, id_ThermScroll, 20, 170, 340, 0, True));
  46.   Stat1 := New(PStatic,
  47.     Init(@Self, id_Stat1, ' 32 degrees', 135, 40, 160, 17, 0));
  48. end;
  49.  
  50. { Create scrollbar and static controls; set range of scrollbar }
  51. procedure TestWindow.SetupWindow;
  52. begin
  53.   inherited SetupWindow;
  54.   ThermScroll^.SetRange(32, 120);
  55. end;
  56.  
  57. { Handle notification messages from therm scrollbar }
  58. procedure TestWindow.HandleThermScrollMsg(var Msg: TMessage);
  59. var
  60.   cString: array[0..11] of Char;
  61. begin
  62.   Str(ThermScroll^.GetPosition:3, cString);
  63.   StrCat(cString, ' degrees');
  64.   Stat1^.SetText(cString);
  65. end;
  66.  
  67. procedure TestApplication.InitMainWindow;
  68. begin
  69.   MainWindow := New(PTestWindow, Init(nil, 'Thermostat'));
  70. end;
  71.  
  72. var
  73.   TestApp : TestApplication;
  74.  
  75. begin
  76.   TestApp.Init('SBarApp');
  77.   TestApp.Run;
  78.   TestApp.Done;
  79. end.
  80.