1

I have 2 forms, Form1(it contain 1 button only) and Form2(it contains a memo only). here is the code when I click the button :

begin
  Form2.Parent := Self;
  Form2.Show;
end;

it was OK, but when I click the memo it can't get focus. But when I press tab, it can get focus. Why it can't get focus during click but it can get focus when I tab? How can I make it focusable when clicked?

EDIT

here is the code in my Form1 :

TForm1 = class(TForm)
    btn1: TButton;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  Unit2;

procedure TForm1.btn1Click(Sender: TObject);
begin
  Form2.Parent := Self;
  Form2.Show;
end;

and this is Form2 :

TForm2 = class(TForm)
    memo2: TMemo;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
Ago
  • 755
  • 7
  • 28
  • 2
    Really curious why you want to do this, by the way. Proper ways to achieve this, is to make Form1 and MDI form and Form2 an MDIChild, or to use TFrames instead of TForms. A normal form is intended to be a top level window, and forcing it to be a child of another window is asking for problems. – GolezTrol Apr 01 '19 at 11:05
  • 1
    Possible duplicate of [How to create a delphi form containing multiple 'child' forms that can be moved/sized and show activated](https://stackoverflow.com/questions/5729295/how-to-create-a-delphi-form-containing-multiple-child-forms-that-can-be-moved) – GolezTrol Apr 01 '19 at 11:08
  • never thought that this will be complex.. just checked MDI and it suits my needs.. – Ago Apr 02 '19 at 02:25

0 Answers0