elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Fondo transparente
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Fondo transparente  (Leído 5,454 veces)
Alex_bro


Desconectado Desconectado

Mensajes: 1.246



Ver Perfil
Fondo transparente
« en: 9 Mayo 2005, 16:10 pm »

buenas , tengo la duda de si se puede poner el fondo del Form transparente , es decir sin color.

gracias y cuidense


En línea

Cicklow


Desconectado Desconectado

Mensajes: 604


-=Cicklow SOFT®=-


Ver Perfil WWW
Re: Fondo transparente
« Respuesta #1 en: 9 Mayo 2005, 16:21 pm »

si esto se puede por medio de esto:
Código:
'----------------------------------------------------------------------------------------------------
Attribute VB_Name = "Transparent"
Option Explicit
'Declaraciones de los diferentes tipos de regiones a crear
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
'POINTAPI tipo requerido para CreatePolygonRgn
Private Type POINTAPI
        X As Long
        Y As Long
End Type
'Fija la region
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
'Combina la region
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
'Tipo de combinacion
Const RGN_XOR = 3
'----------------------------------------------------------------------------------------------------
Public Sub MakeTransparent(TransForm As Form)
Dim ErrorTest As Double
    'en caso de que haya un error, se ignora
    On Error Resume Next
   
    Dim Regn As Long
    Dim TmpRegn As Long
    Dim TmpControl As Control
    Dim LinePoints(4) As POINTAPI
   
    'Puesto que las API trabajan en pixels, cambiamos el modo de escala a pixels
    TransForm.ScaleMode = 3
   
    'Debe ejecutarse sobre un formulario son bordes.
    If TransForm.BorderStyle <> 0 Then MsgBox "Cambia el borderstyle a 0!", vbCritical, "ACK!": End
   
    'Hace todo invisible
    Regn = CreateRectRgn(0, 0, 0, 0)
   
    'Un bucle para controlar cada control en el formulario
    For Each TmpControl In TransForm
   
        'Si el control es una linea...
        If TypeOf TmpControl Is Line Then
            'Comprueba la inclinacion
            If Abs((TmpControl.Y1 - TmpControl.Y2) / (TmpControl.X1 - TmpControl.X2)) > 1 Then
                'Si es mas vertical que horizontal entonces..
                'Fija los puntos
                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
                'Si es mas horizontal que vertical, entonces...
                'Fija los puntos
                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
            'Crea el nuevo poligono con los puntos
            TmpRegn = CreatePolygonRgn(LinePoints(0), 4, 1)
           
        'Si el control es una figura...
        ElseIf TypeOf TmpControl Is Shape Then
           
            'si es asi, comprobamos el tipo
            If TmpControl.Shape = 0 Then
            'Es un rectangulo
                TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height)
            ElseIf TmpControl.Shape = 1 Then
            'Es un cuadrado
                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
            'Es un ovalo
                TmpRegn = CreateEllipticRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width + 0.5, TmpControl.Top + TmpControl.Height + 0.5)
            ElseIf TmpControl.Shape = 3 Then
            'Es un circulo
                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
            'Es un rectangulo redondeado
                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
'Es un cuadrado redondeado
                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
           
            'Si el control es una figura con fondo transparente
            If TmpControl.BackStyle = 0 Then
               
                'Combinamos la region en memoria y creamos una nueva
                CombineRgn Regn, Regn, TmpRegn, RGN_XOR
               
                If TmpControl.Shape = 0 Then
                'Rectangulo
                    TmpRegn = CreateRectRgn(TmpControl.Left + 1, TmpControl.Top + 1, TmpControl.Left + TmpControl.Width - 1, TmpControl.Top + TmpControl.Height - 1)
                ElseIf TmpControl.Shape = 1 Then
                'Cuadrado
                    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
                'Ovalo
                    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
                'Circulo
                    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
'Rectangulo redondeado
                    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
                'Cuadrado redondeado
                    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
                'Crea una region rectangular con estos parametros
                TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top, TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height)
           
        End If
           
            'Comprueba que el control tiene ancho o conseguiremos extraños resultados
           
            ErrorTest = 0
            ErrorTest = TmpControl.Width
            If ErrorTest <> 0 Or TypeOf TmpControl Is Line Then
                'Combina las regiones
                CombineRgn Regn, Regn, TmpRegn, RGN_XOR
            End If
       
    Next TmpControl
   
    'Crea las regiones
    SetWindowRgn TransForm.hwnd, Regn, True
   

End Sub

'----------------------------------------------------------------------------------------------------
Esto lo que hace es dejar el form transparente y los controles NO :)
Kual kier cosa:
http://www.elguille.info/colabora/vb/lcg_Transparente.htm


En línea

www.cicklow.com . Solo Soy Un Ciego que Ve El Sonido Del Silencio
Alex_bro


Desconectado Desconectado

Mensajes: 1.246



Ver Perfil
Re: Fondo transparente
« Respuesta #2 en: 9 Mayo 2005, 16:45 pm »

gracias por responder , me da error en la siguiente linea:
Código:
Attribute VB_Name = "Transparent"
es posible que sea por que uso la version 6.0 de vb?

salu2
En línea

Cicklow


Desconectado Desconectado

Mensajes: 604


-=Cicklow SOFT®=-


Ver Perfil WWW
Re: Fondo transparente
« Respuesta #3 en: 9 Mayo 2005, 16:48 pm »

Borralo, ya que ese datos esta dentro del form y no en el codigo fuente.
ese seria el nombre del formulario.
SUerTE.
En línea

www.cicklow.com . Solo Soy Un Ciego que Ve El Sonido Del Silencio
Alex_bro


Desconectado Desconectado

Mensajes: 1.246



Ver Perfil
Re: Fondo transparente
« Respuesta #4 en: 9 Mayo 2005, 20:26 pm »

si... ya probe quitando esa linea pero no hace efecto , el Form sale con su color de fondo por defecto... es como si no tubiese puesto ningun codigo.

voy a seguir viendo haber si detecto el error.
salu2 y grax.

PD: ya no me hace falta , solo sigo preguntando por si alguien tiene el mismo problema que yo y asi dejar el tema resuelto .
« Última modificación: 9 Mayo 2005, 20:28 pm por alejandro3000 » En línea

Cicklow


Desconectado Desconectado

Mensajes: 604


-=Cicklow SOFT®=-


Ver Perfil WWW
Re: Fondo transparente
« Respuesta #5 en: 9 Mayo 2005, 22:39 pm »

Es facil eso es una funcion; solo coloka esto en el evento load del form
Código:
MakeTransparent Me
En línea

www.cicklow.com . Solo Soy Un Ciego que Ve El Sonido Del Silencio
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Photostock 103 Tatuajes con fondo transparente[FSE-DL-FS-FS]
Diseño Gráfico
EmirSc 2 8,779 Último mensaje 26 Mayo 2011, 01:42 am
por chuner
[Solucionado] Diferencias en Form con fondo transparente en Win7 x64 y x86 (C#)
.NET (C#, VB.NET, ASP)
Xephiro 3 5,842 Último mensaje 22 Marzo 2011, 14:51 pm
por Xephiro
¿Chequear si un archivo PNG tiene fondo transparente?
PHP
extreme69 3 3,056 Último mensaje 14 Enero 2012, 13:46 pm
por Stoya
La TV transparente del futuro. (Samsung's Smart Window)
Foro Libre
Eleкtro 4 3,576 Último mensaje 16 Enero 2012, 14:31 pm
por d(-_-)b
Imágenes con Fondo Transparente « 1 2 »
Diseño Gráfico
B€T€B€ 16 10,703 Último mensaje 30 Noviembre 2020, 19:34 pm
por B€T€B€
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines