1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| //http://support.microsoft.com/kb/83302
TEssai = class(TCustomControl)
protected
fWantTabs : Boolean ;
fWantReturns : Boolean ;
procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
private
{ Déclarations privées }
public
{ Déclarations publiques }
constructor Create(Owner:TComponent); override;
published
property WantTabs : boolean read fWantTabs write fWantTabs default false ;
property WantReturns : boolean read fWantReturns write fWantReturns default true ;
end;
constructor TEssai.Create(Owner:TComponent);
begin
inherited Create(Owner);
TabStop := True ;
Color := clRed ;
Height := 21 ;
Width := 121 ;
fWantTabs := False ;
fWantReturns := true ;
end ;
procedure TEssai.WMGetDlgCode(var Msg: TWMGetDlgCode);
begin
// Applé à chaque appuie de touche
inherited;
Msg.Result := Msg.Result or DLGC_WANTARROWS or DLGC_WANTCHARS;
// Désactive la tabulation pour passer au control suivant
if fWantTabs then
Msg.Result := Msg.Result or DLGC_WANTTAB;
if fWantReturns then
Msg.Result := Msg.Result or DLGC_WANTALLKEYS;
end;
procedure TEssai.KeyDown(var Key: Word; Shift: TShiftState);
begin
if Key = VK_DOWN
then
Color := clBlue ;
end ;
procedure TEssai.KeyUp(var Key: Word; Shift: TShiftState);
begin
end ; |
Partager