Autor Beitrag
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Sa 13.01.07 11:12 
Hi,
kann ich ein TEdit irgendwie ableiten, damit es, wenn es den Fokus hat, einen Druck auf die Eingabe-Taste im OnKeyPress/OnKeyDown-Ereignis mitbekommt und nicht der Default-Button des Fensterns ausgelöst wird?
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Sa 13.01.07 11:26 
Eigentlich hast dus ja schon gesagt
im OnKeyDown kannst du schauen ob der Key vkReturn war und dann eben z.B. Button1.Click ausrufen.

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Sa 13.01.07 14:11 
Gerade das funktioniert eben nicht, sonst hätte ich doch nicht gefragt. Ich habe eine OK-Button mit der Default-Eigenschaft und ModalResult = mrOK. Hat das TEdit den Fokus und ich drücke die Eingabetaste, wird das Fenster geschlossen und das OnKeyPressed bzw OnKeyDown-Ereignis des TEdits nicht gefeuert.
Andidreas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114

Windows XP Pro
BDS 2006
BeitragVerfasst: Sa 13.01.07 14:15 
Hast Du auch im OnKeyPressed bzw OnKeyDown Key := #0 eingebaut?
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Sa 13.01.07 14:21 
Natürlich.

Aber ich hab mir selbst geholfen:

In der Ableitung folgenden Messagehandler überschreiben und es klappt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TAdvEdit.CMWantSpecialKey(var Msg: TCMWantSpecialKey);
begin
 if Msg.CharCode = VK_RETURN then
  Msg.Result := 1
 else
  inherited;
end;