Advertisement
TLama

Untitled

Jul 22nd, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.12 KB | None | 0 0
  1. type
  2.   TInputField = class(TCustomControl)
  3.   private
  4.     procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
  5.   protected
  6.     procedure Paint; override;
  7.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  8.     procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  9.   public
  10.     constructor Create(AOwner: TComponent); override;
  11.   end;
  12.  
  13. implementation
  14.  
  15. { TInputField }
  16.  
  17. constructor TInputField.Create(AOwner: TComponent);
  18. begin
  19.   inherited;
  20.   TabStop := True;
  21. end;
  22.  
  23. procedure TInputField.WMGetDlgCode(var Msg: TWMGetDlgCode);
  24. begin
  25.   inherited;
  26.   Msg.Result := Msg.Result or DLGC_WANTCHARS or DLGC_WANTARROWS or DLGC_WANTTAB or DLGC_WANTALLKEYS;
  27. end;
  28.  
  29. procedure TInputField.Paint;
  30. begin
  31.   inherited;
  32.   Canvas.Rectangle(ClientRect);
  33. end;
  34.  
  35. procedure TInputField.KeyDown(var Key: Word; Shift: TShiftState);
  36. begin
  37.   inherited;
  38.   if Key = VK_RETURN then
  39.     ShowMessage('VK_RETURN');
  40. end;
  41.  
  42. procedure TInputField.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  43. begin
  44.   inherited;
  45.   if CanFocus Then
  46.     SetFocus;
  47. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement