By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

Semi Transparent controls

Ali Rizwan
100+
P: 927
Hi all
I have made my forms and its contents semi transparent but i want to make my controls transparent not my form how can i do this. I m using the following code to setting transperency to my form.
[code]
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_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
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 Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000


Private m_lAlpha As Long

Private Sub Form_Load()

m_lAlpha = 255
If Settings.chkTrans.Value = 1 Then
If (m_lAlpha = 255) Then
Dim lStyle As Long
lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
End If
Dim lAlpha
m_lAlpha = m_lAlpha - 10
lAlpha = m_lAlpha
If (lAlpha < 0) Then
lAlpha = 0
End If
SetLayeredWindowAttributes Me.hwnd, 0, lAlpha, LWA_ALPHA

End If

End Sub
Sep 5 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.