Ver Mensaje Individual
  #2  
Antiguo 21-10-2006
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Reputación: 19
Deiv Va por buen camino
Después de darle tanta vuelta al asunto he alcanzado responder a mi pregunta en un 90% creando un BitMap temporal, según el código de abajo, Cuando corro la aplicación y hago click en el primer botón funciona (me muestra un elemento de la primera fila), pero el segundo botón no me muestra nada!

De nuevo vuelvo a correr la aplicación y hago click pero esta vez en el segundo botón funciona (me muestra sí un elemento de la segunda fila) pero ahora el primer botón no me muestra nada!

¿A que se debe todo esto?

Código Delphi [-]
 
implementation
var
  Bitmap, tempBmp: TBitmap;
  DestRect, SrcRect: TRect;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin  //tempBmp contiene la primera fila del Bitmap
   tempBmp.Width := BitMap.Width;
   tempBmp.Height := Bitmap.Height div 2;
   DestRect := RECT(0,0,tempBmp.Width-1, tempBmp.Height-1);
   SrcRect:=DestRect;
   tempBmp.Canvas.CopyRect(DestRect, BitMap.Canvas, SrcRect);
   ImageList1.Width:= Bitmap.Width div 10;
   ImageList1.Height:= tempBmp.Height;
   ImageList1.AddMasked(tempBmp, tempBmp.Canvas.Pixels[0,0]);
   ImageList1.Draw(PaintBox1.Canvas,0,0,1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin //tempBmp contiene la segunda fila del Bitmap
   tempBmp.Width := BitMap.Width;
   tempBmp.Height := Bitmap.Height div 2;
   DestRect := RECT(0,0,tempBmp.Width-1, tempBmp.Height-1);
   SrcRect:=DestRect;
   SrcRect.Top := tempBmp.Height;
   SrcRect.Bottom := Bitmap.Height-1;
   tempBmp.Canvas.CopyRect(DestRect, BitMap.Canvas, SrcRect);
   ImageList1.Width:= Bitmap.Width div 10;
   ImageList1.Height:= tempBmp.Height;
   ImageList1.AddMasked(tempBmp, tempBmp.Canvas.Pixels[0,0]);
   ImageList1.Draw(PaintBox1.Canvas,0,0,2);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Bitmap:= TBitmap.Create;
  tempBmp:= TBitmap.Create;
  BitMap.LoadFromFile(getcurrentdir+'/Doble.BMP');
  ImageList1.BkColor:=clNone;
  ImageList1.BlendColor:= clNone;
  ImageList1.DrawingStyle:= dsTransparent;
  ImageList1.Masked:= True;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Bitmap.Free;
  tempBmp.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
  PaintBox1.Canvas.Fillrect(PaintBox1.Canvas.ClipRect); //Borra el Canvas
end;
end.
Luego para corregir este problema, he creado un tercer botón para el borrado del Canvas. En el código de arriba al hacer click en el primer botón dibuja bien, luego click en el tercer botón y borra el Canvas; pero cuando click en el segundo botón me vuelve a mostrar el mismo elemento de la primera fila, y no el elemento de la segunda fila.

¿Cómo corregir este problema? Por favor.
Responder Con Cita