Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-03-2008
zarzuela zarzuela is offline
Registrado
 
Registrado: nov 2006
Posts: 7
Poder: 0
zarzuela Va por buen camino
Mira que facil

En la forma principal, recuerda que hablamno de MDI padre puedes ponerte un boton generar que sirva para cerrar todos
y este código lo pones en el

if frmprincipal.MDIChildCount>=1 then
ActiveMDIChild.Close
else
Close;

end;
eso implica que si hay algun MDIChild activo lo cierra pero si es el formulario principal el activo entonces sales del sistema.
Puedes ponerlo o arregarlo a tu gusto.
Responder Con Cita
  #2  
Antiguo 01-05-2008
petitrad petitrad is offline
Registrado
 
Registrado: abr 2008
Posts: 7
Poder: 0
petitrad Va por buen camino
Como Cerrar Una Ventana Hija

Hola a todos es mi primera vez aqui en el foro y me gustaria saber como cerrar una ventana hija.

esta la creo con este codigo

Vventa := TVenta.Create(self);
Vventa.FormStyle := fsMDIChild;
Vventa.Left :=0;
Vventa.Top :=0;
Vventa.Width:=Screen.Width-15;
Vventa.Height:= Screen.Height-50;
Vventa.Parent := self;
Vventa.Name := 'Ventas';
Vventa.Show;

pero al ponerle que la cierra no se cierra no hace nada,
ya e tratado con mdicount, screenform y cosas asi pero todas me marcan error de memoria, tambien e tratado con destroy, close, free y pues nada, espero ustedes me ayuden.

ya que tengo el form principal y de ahi abro la pantalla de ventas y quiero que se pueda cerrar y volver a abrir luego, ya que realize un menu con un panel e imagenes, y si no creo el child seponen arriva del menu y si creo las childs no se suben arriva del menu, el unico problema que no puedo cerrarlas.

espero pronta respuesta gracias.
Responder Con Cita
  #3  
Antiguo 01-05-2008
Avatar de jcarteagaf
[jcarteagaf] jcarteagaf is offline
Miembro Premium
 
Registrado: abr 2006
Ubicación: La Paz, Bolivia
Posts: 651
Poder: 19
jcarteagaf Va por buen camino
Cuando quieras cerrar la ventana hijas usas lo siguiente:

Código Delphi [-]
VentanaHija.close; //asumiendo que lo estas llamando desde tu forma padre



y en el evento OnFormClose de la ventana hija colocas

Código Delphi [-]
procedure TfrmVentanaHija.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

Saludos.
Responder Con Cita
  #4  
Antiguo 01-05-2008
Avatar de MaMu
MaMu MaMu is offline
Miembro
 
Registrado: abr 2006
Ubicación: Argentina
Posts: 863
Poder: 19
MaMu Va por buen camino
Código Delphi [-]
 
procedure TfrmVentanaHija.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
 frmVentanaHija:=nil;  //<-----no?  
 Action := caFree;
end;
__________________
Código Delphi [-]
 
try 
ProgramarMicro(80C52,'Intel',MnHex,True);
except
On Exception do
MicroChip.IsPresent(True);
end;
Responder Con Cita
  #5  
Antiguo 01-05-2008
petitrad petitrad is offline
Registrado
 
Registrado: abr 2008
Posts: 7
Poder: 0
petitrad Va por buen camino
No Puedo Cerrar Ventanas

ya he tratado de cerrarla de esta manera

procedure TfrmVentanaHija.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frmVentanaHija:=nil;
Action := caFree;
end;

me marca el sig error,

project QSoft.exe raised exception class EAccessViolation with message 'Access violation at address 000000000. Read of adress 000000000'. Process stopped. use step or run to continue.

si lo cierra, pero al intentarla abrir de nuevo me marca error que ya existe, pero si la abre, no se si esto es normal o deba hacer algo mas.

gracias
Responder Con Cita
  #6  
Antiguo 02-05-2008
Avatar de jcarteagaf
[jcarteagaf] jcarteagaf is offline
Miembro Premium
 
Registrado: abr 2006
Ubicación: La Paz, Bolivia
Posts: 651
Poder: 19
jcarteagaf Va por buen camino
Proba hacerlo de la siguiente forma

Código Delphi [-]
 procedure TfrmVentanaHija.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
  Action := caFree;
  frmVentanaHija:=nil;
 end;

pero tambien dependera de como crees la ventana si estas haciendo algo asi:

Código Delphi [-]
With TfrmVentanaHija.Create(application) do
  Show;

te marcara error de Access violation en el FormClose, debido a que el objeto frmVentanaHija no ha sido creado.

Normalmente yo creo y llamo a las formas hijas de la siguiente manera:

Código Delphi [-]
if frmVentanaHija = nil then
    frmVentanaHija := TfrmVentaHija.Create(application)
frmVentanaHija.Show;

En este caso, si la ventana hija ya ha sido creada, solamente la muestra.


Saludos.
Responder Con Cita
  #7  
Antiguo 02-05-2008
petitrad petitrad is offline
Registrado
 
Registrado: abr 2008
Posts: 7
Poder: 0
petitrad Va por buen camino
Aun marca error de memoria

aun me marca el mismo error, aqui esta el codigo que utilizo en las formas

Código Delphi [-]
//Principal 
unit Principal;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, LMDControl, LMDBaseControl, LMDBaseGraphicButton,
  LMDCustom3DButton, LMD3DEffectButton, ExtCtrls, StdCtrls,
  LMDCustomControl, LMDCustomPanel, LMDCustomBevelPanel, LMDSimplePanel,
  LMDCustomShapeButton, LMDShapeButton, LMDCustomParentPanel, LMDBackPanel;
type
  TMain = class(TForm)
    LogoQS: TImage;
    Panel1: TPanel;
    LetrasLP: TImage;
    NUsuario: TLabel;
    Fecha: TLabel;
    Hora: TLabel;
    Panel2: TPanel;
    LMDSimplePanel8: TLMDSimplePanel;
    BVentas: TLMDShapeButton;
    LMDSimplePanel9: TLMDSimplePanel;
    BCompras: TLMDShapeButton;
    LMDSimplePanel10: TLMDSimplePanel;
    BCuentasCobrar: TLMDShapeButton;
    LMDSimplePanel11: TLMDSimplePanel;
    BCuentasPagar: TLMDShapeButton;
    LMDSimplePanel12: TLMDSimplePanel;
    BReportes: TLMDShapeButton;
    LMDSimplePanel14: TLMDSimplePanel;
    BInventario: TLMDShapeButton;
    LMDSimplePanel13: TLMDSimplePanel;
    BUtilidades: TLMDShapeButton;
    LMDSimplePanel15: TLMDSimplePanel;
    BPalm: TLMDShapeButton;
    LMDSimplePanel16: TLMDSimplePanel;
    BSalir: TLMDShapeButton;
    procedure BSalirClick(Sender: TObject);
    procedure FormClick(Sender: TObject);
    procedure LMDSimplePanel8MouseEnter(Sender: TObject);
    procedure LMDSimplePanel9MouseEnter(Sender: TObject);
    procedure LMDSimplePanel10MouseEnter(Sender: TObject);
    procedure LMDSimplePanel11MouseEnter(Sender: TObject);
    procedure LMDSimplePanel12MouseEnter(Sender: TObject);
    procedure LMDSimplePanel13MouseEnter(Sender: TObject);
    procedure LMDSimplePanel14MouseEnter(Sender: TObject);
    procedure LMDSimplePanel15MouseEnter(Sender: TObject);
    procedure LMDSimplePanel16MouseEnter(Sender: TObject);
    procedure LogoQSClick(Sender: TObject);
    procedure LetrasLPClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BVentasClick(Sender: TObject);
    procedure BComprasClick(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
    procedure AbreCotizacion();
  end;
var
  Main: TMain;
implementation
uses Ventas, MenuV, MenuC, MenuCC, MenuCP, MenuI, MenuR, MenuU, Compras,
  Cotizaciones;
{$R *.dfm}
procedure TMain.BSalirClick(Sender: TObject);
var
        I: integer;
begin
//cierra todas las ventanas que esten abiertas
for I := 0 to Screen.FormCount - 1 do
       Screen.Forms[i].Close;
Close;
end;
procedure pantalla_completa();
var
  HTaskbar : HWND;
begin
  TRY     //Obtener el  handle del Taskbar de Windows
    HTaskBar:=FindWindow('Shell_TrayWnd',nil );
    EnableWindow(HTaskBar,False);  //Deshabilitar el Taskbar
    ShowWindow(HTaskbar,SW_HIDE);   //Esconder el Taskbat
  FINALLY
    With  Main  do begin
      BorderStyle :=bsNone;
    //  FormStyle :=fsStayOnTop;
      Left :=0;
      Top :=0;
      Height :=Screen.Height;
      Width :=Screen.Width;
    end;
  END //FINALLY    end;
end;
procedure restaurar_pantalla_completa();
var
  HTaskbar : HWND;
  OldVal : LongInt;
begin
    HTaskBar:=FindWindow('Shell_TrayWnd',nil );
    SystemParametersInfo (97, Word (False), @OldVal, 0); //solo en Win 95/98/ME
    EnableWindow(HTaskBar,True);
    ShowWindow(HTaskbar,SW_SHOW);
end;
procedure TMain.FormClick(Sender: TObject);
begin
        //Esconde todos los menus.
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel8MouseEnter(Sender: TObject);
begin
        //Muestra Menu Ventas
        MVentas.Show;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel9MouseEnter(Sender: TObject);
begin
        //Muestra Menu Compras
        MVentas.Hide;
        MCompras.Show;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel10MouseEnter(Sender: TObject);
begin
        //Muestra Menu  Cuentas Por Cobrar
        MCC.Show;
        MVentas.Hide;
        MCompras.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel11MouseEnter(Sender: TObject);
begin
        //Muestra Menu Cuentas Por Pagar
        MCP.Show;
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel12MouseEnter(Sender: TObject);
begin
        //Muestra Menu Reportes
        MReportes.Show;
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel13MouseEnter(Sender: TObject);
begin
        //Muestra Menu Utilidades
        MUtilidades.Show;
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel14MouseEnter(Sender: TObject);
begin
        //Muestra Menu Inventarios
        MInventario.Show;
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
end;
procedure TMain.LMDSimplePanel15MouseEnter(Sender: TObject);
begin
        //Esconde todos los menus
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LMDSimplePanel16MouseEnter(Sender: TObject);
begin
        //Esconde todos los menus
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LogoQSClick(Sender: TObject);
begin
        //Esconde todos los menus
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.LetrasLPClick(Sender: TObject);
begin
        //Esconde todos los menus
        MVentas.Hide;
        MCompras.Hide;
        MCC.Hide;
        MCP.Hide;
        MReportes.Hide;
        MUtilidades.Hide;
        MInventario.Hide;
end;
procedure TMain.FormCreate(Sender: TObject);
var
  stSystemTime : TSystemTime;
begin
  Windows.GetLocalTime( stSystemTime );
  Hora.Caption := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
  pantalla_completa();
end;
procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  restaurar_pantalla_completa();
end;
procedure TMain.BVentasClick(Sender: TObject);
begin
        //Crea y abre la ventana de ventas en modo Hija.
        if venta = nil then
        begin
              venta := TVenta.Create(self);
              venta.FormStyle := fsMDIChild;
              venta.Left :=0;
              venta.Top :=0;
              venta.Width:=Screen.Width-15;
              venta.Height:= Screen.Height-50;
              venta.Parent     :=  self;
        end;
        venta.Show;
end;
procedure TMain.BComprasClick(Sender: TObject);
begin
//Pendientes todas las formas
        Compra.Show;
end;
procedure TMain.AbreCotizacion();
begin
        Cotizacion.Show;
end;

End.
 
 
 
// Ventana Hija.
 
 
unit Ventas;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, LMDControl, LMDBaseControl, LMDBaseGraphicButton,
  LMDCustom3DButton, LMD3DEffectButton, LMDCustomControl, LMDCustomPanel,
  LMDCustomBevelPanel, LMDSimplePanel, StdCtrls, LMDCustomShapeButton,
  LMDShapeButton, Grids;
type
  TVenta = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Bevel1: TBevel;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Bevel3: TBevel;
    Bevel4: TBevel;
    Image4: TImage;
    LabeledEdit3: TLabeledEdit;
    LabeledEdit4: TLabeledEdit;
    LabeledEdit5: TLabeledEdit;
    LabeledEdit6: TLabeledEdit;
    LabeledEdit7: TLabeledEdit;
    LMDShapeButton1: TLMDShapeButton;
    StringGrid1: TStringGrid;
    LabeledEdit8: TLabeledEdit;
    LMDShapeButton2: TLMDShapeButton;
    LabeledEdit9: TLabeledEdit;
    LabeledEdit10: TLabeledEdit;
    LabeledEdit11: TLabeledEdit;
    LMDShapeButton3: TLMDShapeButton;
    LMDShapeButton4: TLMDShapeButton;
    LabeledEdit12: TLabeledEdit;
    LMDShapeButton5: TLMDShapeButton;
    procedure LMDShapeButton4Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Venta: TVenta;
implementation
uses Principal;
{$R *.dfm}

procedure TVenta.LMDShapeButton4Click(Sender: TObject);
begin
        Close;
end;
procedure TVenta.FormClose(Sender: TObject; var Action: TCloseAction);
begin   
        Action := caFree;
        Venta := nil;
end;
end.

aun asi no funciona cambiando el action a la parte de abajo.

espero que me puedan ayudar.

Última edición por roman fecha: 02-05-2008 a las 03:36:53. Razón: Añadir etiqueta [delphi]
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Busco un consejo (muchas ventanas hijas y muchos menús) ixMike Varios 9 14-09-2006 11:23:34
Recorrido de ventanas hijas sur-se OOP 3 23-08-2004 11:43:10
La señora y sus hijas roman Humor 24 28-05-2004 19:46:20
Ventanas MDI Hijas LucianoRey OOP 4 25-02-2004 01:28:32
Problemas con formas Hijas (MDI Child) D.M Varios 1 10-09-2003 22:56:30


La franja horaria es GMT +2. Ahora son las 03:40:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi