Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/06/2006, 16:55
alberanonn
 
Fecha de Ingreso: febrero-2005
Mensajes: 28
Antigüedad: 19 años, 3 meses
Puntos: 1
Este es el código que soluciona el problema

Option Explicit
Dim ancho As Single, alto As Single, porcentaje As Single
Dim imagen As IPictureDisp

Private Sub Command1_Click()
Picture1.Cls
Set imagen = LoadPicture("I:\System\Easy Plantillas\1724000001.bmp")



ancho = imagen.Width
alto = imagen.Height

If ancho > Picture1.Width Or alto > Picture1.Height Then
If ancho > alto Then
porcentaje = (Picture1.Width * 100) / ancho
Else
porcentaje = (Picture1.Height * 100) / alto
End If
CentrarPicture
Exit Sub
End If

If ancho <= Picture1.Width Or alto <= Picture1.Height Then
If ancho > alto Then
porcentaje = (Picture1.Width * 100) / ancho
Else
porcentaje = (Picture1.Width * 100) / alto
End If
CentrarPicture
End If
End Sub


Public Sub CentrarPicture()
Dim centro1 As Single, centro2 As Single
ancho = (ancho * porcentaje) / 100
alto = (alto * porcentaje) / 100
centro1 = (Picture1.Width - ancho) / 2
centro2 = (Picture1.Height - alto) / 2
Picture1.PaintPicture imagen, centro1, centro2, ancho, alto
End Sub