Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Problem mit KeyDown (https://www.delphipraxis.net/113851-problem-mit-keydown.html)

_frank_ 15. Mai 2008 23:08


Problem mit KeyDown
 
ich hab mir ein Control von TCustomControl abgeleitet und da KeyDown überschrieben.
leider wird meine methode nicht aufgerufen (wurde nicht wegoptimiert).
es kommen keine Compilerfehler/warnungen. TWinControl.KeyDown (die ursprungsmethode) wird aufgerufen nur meine nicht.

Delphi-Quellcode:
  TBlah=class(TCustomControl)

  protected
    procedure KeyDown(var Key: Word; Shift: TShiftState);override;
  end;

...

procedure TBlah.KeyDown(var Key: Word; Shift: TShiftState);
begin
  showmessage('keydown');
  inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TBlah.create(self) do
  begin
    parent:=self;
    top:=0;
    left:=0;
    width:=100;
    height:=100;
  end;
end;
hat jemand eine Idee, was ich falsch mache?

Gruß Frank

bitsetter 16. Mai 2008 00:07

Re: Problem mit KeyDown
 
Hi,

setze mal den Focus in das Control, dann funktioniert es auch.
Delphi-Quellcode:
   
   ...
  with TBlah.create(self) do
  begin
    parent:=self;
    top:=0;
    left:=0;
    width:=100;
    height:=100;

    SetFocus;
  end;...

_frank_ 16. Mai 2008 09:26

Re: Problem mit KeyDown
 
danke bitsetter
naja, der focus sollte doch gesetzt werden, wenn ich mit der maus draufklicke, oder?
hab das jetzt zwar manuell im mousedown gemacht, aber trotzdem komisch...

Gruß Frank


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz