Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-02-2009
astwin astwin is offline
Miembro
 
Registrado: feb 2009
Posts: 21
Poder: 0
astwin Va por buen camino
Problema de objeto que hereda de Timage

Hola, estoy creando un programa que se encarga de interconexionar bloques. Estoy intentando que en un Tpanel pueda tener los bloques que serviran para su interconexion (en el se podran mover libremente los bloques). Cada bloque tiene una imagen.

Tengo dos codigos hechos, el primero que funciona bien (con la imagen como objeto dentro de una clase) y otro que no funciona (no aparece la imagen en el Tpanel; esta hecha heredando de timage)

Funciona: la imagen se ve sobre el Tpanel
Código Delphi [-]
type TgraphBlock=class
  public
    image: Timage;
    pIn,pOut: array of Tpoint;
    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
    function isIn(p:Tpoint):integer;
    function isOut(p:Tpoint):integer;
    procedure imageDragOver(Sender, Source: TObject; X, Y: Integer;
                            State: TDragState; var Accept: Boolean);
    procedure imageDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure imageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

end;

Type BlockA=class(TgraphBlock)
  public
    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
end;

Type BlockB=class(TgraphBlock)
  public
    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
end;
////////////////////////////////////////////////////////////////////////////
Constructor TgraphBlock.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  // Creamos el objeto imagen
  image:=TImage.Create(parent);

  Form1.ImageList1.GetBitmap(img,image.Picture.bitmap);
  image.Left:=pos.X;
  image.Top:=pos.Y;
  image.AutoSize:=true;
  image.Visible:=true;
  image.BringToFront;
  image.Parent:=parent;
  image.OnDragOver:=ImageDragOver;
  image.OnDragDrop:=ImageDragDrop;
  image.onMouseDown:=ImageMouseDown ;
end;

Constructor BlockA.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  Inherited Create(img,parent,pos);
  setlength(pIn,2);
  setlength(pOut,1);
  pIn[0].X:=1 ;
  pIn[0].Y:=14 ;
  pIn[1].X:=1 ;
  pIn[1].Y:=32 ;
  pOut[0].X:=72 ;
  pOut[0].Y:=22 ;
end;

Constructor BlockB.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  Inherited Create(img,parent,pos);
  setlength(pIn,1);
  setlength(pOut,1);
  pIn[0].X:=1 ;
  pIn[0].Y:=22 ;
  pOut[0].X:=72 ;
  pOut[0].Y:=22 ;
end;

No funciona: la imagen no se ve sobre el Tpanel
Código Delphi [-]
type TgraphBlock=class(Timage)
  public
    pIn,pOut: array of Tpoint;
    lineaIn: array of Tlinea;
    lineaOut: array of array of Tlinea;

    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
    function isIn(p:Tpoint):integer;
    function isOut(p:Tpoint):integer;
    procedure imageDragOver(Sender, Source: TObject; X, Y: Integer;
                            State: TDragState; var Accept: Boolean);
    procedure imageDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure imageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

end;

Type BlockA=class(TgraphBlock)
  public
    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
end;

Type BlockB=class(TgraphBlock)
  public
    Constructor Create(img:integer;parent:TWinControl;pos:Tpoint);
end;
///////////////////////////////////////////////////////////////////
Constructor TgraphBlock.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  inherited create(parent);
  Parent:=parent;
  Form1.ImageList1.GetBitmap(img,Picture.bitmap);
  Left:=pos.X;
  Top:=pos.Y;
  AutoSize:=true;
  Visible:=true;
  BringToFront;

  OnDragOver:=ImageDragOver;
  OnDragDrop:=ImageDragDrop;
  onMouseDown:=ImageMouseDown ;
end;

Constructor BlockA.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  Inherited Create(img,parent,pos);
  setlength(pIn,2);
  setlength(pOut,1);
  pIn[0].X:=1 ;
  pIn[0].Y:=14 ;
  pIn[1].X:=1 ;
  pIn[1].Y:=32 ;
  pOut[0].X:=72 ;
  pOut[0].Y:=22 ;
  // Inicializamos lineas entrada y salida
  setlength(lineaIn,2); // Tantas lineas de entrada como entradas
  setlength(lineaOut,1,0); // Una dimension la salida
end;

Constructor BlockB.Create(img:integer;parent:TWinControl;pos:Tpoint);
begin
  Inherited Create(img,parent,pos);
  setlength(pIn,1);
  setlength(pOut,1);
  pIn[0].X:=1 ;
  pIn[0].Y:=22 ;
  pOut[0].X:=72 ;
  pOut[0].Y:=22 ;
  // Inicializamos lineas entrada y salida
  setlength(lineaIn,1); // Tantas lineas de entrada como entradas
  setlength(lineaOut,1,0); // Una dimension la salida
end;


Si pudierais ayudarme os estaria muy agradecido.
Responder Con Cita
 



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
Cargar imagen en Un TImage guardada en campo Blob o Objeto OLE en accsess gulder Varios 1 28-11-2008 18:54:43
Problema con Timage JerS Varios 12 26-06-2008 19:12:49
Responder a un click en un objeto (tImage) mostrado en un tStatusBar sitrico OOP 4 16-06-2006 21:34:39
Clase que hereda de TForm rocio84 OOP 3 29-10-2005 12:54:27
Problema con un TImage Jan_polero Gráficos 1 29-11-2004 23:15:11


La franja horaria es GMT +2. Ahora son las 07:40:51.


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