espero te sirva este ejemplo
es un treeview que muestra 4 opciones cada una manda llamar un formulario
Código Delphi
[-]procedure TfPrincipal.tPVentasClick(Sender: TObject);
begin
if tPVentas.Items[0].Selected then
begin
if not createMDI(fPrincipal,tfNvaVenta,fNvaVenta) then
Application.CreateForm(tfNvaVenta,fNvaVenta);
PanelPrincipal.Enabled := False;
fnvaventa.envia:='P';
fnvaventa.Height:= 650;
fNvaVenta.Show;
end;
if tPVentas.Items[1].Selected then
begin
if not createMDI(fPrincipal,tfListVenta,fListVenta) then
Application.CreateForm(tfListVenta,fListVenta);
PanelPrincipal.Enabled := False;
dbds.filtra(dbds.dsventas, dbds.con_ventas +' order by tblpuntodeventa.posid desc');
flistventa.envia:='P';
fListVenta.Show;
end;
if tPVentas.Items[2].Selected then
begin
if not createMDI(fPrincipal,tfCorteCaja,fCorteCaja) then
Application.CreateForm(tfCorteCaja,fCorteCaja);
PanelPrincipal.Enabled := False;
fCorteCaja.envia:='P';
fCorteCaja.Show;
end;
if tPVentas.Items[3].Selected then
begin
if not createMDI(fPrincipal,tfrmcorte_parcial,frmcorte_parcial) then
Application.CreateForm(tfrmcorte_parcial,frmcorte_parcial);
PanelPrincipal.Enabled := False;
frmcorte_parcial.envia:='P';
frmcorte_parcial.Show;
end;
end;
createmdi es una funcion que uso para saber si el formulario no ha sido creado.
Código Delphi
[-]function tfPrincipal.CreateMDI(Owner:TForm;BaseClass:TFormClass; FormVar:TForm):Boolean;
var
found:Boolean;
i:integer;
begin
Application.ProcessMessages;
found := False;
For i:= 0 To Owner.MDIChildCount-1 Do
If Owner.MDIChildren[i] is BaseClass Then
Begin
Owner.MDIChildren[i].Show;
found := True;
End;
createMDI := Found;
end;
espero te sirva