Hi Everyone.
I am using Vista, 7 Aero glass in my app. I am able to apply it using the
DwmExtendFrameIntoClientArea API, but there is a minor problem, the text on
controls appears transparent. someone suggested me that I should use
SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY
it works, now the text is no longer transparent but this creates another
problem. I can no longer click on the form, the mouse events gets passed
through.
anyone have a fix for this?
Thanks in advance.
' here is the code.
' a form with a command button and this code
Option Explicit
Private Const LWA_COLORKEY As Long = &H1
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_EX_LAYERED As Long = &H80000
Private Const WS_EX_TRANSPARENT As Long = &H20&
Private Const LWA_ALPHA As Long = &H2&
Private Type tRect
m_Left As Long
m_Right As Long
m_Top As Long
m_Buttom As Long
End Type
Private Declare Function apiApplyGlass Lib "dwmapi.dll" Alias _
"DwmExtendFrameIntoClientArea" (ByVal hWnd As Long, rect As tRect) 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 Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd
As _
Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwflags As Long)
As Long
Public Sub ApplyTransparency()
Dim lOldStyle As Long
lOldStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
SetWindowLong hWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY
End Sub
Private Sub ApplyAero()
Dim GRect As tRect
Dim lngReturn As Long
GRect.m_Buttom = -1
GRect.m_Left = -1
GRect.m_Right = -1
GRect.m_Top = -1
lngReturn = apiApplyGlass(Me.hWnd, GRect)
End Sub
Private Sub Command1_Click()
Me.BackColor = vbBlack
Call ApplyTransparency
Call ApplyAero
End Sub