Red de conocimiento informático - Problemas con los teléfonos móviles - vb6 hace que el fondo de la imagen sea transparente

vb6 hace que el fondo de la imagen sea transparente

El método consiste en utilizar SetWindowLong para establecer el "estilo" del cuadro de imagen para incluir WS_EX_LAYERED, y luego utilizar SetLayeredWindowAttributes para establecer el fondo dentro del cuadro de imagen en transparente (debe ser un color sólido).

El código es el siguiente: 'En "General?Declaración"

¿Privado?Declarar?Función?SetWindowLong?_

Lib?"user32"?" SetWindowLongA"? _

(ByVal?hwnd?As?Long,?ByVal?nIndex?As?Long,? _

ByVal?dwNewLong?As?Long)?As?Long

¿Privado?¿Declarar?Función?GetWindowLong?_

Lib?"user32"?"GetWindowLongA"?_

(ByVal?lhWnd?As?Long, ? _

¿PorVal?nIndex?As?Long)?As?Long

¿Privado?¿Declarar?Función?Establecer atributos de ventana en capas?_

¿Lib?»user32"? _(ByVal ?lhWnd?As?Long, ?ByVal?crKey?As?Long, ?_

ByVal?bAlpha?As?Byte, ?ByVal?dwFlags?As?Long)?As?Long

¿Privado?Const?GWL_EXSTYLE?=?(-20)

¿Privado?Const?WS_EX_LAYERED?=? amp; H80000

¿Privado?Const?LWA_COLORKEY?= ? amp; H1

'Agregue el siguiente código al lugar donde desea que sea transparente

'Suponga que el PictureBox que será transparente es Pict1 y el color de fondo es blanco

Dim?ws?As?Long

ws?=?GetWindowLong(Pict1.hWnd,?GWL_ EXSTYLE)?Or?WS_EX_LAYERED

SetWindowLong?Pict1.hWnd,?GWL_EXSTYLE ,?ws

'El vbWhite a continuación se puede cambiar a un color de fondo transparente

SetLayeredWindowAttributes?Pict1.hWnd,?vbWhite,?0,?LWA_COLORKEY