home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / oop.swg / 0025_Password for TVision.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-27  |  1.5 KB  |  70 lines

  1. {
  2. EDWIN GROOTHUIS
  3.  
  4. somebody asked For a inputline For passWords. I have such one, but I've
  5. forgotten WHICH discussionlist... so I'll mail it to the above lists, I
  6. know it's one of it, and know it can be interesting For somebody else.
  7.  
  8. What I have done is overriden the Draw-Procedure For the inputline to draw
  9. only ***'s instead of the right Characters.  The solution I gave yesterday
  10. was not quitte correct: I used the Procedure SetData to put the *'s into the
  11. Data^-field, but that Procedure calls the Draw-Procedure itself so you'll
  12. get an infinite loop and a stack-overflow error. Now I put the *'s direct to
  13. the Data^-field, I don't think it can give problems.
  14. }
  15.  
  16. Uses
  17.   app, dialogs, views, Objects;
  18.  
  19. Type
  20.   PPassWord = ^TPassWord;
  21.   TPassWord = Object(TInputLine)
  22.                 Procedure Draw; Virtual;
  23.               end;
  24.  
  25.  
  26. Procedure TPassWord.Draw;
  27.  
  28. Var
  29.   s, t : String;
  30.   i    : Byte;
  31. begin
  32.   GetData(s);
  33.   t := s;
  34.   For i := 1 to length(t) do
  35.     t[i] := '*';
  36.   Data^ := t;
  37.   inherited Draw;
  38.   Data^ := s;
  39. end;
  40.  
  41. Procedure about;
  42. Var
  43.   d : pdialog;
  44.   r : trect;
  45.   b : pview;
  46. begin
  47.   r.assign(1, 1, 60, 15);
  48.   d := new(pdialog,init(r, 'About'));
  49.   With d^ do
  50.   begin
  51.     flags := flags or wfgrow;
  52.     r.assign(1,1,10,3);
  53.     insert(new(PButton, init(r,'~O~K', cmok, bfdefault)));
  54.     r.assign(2,4,8,5);
  55.     insert(new(PPassWord, init(r,10)));
  56.   end;
  57.   desktop^.execview(d);
  58.   dispose(d, done);
  59. end;
  60.  
  61.  
  62. Var
  63.   a : TApplication;
  64. begin
  65.   a.init;
  66.   about;
  67.   a.run;
  68.   a.done;
  69. end.
  70.