Ver Mensaje Individual
  #3  
Antiguo 25-06-2015
Avatar de kapcomx
kapcomx kapcomx is offline
Miembro
 
Registrado: jun 2007
Ubicación: Puebla México
Posts: 350
Reputación: 17
kapcomx Va por buen camino
ejemplo

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;
//                        Recorremos el array de ventanas hijas
     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
__________________
un tipo al cual la sociedad no le tiene el mas mínimo respeto no puede ser presidente....
Responder Con Cita