Ver Mensaje Individual
  #1  
Antiguo 23-11-2008
Avatar de The_Duke
The_Duke The_Duke is offline
Miembro
 
Registrado: abr 2006
Ubicación: Republica Dominicana
Posts: 48
Reputación: 0
The_Duke Va por buen camino
Question Como centrar una imagen en un timage con un click

Hola le explico estoy haciendo un visor de imagen y al hacer zoom, necesito que si le hacen click con el mouse se centre la zona donde se izo el click, hago el zoom así:

Código Delphi [-]
procedure TForm1.Image1Click(Sender: TObject);
var
re1, re2: integer;
begin
zoom:=zoom+1;
re1:=round(Image1.Width*6/100);
re2:=round(Image1.Height*6/100);
Image1.Width:=Image1.Width+re1;
Image1.Height:=Image1.Height+re2;
sScrollBox1.VertScrollBar.Visible:=true;
sScrollBox1.HorzScrollBar.Visible:=true;
zoom:=zoom+1;
Image1.Stretch:=true;
ajustar;
end;

y el ajustar es:

Código Delphi [-]
procedure TForm1.ajustar;
begin
sScrollBox1.VertScrollBar.Margin:=Image1.Height;
sScrollBox1.HorzScrollBar.Margin:=Image1.Width;
if (Image1.Width>Form1.Width) and (Image1.Height>Form1.Height) then
  begin
    Image1.Left :=1;
    Image1.Top :=1;
  end
else
  if (Image1.Width>Form1.Width) and (Image1.Heightthen
     begin
       Image1.Left :=1;
       Image1.Top := (Form1.Height div 2) - (Image1.Height div 2);
      end
 else
   if (Image1.Widthand (Image1.Height>Form1.Height) then
       begin
         Image1.Left := (Form1.Width div 2) - (Image1.Width div 2);
         Image1.Top := 1;
       end
     else
        if (Image1.Widthand (Image1.Heightthen
       begin
           Image1.Left := (Form1.Width div 2) - (Image1.Width div 2);
           Image1.Top := (Form1.Height div 2) - (Image1.Height div 2);
       end;
end;
Responder Con Cita