Question : Capture arrow keystrokes in a TForm

I have already asked this question and got response for several component in a TForm
I set the keypreview of the form to True
I code the keydown event so that I can do something special for keystrokes like left and right arrow
But now I have a TRadioGroup on my form.
Keystrokes is correctly processed until the focus gets into the TRadioGroup.
The arrows move the focus between the items
How can I forbid that and have the control in the keydown instead ?
Thanks

Answer : Capture arrow keystrokes in a TForm

redeclare the TRadioGroup class to override the default Click event in order to give control back to the form once the radiogroup is clicked. With TabStop = False that should do the trick.
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:
Type
  TRadioGroup=class(extctrls.TRadioGroup)
  public
   constructor Create(AOwner: TComponent); override;
   procedure Click; override;
  end;

  TForm1=class(TForm)
   ...
   rg1:TRadioGroup
   ...
  public
   ...
  end;

implementation

procedure TRadioGroup.Click;
begin
 inherited;
 (Owner As TForm).ActiveControl:=nil;
end;

constructor TRadioGroup.Create(AOwner: TComponent);
begin
 inherited;
 TabStop:=False;
end;
Random Solutions  
 
programming4us programming4us