home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_11 / 2n11037a < prev    next >
Text File  |  1991-10-11  |  2KB  |  64 lines

  1. program TestMaskEdit;
  2. uses MaskEdit, WObjects, WinProcs;
  3. type
  4.     TAMaskEdit = object(TMaskEdit)
  5.         procedure InputChar(Pressed:char;
  6.             StartPos, EndPos : integer); virtual;
  7.     end;
  8.     PAMaskEdit = ^TAMaskEdit;
  9.     TTestMaskEdit = object(TApplication)
  10.         TestEdit    : PMaskEdit;
  11.         TestAEdit   : PAMaskEdit;
  12.         procedure InitMainWindow; virtual;
  13.     end;
  14.  
  15. { InputChar - implement pattern character 'A'. }
  16.  
  17. procedure TAMaskEdit.InputChar(Pressed:char;
  18.     StartPos, EndPos : integer);
  19. begin
  20.  
  21.     { if 'A', only allow alpha and map to upper case }
  22.  
  23.     if Pattern[StartPos] = 'A' then
  24.         begin
  25.         if Pressed in ['a'..'z','A'..'Z'] then
  26.             begin
  27.             if Pressed in ['a'..'z'] then
  28.                 Pressed    := UpCase(Pressed);
  29.             PutChar(Pressed);
  30.             end
  31.         else
  32.             MessageBeep(0);
  33.         end
  34.     else
  35.         TMaskEdit.InputChar(Pressed, StartPos, EndPos);
  36. end;
  37.  
  38. procedure TTestMaskEdit.InitMainWindow;
  39. begin
  40.     MainWindow := New(PWindow, Init(nil, 'Test MaskEdit'));
  41.  
  42.     TestEdit  := New(PMaskEdit, Init(MainWindow, 98,
  43.         '(nnn) nnn-nnnn', 20, 20, 115, 30, 14));
  44. {
  45. Normally, you would put "State" in a static text field, but I
  46. want to demonstrate literal alphabetic characters...
  47. }
  48.     TestAEdit := New(PAMaskEdit, Init(MainWindow, 99,
  49.         '\S\t\a\t\e [AA]', 20, 55, 115, 30, 15));
  50. end;
  51.  
  52.  
  53. var    App : TTestMaskEdit;
  54.     TestEdit : PEdit;
  55. begin
  56.  
  57.     App.Init('Test Numeric Edit');
  58.     SetFocus(App.TestEdit^.HWindow);
  59.     App.Run;
  60.     App.Done;
  61. end.
  62. { End of File } 
  63.  
  64.