Buenas gente
Les queria preguntar una cosita, estoy seguro que me podran ayudar...
Estoy armando algo simple en vb6.0 y me gustaria poner un formulario sin el fondo, osea que si pongo un boton se vea "en el aire" y detras se muestre lo que hay de fondo...ya sea el escritorio o lo que tenga detras del form...
se entendio? ::)
saludos y gracias.
http://www.vbforums.com/showthread.php?413218-VB6-Glass-Form
Un efecto Glass (por cierto, muy bueno) para lograr lo que pides.
Saludos.
Hola,
Este sencillo código sirve para transparentar totalmente un color determiando ya sea del formulario o de un objeto cualquiera que esté dentro del formulario. He establecido la propiedad Backcolor del formulario a vbRed y por lo tanto toda la parte interna del formulario se verá transparente al 100%. He utilizado el Rojo pero puedes usar cualquier color.
Option Explicit
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Public Function TransparentarColor(ByVal hwnd As Long, Color As Long) As Long
On Error Resume Next
SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, Color, 0, &H1
End Function
Private Sub Form_Load()
Me.BackColor = vbRed
Call TransparentarColor(Me.hwnd, vbRed)
End Sub
Añado este código de más como muestra de la utilidad que tiene el código para crear formularios personalizados.
(https://s25.postimg.org/f53zwfkzz/Form_Personalized1.jpg)
(https://s25.postimg.org/qvhxdtdsf/Form_Personalized2.jpg)
Option Explicit
'Mover formulario sin barra
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Public Function TransparentarColor(ByVal hwnd As Long, Color As Long) As Long
On Error Resume Next
SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, Color, 0, &H1
End Function
Private Sub Form_Load()
Me.BackColor = vbRed
Call TransparentarColor(Me.hwnd, vbRed)
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Z As Long
If Button = 1 Then
ReleaseCapture
Z = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Y el proyecto lo puedes descargar aquí.
Form_Personalized.zip
(https://mega.nz/#!uEt3QAab!pSaFOmYGDVDKgX1A2RyXWagxRu5FIVybU2aSLMlR1Q4)
Muchas gracias okik por tomarte el tiempo y dejarme esos codes!
Ya logre solucionarlo gracias a ustedes..
Saludos y gracias!.