Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 12-04-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola JuniorSoft.

La idea que te propongo es agrupar la creación del MDIChild y del ToolButton correspondiente como hago en este ejemplo simplificado, que usa un TToolBar un TPanel (alBottom) y dentro de él tres TButton.
Código Delphi [-]
type
  TfrmMain = class(TForm)
  ... 
  private
    FChildTags: Integer;
    procedure OpenMDIChild(AClass: TFormClass; const btnCaption: string; aAction: TAction );
  public
    property ChildTag: Integer read FChildTags;
    procedure DeleteToolButton(const TagButton: Integer);
  end;
...
implementation
uses Unit2, Unit3, Unit4; // MDIChilds

procedure TfrmMain.FormCreate(Sender: TObject);
begin
  FChildTags := 1; // p
end;


// Crear-Mostrar MDIChilds
procedure TfrmMain.OpenMDIChild(AClass: TFormClass; const btnCaption: string; aAction: TAction);
var
  i, inx: Integer;
  nb: TToolButton;
begin
  for i:= MDIChildCount-1 downto 0 do
    if MDIChildren[i] is AClass then
    begin
      if MDIChildren[i].WindowState = wsMinimized then
        MDIChildren[i].WindowState:= wsNormal;
      MDIChildren[i].BringToFront;
      Exit;
    end;

  with AClass.Create(Self) do
  begin
    Tag           := FChildTags;
    nb            := TToolButton.Create(ToolBar1);
    nb.Height     := ImageList1.Height;
    nb.Width      := ImageList1.Width;
    nb.Caption    := btnCaption;
    inx           := ToolBar1.ButtonCount - 1;
    if inx > -1 then
      nb.Left := ToolBar1.Buttons[inx].Left + ToolBar1.Buttons[inx].Width
    else
      nb.Left := 0;
    nb.Action := aAction;
    nb.Parent := ToolBar1;
    nb.Tag    := ChildTag;
    //...
    Inc(FChildTags);
  end;
end;

// Eliminar ToolButton
procedure TfrmMain.DeleteToolButton(const TagButton: Integer);
var
  i: Integer;
begin
  for i:= ToolBar1.ButtonCount-1 downto 0 do
    if ToolBar1.Buttons[i].Tag = TagButton then
      ToolBar1.Buttons[i].Free;
end;

// Llamada crear-mostrar MDIChilds
procedure TfrmMain.btnChild1Click(Sender: TObject);
begin
  OpenMDIChild(TChild1, 'Child1', TAction(ActionList1.Actions[0]));
end;

procedure TfrmMain.btnChild2Click(Sender: TObject);
begin
  OpenMDIChild(TChild2, 'Child2', TAction(ActionList1.Actions[1]));
end;

procedure TfrmMain.btnChild3Click(Sender: TObject);
begin
  OpenMDIChild(TChild3, 'Child3', TAction(ActionList1.Actions[2]));
end;

// Acciones de ejemplo
procedure TfrmMain.Action1Execute(Sender: TObject);
begin
  ShowMessage(TToolButton(Sender).Name);
end;

procedure TfrmMain.Action2Execute(Sender: TObject);
begin
  ShowMessage(TToolButton(Sender).Name);
end;

procedure TfrmMain.Action3Execute(Sender: TObject);
begin
  ShowMessage(TToolButton(Sender).Name);
end;
...

Salida:


Como verás es sólo un ejemplo orientativo, si nos explicas mas detalladamente la situación, tal vez lo podamos ajustar.

Saludos

Pd: Te ajunto los archivos fuentes de la prueba.
Archivos Adjuntos
Tipo de Archivo: zip junior.zip (14,4 KB, 5 visitas)
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
 


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
Ventanas mdi hijas en cascada.. lbidi Varios 1 14-04-2011 17:25:30
Cómo hacer que se creen nuevos objetos cada vez? gerupc Varios 2 31-12-2007 00:55:44
Ventanas Hijas en Aplicacion MDI Esau OOP 6 06-11-2007 18:23:56
Recorrido de ventanas hijas sur-se OOP 3 23-08-2004 11:43:10
Ventanas MDI Hijas LucianoRey OOP 4 25-02-2004 01:28:32


La franja horaria es GMT +2. Ahora son las 14:05:39.


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