Hola, con el ejemplo que pego mas abajo si tengo un objeto Picture en el formulario anda bien, pero quiero hacer lo mismo sin el objeto en el formulario. Es decir quiero crear este objeto Picture desde el código (no sé cómo hacerlo).
Código:
Dim Ancho As Single, Alto As Single, Porcentaje As Single
Dim Imagen As Picture
Private Sub Command1_Click()
mshflexgrid1.ColWidth(1) = 1600
Set Imagen = LoadPicture(App.Path & "\prueba.jpg")
Ancho = Imagen.Width
Alto = Imagen.Height
PIMUESTRA.AutoRedraw = True
MostrarImagen
Set mshflexgrid1.CellPicture = PIMUESTRA.Image
End Sub
Private Sub MostrarImagen()
Dim centro1 As Single, centro2 As Single
PIMUESTRA.Cls
If Ancho <> PIMUESTRA.Width Or Alto <> PIMUESTRA.Height Then
If Ancho > Alto Then
Porcentaje = (PIMUESTRA.Width * 100) / Ancho
Else
Porcentaje = (PIMUESTRA.Height * 100) / Alto
End If
End If
Ancho = (Ancho * Porcentaje) / 100
Alto = (Alto * Porcentaje) / 100
centro1 = (PIMUESTRA.Width - Ancho) / 2
centro2 = (PIMUESTRA.Height - Alto) / 2
PIMUESTRA.PaintPicture Imagen, centro1, centro2, Ancho, Alto
End Sub
Gracias desde ya por las respuestas.
Saludos