MS Excel – Formulários Transparentes (Transparent (See through) userforms in Excel)





Este é um recurso útil para utilização em formulários utilizados como Splash
ou em outras áreas onde sua imaginação o tornar aplicável.
O que importa é que vc saiba como fazê-lo.
No módulo do formulário acrescente:
'==============================================================================================
' Microsoft® Office Excel by A&A - In Any Place.
' Copyright© A&A – In Any Place. All Rights Reserved.
'==============================================================================================
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 SetLayeredWindowAttributes _
Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong _
Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2&
Public hWnd As Long
Option Explicit
No evento de inicialização do seu formulário, faça uma chamada a função a seguir:
Function OpacityNow()
' Author: Date: Contact:
' André Bernardes 24/11/2008 10:09 bernardess@gmail.com
' Deixando o formulário transparente.
Dim bytOpacity As Byte
Let bytOpacity = 195 ' Nível de opacidade.
Let hWnd = FindWindow ("ThunderDFrame", Me.Caption)
Call SetWindowLong (Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes (Me.hWnd, 0, bytOpacity, LWA_ALPHA)
End Function
Boa diversão!

Nenhum comentário:

Postar um comentário

diHITT - Notícias