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

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <stdio.h>
  4. #include <owl.h>
  5. #include <window.h>
  6. #include <scrollba.h>
  7. #include <static.h>
  8.  
  9. const WORD ID_THERMOMETER = 100;
  10. const WORD ID_STATIC = 101;
  11.  
  12. class TTestApp : public TApplication
  13. {
  14. public:
  15.   TTestApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
  16.     LPSTR lpCmdLine, int nCmdShow)
  17.     : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
  18.   virtual void InitMainWindow();
  19. };
  20.  
  21. class TTestWindow : public TWindow
  22. {
  23. public:
  24.   TScrollBar *Thermometer;
  25.   TStatic *Static;
  26.   TTestWindow(PTWindowsObject AParent, LPSTR ATitle);
  27.   virtual void SetupWindow();
  28.   virtual void HandleThermMsg(RTMessage Msg)
  29.     = [ID_FIRST + ID_THERMOMETER];
  30. };
  31.  
  32. TTestWindow::TTestWindow(PTWindowsObject AParent, LPSTR ATitle) :
  33.   TWindow(AParent, ATitle)
  34. {
  35.   Attr.X = 20;  Attr.Y = 20;  Attr.W = 380;  Attr.H = 250;
  36.   Thermometer =
  37.     new TScrollBar(this, ID_THERMOMETER, 20, 170, 340, 0, TRUE);
  38.   Static =
  39.     new TStatic(this, ID_STATIC, "32 degrees", 135, 40, 160, 17, 0);
  40.   EnableKBHandler();
  41. }
  42.  
  43. void TTestWindow::SetupWindow()
  44. {
  45.   TWindow::SetupWindow();
  46.   Thermometer->SetRange(32, 120);
  47. }
  48.  
  49. void TTestWindow::HandleThermMsg(RTMessage)
  50. {
  51.   char AString[11];
  52.  
  53.   sprintf(AString, "%d%s", Thermometer->GetPosition(), " degrees");
  54.   Static->SetText(AString);
  55. }
  56.  
  57. void TTestApp::InitMainWindow()
  58. {
  59.   MainWindow = new TTestWindow(NULL, Name);
  60. }
  61.  
  62. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  63.   LPSTR lpCmdLine, int nCmdShow)
  64. {
  65.   TTestApp TestApp("Thermostat", hInstance, hPrevInstance,
  66.     lpCmdLine, nCmdShow);
  67.   TestApp.Run();
  68.   return TestApp.Status;
  69. }
  70.  
  71.