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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Form semi-transparente en el q se vean los controles???
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 3 Ir Abajo Respuesta Imprimir
Autor Tema: Form semi-transparente en el q se vean los controles???  (Leído 11,755 veces)
~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Form semi-transparente en el q se vean los controles???
« en: 6 Diciembre 2006, 11:38 am »

Pues eso basicamente, si alguien sabe como hacer un form semi-transparente, pero q se vean los controles q tiene dentro sin transparentar.

Buscando por google e encontrado muxo code q lo hace del todo transparente y uno q lo hace semi-transparente, pero no se ven los botones  :-(

Alguien lo sabe???
1S4ludo  ;)


En línea

DarkMouth

Desconectado Desconectado

Mensajes: 14



Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #1 en: 6 Diciembre 2006, 23:59 pm »


Hola que tal, prueba con esto a ver si te funciona
  ;D

Código:

Private Declare Function SetWindowLong Lib "user32" Alias _
    "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long

Private Sub Form_Load()
    Dim Resp As Long
    Resp = SetWindowLong(Me.hwnd, -20, &H20&)
    Form1.Refresh
End Sub



En línea

    Nur Gott kann mich bewerten
~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #2 en: 7 Diciembre 2006, 11:41 am »

No, yo no estoy buscando exactamente eso, tu code lo hace imbisible del todo y ademas funciona un poco mal...

Seria algo asi pero con los botones visibles:

Código:
Private mAlpha As Long

' Declaraciones para Layered Windows (sólo Windows 2000 y superior)
Private Const WS_EX_LAYERED As Long = &H80000
Private Const LWA_ALPHA As Long = &H2
'
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
    (ByVal hWnd As Long, ByVal crKey As Long, _
    ByVal bAlpha As Long, ByVal dwFlags As Long) As Long

'------------------------------------------------------------------------------
Private Const GWL_EXSTYLE = (-20)

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 GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long


Private Const RDW_INVALIDATE = &H1
Private Const RDW_ERASE = &H4
Private Const RDW_ALLCHILDREN = &H80
Private Const RDW_FRAME = &H400

Private Declare Function RedrawWindow2 Lib "user32" Alias "RedrawWindow" _
    (ByVal hWnd As Long, ByVal lprcUpdate As Long, ByVal hrgnUpdate As Long, _
    ByVal fuRedraw As Long) As Long


Private Sub Transparente()
        Dim tAlpha As Long
       
        tAlpha = 70 'Modificar aki el valor para hacerlo mas o menos transparente

        '// Set WS_EX_LAYERED on this window
        Call SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
       
        '// Make this window tAlpha% alpha
        Call SetLayeredWindowAttributes(hWnd, 0, (255 * tAlpha) / 100, LWA_ALPHA)
End Sub


Private Sub Form_Load()
    Transparente
End Sub

1S4ludo
En línea

CeLaYa


Desconectado Desconectado

Mensajes: 543



Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #3 en: 7 Diciembre 2006, 16:24 pm »

¿Como se podria aplicar este código a un solo control del Form?
En línea

"La soledad es el elemento de los grandes talentos".
Cristina de Suecia (1626-1689) Reina de Suecia.
IP3

Desconectado Desconectado

Mensajes: 73


Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #4 en: 7 Diciembre 2006, 21:53 pm »

Prueba con un control de usuario
En línea

~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #5 en: 7 Diciembre 2006, 23:30 pm »

Código:
¿Como se podria aplicar este código a un solo control del Form?

Eso es una indirecta diciendome q tengo la solucion ante los ojos enfocando esto solo hacia el form o es q tu tampoco lo sabes???

Citar
Prueba con un control de usuario

A q te refieres??

1S4ludo
En línea

dPix

Desconectado Desconectado

Mensajes: 222


¬_¬ - ¬O.o


Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #6 en: 7 Diciembre 2006, 23:37 pm »

Imagino que se referiría a la libreria user32.dll, es lo único que se me ocurre, con eso quizás puedas modificar la transferencia del form.

Salu2,

dPix
En línea

dPix

Desconectado Desconectado

Mensajes: 222


¬_¬ - ¬O.o


Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #7 en: 7 Diciembre 2006, 23:42 pm »

Efectivamente, IP3, era un control de usuario, aqui le dejo el código que googleando encontré (espero que sea esto lo que buscas).

Esto a un módulo:

Citar
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 UpdateLayeredWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcDst As Long, pptDst As Any, psize As Any, ByVal hdcSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, 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 LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Const WS_EX_LAYERED = &H80000

Public Function isTransparent(ByVal hWnd As Long) As Boolean
On Error Resume Next
Dim Msg As Long
Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED Then
  isTransparent = True
Else
  isTransparent = False
End If
If Err Then
  isTransparent = False
End If
End Function

Public Function MakeTransparent(ByVal hWnd As Long, Perc As Integer) As Long
Dim Msg As Long
On Error Resume Next
If Perc < 0 Or Perc > 255 Then
  MakeTransparent = 1
Else
  Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
  Msg = Msg Or WS_EX_LAYERED
  SetWindowLong hWnd, GWL_EXSTYLE, Msg
  SetLayeredWindowAttributes hWnd, 0, Perc, LWA_ALPHA
  MakeTransparent = 0
End If
If Err Then
  MakeTransparent = 2
End If
End Function

Public Function MakeOpaque(ByVal hWnd As Long) As Long
Dim Msg As Long
On Error Resume Next
Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
Msg = Msg And Not WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes hWnd, 0, 0, LWA_ALPHA
MakeOpaque = 0
If Err Then
  MakeOpaque = 2
End If
End Function


Donde quieres que funcione la transparencia pones:

Citar
MakeTransparent Me.hWnd, x

Donde x es un nº entre 0 y 255. Espero que sea esto. Codigo bastante interesante.

Un saludo,

dPix ;D
En línea

IP3

Desconectado Desconectado

Mensajes: 73


Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #8 en: 8 Diciembre 2006, 00:36 am »

Exacto dPix, a eso me referia, ahora en unos proyectos que hice lo estaba buscando, justo cuando tu lo posteaste, me ahorraste trabajo! Buen aporte!!!!
En línea

CeLaYa


Desconectado Desconectado

Mensajes: 543



Ver Perfil
Re: Form semi-transparente en el q se vean los controles???
« Respuesta #9 en: 8 Diciembre 2006, 01:11 am »

a lo que me referia es a como puedo aplicar la transparencia por ejemplo a un command o a un picture sin que el form se haga transparente
En línea

"La soledad es el elemento de los grandes talentos".
Cristina de Suecia (1626-1689) Reina de Suecia.
Páginas: [1] 2 3 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Semi- Bot para Hi5
Programación Visual Basic
yalosabes 0 1,420 Último mensaje 21 Febrero 2011, 23:57 pm
por yalosabes
[Solucionado] Diferencias en Form con fondo transparente en Win7 x64 y x86 (C#)
.NET (C#, VB.NET, ASP)
Xephiro 3 5,861 Último mensaje 22 Marzo 2011, 14:51 pm
por Xephiro
Crear controles runtime y agrandar el form
Programación Visual Basic
$Edu$ 6 2,461 Último mensaje 26 Septiembre 2011, 02:47 am
por $Edu$
PC semi-gamer y actualizable (~600€)
Hardware
Morty_13 6 4,018 Último mensaje 8 Agosto 2012, 23:26 pm
por worldrings
Windows Form transparente
.NET (C#, VB.NET, ASP)
diegoCmC 4 3,994 Último mensaje 1 Abril 2014, 10:55 am
por diegoCmC
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines