I'm trying to implement a TDI interface in my project. It's working fine so far (the forms are created inside tabs on my PageControl - as expected). However, I'm facing an annoying issue: the OnKeyPress event isn't fired on my child forms just because they are "parented". I've tried both ways below, but with no success:
procedure TForm1.Button1Click(Sender: TObject);
var
f: TForm2;
begin
f := TForm2.Create(self);
f.ManualDock(PageControl1);
f.Show;
end;
-OR-
procedure TForm1.Button1Click(Sender: TObject);
var
f: TForm2;
tab: TTabSheet;
begin
tab := TTabSheet.Create(PageControl1);
tab.PageControl := PageControl1;
tab.Parent := PageControl1;
f := TForm2.Create(tab);
f.BorderStyle := bsNone;
f.Align := alClient;
f.Parent := tab;
tab.Caption := f.Caption;
f.Show;
end;
¹ needless to say that the KeyPreview property is set as True.
² if I just comment the following line, the event works fine (but the form is not created inside a TabSheet):
//f.Parent := tab;
Has anyone faced this issue before? Any help? Thanks!