PDA

Ver la Versión Completa : Botones Transparentes en Visual Basic


LmB
29-Jun-2009, 01:56
Dentro de nuestro proyecto creamos un nuevo modulo.

Name: Mod_Trans

Adentro colocamos:

Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex AsLong) As Long

Private Pic As PictureBox


Sub Aplicar_TRansparencia(ByVal Cmd As CommandButton, f As) Form

Dim Ancho As Single, Alto As Single
Dim xo As Single, yo As Single


If Pic Is Nothing Then

Set Pic = f.Controls.Add("Vb.PictureBox", "UnPicture")


With Pic
.BorderStyle = vbBSNone
.AutoRedraw = True
.Visible = False
End With

End If

Ancho = Cmd.Width
Alto = Cmd.Height + f.TextHeight(Cmd.Caption) * 2


xo = GetSystemMetrics(7)
yo = GetSystemMetrics(8)

With Pic

.Move 0, 0, Ancho, Alto

.PaintPicture f.Picture, 0, 0, Ancho, Alto, Cmd.Left + xo, _
Cmd.Top + yo, Ancho, Alto
.Picture = .Image

Cmd.Picture = .Picture

End With
End Sub


Private Sub Form_Unload(Cancel As Integer)
Set Pic = Nothing
End Sub


Si quieren aplicarle la transparencia a un Command Button, hacen lo siguiente:

En el formulario donde tengan ese CommandButton ponen lo siguiente adentro del codigo.

Private sub form_load()
Call Aplicar_TRansparencia(NombredeCommandButton, Me)
end sub





El Command button debe tener la propiedad Style = Graphical.

Saludos.