Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Formulario Transparente Visual Basic

Estas en el tema de Formulario Transparente Visual Basic en el foro de Visual Basic clásico en Foros del Web. Como puedo hacer que un formulario sea transparente pero ke los controlos que contengan sean no lo sean...
  #1 (permalink)  
Antiguo 27/03/2004, 15:45
 
Fecha de Ingreso: marzo-2004
Ubicación: culiacan sinaloa mexico
Mensajes: 4
Antigüedad: 20 años, 1 mes
Puntos: 0
Formulario Transparente Visual Basic

Como puedo hacer que un formulario sea transparente pero ke los controlos que contengan sean no lo sean
  #2 (permalink)  
Antiguo 27/03/2004, 23:37
Avatar de Mickel  
Fecha de Ingreso: mayo-2002
Ubicación: Lima, Peru
Mensajes: 4.619
Antigüedad: 22 años
Puntos: 7
Recuerdo haber visto ese truco en http://guille.costasol.net
__________________
No tengo firma ahora... :(
  #3 (permalink)  
Antiguo 09/04/2005, 10:28
Avatar de jariza  
Fecha de Ingreso: agosto-2003
Ubicación: Málaga
Mensajes: 1.449
Antigüedad: 20 años, 8 meses
Puntos: 10
Hola

El enlace que das no me funciona, ¿conoceis alguna alternativa?

Muchas gracias
  #4 (permalink)  
Antiguo 09/04/2005, 12:37
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Este codigo funciona solo si el BorderStyle del form es 0... En un modulo:

Option Explicit
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Const RGN_XOR = 3

Public Sub MakeTransparent(TransForm As Form)
Dim ErrorTest As Double
On Error Resume Next
Dim Regn As Long
Dim TmpRegn As Long
Dim TmpControl As Control
Dim LinePoints(4) As POINTAPI
TransForm.ScaleMode = 3
If TransForm.BorderStyle <> 0 Then MsgBox "Change the borderstyle to 0!", vbCritical, "ACK!": End
Regn = CreateRectRgn(0, 0, 0, 0)
For Each TmpControl In TransForm
If TypeOf TmpControl Is Line Then
If Abs((TmpControl.Y1 - TmpControl.Y2) / (TmpControl.X1 - TmpControl.X2)) > 1 Then
LinePoints(0).X = TmpControl.X1 - 1
LinePoints(0).Y = TmpControl.Y1
LinePoints(1).X = TmpControl.X2 - 1
LinePoints(1).Y = TmpControl.Y2
LinePoints(2).X = TmpControl.X2 + 1
LinePoints(2).Y = TmpControl.Y2
LinePoints(3).X = TmpControl.X1 + 1
LinePoints(3).Y = TmpControl.Y1
Else
LinePoints(0).X = TmpControl.X1
LinePoints(0).Y = TmpControl.Y1 - 1
LinePoints(1).X = TmpControl.X2
LinePoints(1).Y = TmpControl.Y2 - 1
LinePoints(2).X = TmpControl.X2
LinePoints(2).Y = TmpControl.Y2 + 1
LinePoints(3).X = TmpControl.X1
LinePoints(3).Y = TmpControl.Y1 + 1
End If
TmpRegn = CreatePolygonRgn(LinePoints(0), 4, 1)
ElseIf TypeOf TmpControl Is Shape Then
If TmpControl.Shape = 0 Then
TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height)
ElseIf TmpControl.Shape = 1 Then
If TmpControl.Width < TmpControl.Height Then
TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2, TmpControl.Left + TmpControl.Width, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width)
Else
TmpRegn = CreateRectRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2, TmpControl.Top, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height, TmpControl.Top + TmpControl.Height)
End If
ElseIf TmpControl.Shape = 2 Then
TmpRegn = CreateEllipticRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width + 0.5, TmpControl.Top + TmpControl.Height + 0.5)
ElseIf TmpControl.Shape = 3 Then
If TmpControl.Width < TmpControl.Height Then
TmpRegn = CreateEllipticRgn(TmpControl.Left, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2, TmpControl.Left + TmpControl.Width + 0.5, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width + 0.5)
Else
TmpRegn = CreateEllipticRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2, TmpControl.Top, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height + 0.5, TmpControl.Top + TmpControl.Height + 0.5)
End If
ElseIf TmpControl.Shape = 4 Then
If TmpControl.Width > TmpControl.Height Then
TmpRegn = CreateRoundRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width + 1, TmpControl.Top + TmpControl.Height + 1, TmpControl.Height / 4, TmpControl.Height / 4)
Else
TmpRegn = CreateRoundRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width + 1, TmpControl.Top + TmpControl.Height + 1, TmpControl.Width / 4, TmpControl.Width / 4)
End If
ElseIf TmpControl.Shape = 5 Then
If TmpControl.Width > TmpControl.Height Then
TmpRegn = CreateRoundRectRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2, TmpControl.Top, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height + 1, TmpControl.Top + TmpControl.Height + 1, TmpControl.Height / 4, TmpControl.Height / 4)
Else
TmpRegn = CreateRoundRectRgn(TmpControl.Left, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2, TmpControl.Left + TmpControl.Width + 1, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width + 1, TmpControl.Width / 4, TmpControl.Width / 4)
End If
End If
If TmpControl.BackStyle = 0 Then
CombineRgn Regn, Regn, TmpRegn, RGN_XOR
If TmpControl.Shape = 0 Then
TmpRegn = CreateRectRgn(TmpControl.Left + 1, TmpControl.Top + 1, TmpControl.Left + TmpControl.Width - 1, TmpControl.Top + TmpControl.Height - 1)
ElseIf TmpControl.Shape = 1 Then
If TmpControl.Width < TmpControl.Height Then
TmpRegn = CreateRectRgn(TmpControl.Left + 1, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + 1, TmpControl.Left + TmpControl.Width - 1, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width - 1)
Else
TmpRegn = CreateRectRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + 1, TmpControl.Top + 1, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height - 1, TmpControl.Top + TmpControl.Height - 1)
End If
ElseIf TmpControl.Shape = 2 Then
TmpRegn = CreateEllipticRgn(TmpControl.Left + 1, TmpControl.Top + 1, TmpControl.Left + TmpControl.Width - 0.5, TmpControl.Top + TmpControl.Height - 0.5)
ElseIf TmpControl.Shape = 3 Then
If TmpControl.Width < TmpControl.Height Then
TmpRegn = CreateEllipticRgn(TmpControl.Left + 1, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + 1, TmpControl.Left + TmpControl.Width - 0.5, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width - 0.5)
Else
TmpRegn = CreateEllipticRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + 1, TmpControl.Top + 1, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height - 0.5, TmpControl.Top + TmpControl.Height - 0.5)
End If
ElseIf TmpControl.Shape = 4 Then
If TmpControl.Width > TmpControl.Height Then
TmpRegn = CreateRoundRectRgn(TmpControl.Left + 1, TmpControl.Top + 1, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height, TmpControl.Height / 4, TmpControl.Height / 4)
Else
TmpRegn = CreateRoundRectRgn(TmpControl.Left + 1, TmpControl.Top + 1, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height, TmpControl.Width / 4, TmpControl.Width / 4)
End If
ElseIf TmpControl.Shape = 5 Then
If TmpControl.Width > TmpControl.Height Then
TmpRegn = CreateRoundRectRgn(TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + 1, TmpControl.Top + 1, TmpControl.Left + (TmpControl.Width - TmpControl.Height) / 2 + TmpControl.Height, TmpControl.Top + TmpControl.Height, TmpControl.Height / 4, TmpControl.Height / 4)
Else
TmpRegn = CreateRoundRectRgn(TmpControl.Left + 1, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + 1, TmpControl.Left + TmpControl.Width, TmpControl.Top + (TmpControl.Height - TmpControl.Width) / 2 + TmpControl.Width, TmpControl.Width / 4, TmpControl.Width / 4)
End If
End If
End If
Else
TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height)
End If
ErrorTest = 0
ErrorTest = TmpControl.Width
If ErrorTest <> 0 Or TypeOf TmpControl Is Line Then
CombineRgn Regn, Regn, TmpRegn, RGN_XOR
End If
Next TmpControl
SetWindowRgn TransForm.hwnd, Regn, True
End Sub

En el form:

Private Declare Function ReleaseCapture Lib "user32" () As Long
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 Const WM_SYSCOMMAND = &H112

Private Sub Form_Load()
MakeTransparent frmTrans
End Sub
__________________
ホルヘ・ラファエル・マルティネス・レオン
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:04.