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

Problema con fondo transparente de formulario y de boton flash insertado en VB

Estas en el tema de Problema con fondo transparente de formulario y de boton flash insertado en VB en el foro de Visual Basic clásico en Foros del Web. Hola, tengo un formulario al que le hice el fondo transparente de esta manera: Cree un modulo e introduje este codigo: Código: Option Explicit Private ...
  #1 (permalink)  
Antiguo 21/05/2006, 15:12
Avatar de elias77  
Fecha de Ingreso: noviembre-2005
Ubicación: Buscame...
Mensajes: 1.051
Antigüedad: 18 años, 5 meses
Puntos: 11
Problema con fondo transparente de formulario y de boton flash insertado en VB

Hola, tengo un formulario al que le hice el fondo transparente de esta manera:
Cree un modulo e introduje este codigo:

Código:
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
Luego en el form load puse esto:

Código:
MakeTransparent frmTrans
Luego le puse la propiedad border style en None

Y perfecto el form transparente...

Pero el problema es que despues inserte un boton hecho en flash y en la propiedad "Personalizado" en donde dise "Modo de" le puse "Transparent" y resulta que no se hace transparente el fondo de lo que haya insertado de flash cuando el form tambien es transparente...solo queda el form tranparente y el fondo del boton que inserte de flash queda del color del fondo que tiene el form....no se si me explique bien...espero que si...

Nesesito saver como puedo hacer transparente el fondo del boton hecho en flash mas el fondo del form... o alguna sujerencia para arreglar el codigo del modulo...no se...algo de ayuda por favor!!!
El codigo del moduilo para hacer el form transparente lo saque de las faq's de VB de este foro asi que creo que podran ayudar en esto.
__________________
You're face to face, with the man who sold the world - NIRVANA
Diese stadt ist eine Dirne, hat rote flecken auf der Stirn - RAMMSTEIN
  #2 (permalink)  
Antiguo 22/05/2006, 15:47
Avatar de elias77  
Fecha de Ingreso: noviembre-2005
Ubicación: Buscame...
Mensajes: 1.051
Antigüedad: 18 años, 5 meses
Puntos: 11
Ni una respuesta????? =(
__________________
You're face to face, with the man who sold the world - NIRVANA
Diese stadt ist eine Dirne, hat rote flecken auf der Stirn - RAMMSTEIN
  #3 (permalink)  
Antiguo 23/05/2006, 18:05
 
Fecha de Ingreso: abril-2004
Mensajes: 192
Antigüedad: 20 años
Puntos: 0
yo probe tu codigo he hice varias pruebas, pero no pude hacer que el area de fondo del swf tambien sea transparente.

salu2
__________________
Recursos visual basic
  #4 (permalink)  
Antiguo 23/05/2006, 20:25
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 19 años
Puntos: 3
hola prova de esta forma:

Cita:
Option Explicit
Const LW_KEY = &H1
Const G_E = (-20)
Const W_E = &H80000
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 Declare Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Sub Form_Load()
'On Error Resume Next
Dim Ret As Long
Dim TC As Long
TC = vbRed
Ret = GetWindowLong(hWnd, G_E)
Ret = Ret Or W_E
SetWindowLong hWnd, G_E, Ret
SetLayeredWindowAttributes hWnd, TC, 0, LW_KEY
Me.BackColor = vbRed
End Sub
elimina todas las regiones rojas que aya dentro del formulario si queres que sea otro color cambia el vbred por otro color
__________________
www.leandroascierto.com
  #5 (permalink)  
Antiguo 25/05/2006, 10:27
Avatar de elias77  
Fecha de Ingreso: noviembre-2005
Ubicación: Buscame...
Mensajes: 1.051
Antigüedad: 18 años, 5 meses
Puntos: 11
Hola prove el codigo de "LeandroA" y funciona...muchas gracias, pero a los botones les quedan como una especie de borde rojo, que no queda nada atractivo eso...
No se si es mucho pedir...pero...se puede sacarle ese borde rojo que le quedan a los botnes...?
__________________
You're face to face, with the man who sold the world - NIRVANA
Diese stadt ist eine Dirne, hat rote flecken auf der Stirn - RAMMSTEIN
  #6 (permalink)  
Antiguo 25/05/2006, 16:57
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 19 años
Puntos: 3
hola este problema lo vas a tene a no ser que el boton se 100% de un color ya que seguramente tiene algunos pixeles que no estan en un rgb(0,0,255) lo que te podria llegar a funcionar es o cambiar el color rojo por alguno mas disimulado o bien pro no estoy seguro ya que no se como es el boton flash pero asegurate de los bordes tengan un color puro sin sonas transparente me explico?

Saludos
__________________
www.leandroascierto.com
  #7 (permalink)  
Antiguo 25/05/2006, 20:20
Avatar de elias77  
Fecha de Ingreso: noviembre-2005
Ubicación: Buscame...
Mensajes: 1.051
Antigüedad: 18 años, 5 meses
Puntos: 11
Si, te explicas, pero por mas que tengan un borde oscuro, el maldito borde rojo siempre aparece, o el color que yo le ponga...le puedo cambiar el color al codigo pero igual sea el color que sea...queda mal..
En conclusion:
Nunca voy a obtener el fondo completamente transparente sin bordes ni nada por el estilo, de un .swf de flash insertado en vb con el fondo del form de visual tambien en trasparente...?
__________________
You're face to face, with the man who sold the world - NIRVANA
Diese stadt ist eine Dirne, hat rote flecken auf der Stirn - RAMMSTEIN
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 08:50.