Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/01/2007, 15:46
ci2000
 
Fecha de Ingreso: abril-2005
Mensajes: 483
Antigüedad: 19 años, 1 mes
Puntos: 3
Crear objeto Picture en tiempo de ejecución

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