I have a child form 'frmTest' and a main form 'TfrmMain'. I set the main form as parent for frmTest like this:
unit Main;
INTERFACE
USES
System.SysUtils, System.Classes, Vcl.Forms, Test, Vcl.StdCtrls, Vcl.Controls;
type
TfrmMain = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
IMPLEMENTATION {$R *.dfm}
procedure TfrmMain.Button1Click(Sender: TObject);
VAR frmTest: TChildForm;
begin
Application.CreateForm(TChildForm, frmTest);
//frmTest:= TForm1.Create(Self);
frmTest.Parent:= Self;
frmTest.Show;
frmTest.SetFocus;
end;
unit test; { THIS IS THE CHILD }
INTERFACE
USES
System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin;
TYPE
TChildForm = class(TForm)
Edit1: TEdit;
SpinEdit1: TSpinEdit;
private
public
end;
IMPLEMENTATION {$R *.dfm}
end.
Code as ZIP
But controls (edit box, spin edit, etc) in frmInsertImg will not accept focus from mouse but can be focused with Tab.
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…