Autor Tema: Autoajustar Imagen de un CommandButton evento resize  (Leído 3911 veces)

0 Usuarios y 1 Visitante están viendo este tema.

el_trocha

  • Kilobyte
  • **
  • Mensajes: 62
  • Reputación: +1/-2
    • Ver Perfil
Autoajustar Imagen de un CommandButton evento resize
« en: Octubre 04, 2011, 02:46:52 pm »
Hola Amigos tengo un resize hecho y que funciona perfectamente para la mayoria de controles.

Pero con los botones en modo grafico y que contienen imagenes no me funciona del todo bien.

ES decir con el evento resize, el boton se hace garnde o pequeño dependiendo del formulario.

El problema es que la imagen que contiene el boton en su Style grafico pues se queda siempre igual.

hay algun modo de hacer que la imagen del boton crezca o se reduzca al mismo tiempo que pasa con el boton ???

ya probe con esto y nada:

Boton1.Picture.Height = Boton1.Height
Boton1.Picture.Width = Boton1.Width

Muchas Gracias

Un saludito a todos

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:Autoajustar Imagen de un CommandButton evento resize
« Respuesta #1 en: Octubre 04, 2011, 03:07:18 pm »
hola creo que lo mejor seria utilizando un PictureBox para poder ajustar la imagen, la imagen la debe contener el PictureBox, no es un método muy recomendable pero...

Código: [Seleccionar]

Option Explicit

Private Sub Form_Load()
    With Picture1
        .AutoRedraw = True
        .BorderStyle = 0
        .Visible = False
    End With
       
End Sub

Private Sub Form_Resize()
    Command1.Move 100, 100, (Me.ScaleWidth / 5), (Me.ScaleHeight / 5)
    Picture1.Move 0, 0, Command1.Width, Command1.Height
    Picture1.Cls
    Picture1.PaintPicture Picture1.Picture, 0, 0, Command1.Width, Command1.Height
    Command1.Picture = Picture1.Image
End Sub


ENOKSAJU

  • Bit
  • Mensajes: 1
  • Reputación: +0/-0
    • Ver Perfil
Re:Autoajustar Imagen de un CommandButton evento resize
« Respuesta #2 en: Abril 20, 2015, 11:17:27 am »
PODRIAS HACERLO ASI, TOMO COMO REFERENCIA LA RESPUESTA ANTERIOR


Private Sub Form_Load()
HScr = Screen.Width / Screen.TwipsPerPixelX
VScr = Screen.Height / Screen.TwipsPerPixelY
VFactor = VScr / 750
HFactor = HScr / 1000
'Factor = HScr / 800
NoCambiar = True
Me.Width = Me.Width * HFactor
Me.Height = Me.Height * VFactor
NoCambiar = False
End Sub

Private Sub Form_Resize()
Dim ctl As Control
On Error Resume Next
If NoCambiar Then Exit Sub
For Each ctl In Form1
ctl.Top = ctl.Top * VFactor
ctl.Height = ctl.Height * VFactor
ctl.Left = ctl.Left * HFactor
ctl.Width = ctl.Width * HFactor
ctl.FontSize = ctl.FontSize * VFactor
    If ctl.Picture Then
    IMAGE3.Move 0, 0, ctl.Width * 0.6, ctl.Height * 0.6
    IMAGE3.Picture = LoadPicture("")
    IMAGE3.Refresh
    IMAGE3.PaintPicture ctl.Picture, 0, 0, ctl.Width * 0.6, ctl.Height * 0.6
    ctl.Picture = IMAGE3.Image
    End If
Next
NoCambiar = True
 
End Sub