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

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program BtnTest;
  9.  
  10. uses WinTypes, WinProcs, OWindows, ODialogs;
  11.          
  12. const
  13.   id_Push1  = 101;
  14.   id_Rad1   = 102;
  15.   id_Rad2   = 103;
  16.   id_Check1 = 104;
  17.   id_Group1 = 105;
  18.  
  19. type
  20.   TestApplication = object(TApplication)
  21.     procedure InitMainWindow; virtual;
  22.   end;
  23.  
  24.   PTestWindow = ^TestWindow;
  25.  
  26.   TestWindow = object(TWindow)
  27.     Rad1, Rad2: PRadioButton;
  28.     Check1: PCheckBox;
  29.     Group1: PGroupBox;
  30.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  31.     procedure HandlePush1Msg(var Msg: TMessage);
  32.       virtual id_First + id_Push1;
  33.     procedure HandleCheck1Msg(var Msg: TMessage);
  34.       virtual id_First + id_Check1;
  35.     procedure HandleGroup1Msg(var Msg: TMessage);
  36.       virtual id_First + id_Group1;
  37.   end;
  38.  
  39. { --------TestWindow methods------------------ }
  40. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  41. var
  42.   AButt: PButton;
  43. begin
  44.   inherited Init(AParent, ATitle);
  45.   AButt := New(PButton, Init(@Self, id_Push1, 'State of Check Box',
  46.     88, 48, 296, 24, False));
  47.   Check1 := New(PCheckBox, Init(@Self, id_Check1, 'Check Box Text',
  48.     158, 12, 150, 26, nil));
  49.   Group1 := New(PGroupBox, Init(@Self, id_Group1, 'Group Box',
  50.     158, 102, 176, 108));
  51.   Rad1 := New(PRadioButton, Init(@Self, id_Rad1, 'Radio Button 1',
  52.     174, 128, 138, 24, Group1));
  53.   Rad2 := New(PRadioButton, Init(@Self, id_Rad2, 'Radio Button 2',
  54.     174, 162, 138, 24, Group1));
  55. end;
  56.  
  57. procedure TestWindow.HandlePush1Msg(var Msg: TMessage);
  58. begin
  59.   if Check1^.GetCheck = bf_Unchecked then
  60.   MessageBox(HWindow, 'Unchecked', 'The check box is:', MB_OK)
  61.   else MessageBox(HWindow, 'Checked', 'The check box is:', MB_OK);
  62. end;
  63.  
  64. procedure TestWindow.HandleCheck1Msg(var Msg: TMessage);
  65. begin
  66.   MessageBox(HWindow, 'Toggled', 'The check box has been:', MB_OK)
  67. end;
  68.  
  69. procedure TestWindow.HandleGroup1Msg(var Msg: TMessage);
  70. var
  71.   TextBuff: array[0..20] of Char;
  72. begin
  73.   if Rad1^.GetCheck <> bf_Unchecked
  74.   then GetWindowText(Rad1^.HWindow, TextBuff, SizeOf(TextBuff))
  75.   else GetWindowText(Rad2^.HWindow, TextBuff, SizeOf(TextBuff));
  76.   MessageBox(HWindow, TextBuff, 'You have selected:', MB_OK);
  77. end;
  78.  
  79. { -----------TestApplication Methods------------ }
  80. procedure TestApplication.InitMainWindow;
  81. begin
  82.   MainWindow := New(PTestWindow, Init(nil, 'Button Tester'));
  83. end;
  84.  
  85. var
  86.   TestApp : TestApplication;
  87.  
  88. begin
  89.   TestApp.Init('ButtonTest');
  90.   TestApp.Run;
  91.   TestApp.Done;
  92. end.
  93.