Registriert seit: 29. Mai 2002
Ort: Frankfurt
8.252 Beiträge
Delphi 2006 Professional
|
Re: SetFocus / Taborder im OnKeyPress setzen ?
23. Jul 2006, 07:52
Hai Hansa,
warum verwendest Du nicht einfach diesen Code zum nächsten Control zu gehen?
if Key = #13 then Parent.Perform(WM_NEXTDLGCTL,0,0);
Ich habe das mal so gemacht:
Delphi-Quellcode:
unit ShEdit;
interface
uses
Classes, StdCtrls, Controls, Messages, Windows;
type
TShEdit = class(TEdit)
protected
FEnterAsTab: Boolean;
procedure KeyDown( var Key: Word; Shift: TShiftState); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property EnterAsTab: Boolean read FEnterAsTab write FEnterAsTab default True;
end;
procedure Register;
implementation
constructor TShEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEnterAsTab := True;
end;
destructor TShEdit.Destroy;
begin
inherited Destroy;
end;
procedure TShEdit.KeyDown( var Key: Word; Shift: TShiftState);
var
mgsTemp: TMsg;
begin
inherited KeyDown(Key, Shift);
if (Key = VK_RETURN) and (FEnterAsTab) then
begin
Parent.Perform(WM_NEXTDLGCTL, 0, 0);
PeekMessage(mgsTemp, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
end;
end;
procedure Register;
begin
RegisterComponents(' Sharky', [TShEdit]);
end;
end.
Stephan B.
|
|
Zitat
|