Hola.
De esta forma creo que vas a evitar la pérdida del foco.
Código Delphi
[-]
uses Unit2;
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel1.Visible:= False;
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
Panel1.Visible:= True;
with TForm2.Create(Self) do
begin
ManualDock(Panel1, nil, alClient);
Align := alClient;
Show;
end;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
if Panel1.Visible then
begin
Form2.Free;
Panel1.Visible:= False;
end;
end;
El uso de
ManualDock en lugar del tradicional 'Form2.Parent:= Panel1' para mí era una novedad hasta hace muy poco.
Es un dato que se lo debo al amigo
Neftalí, quíen explica muy bién sus ventajas [
aquí ].
Saludos.