By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 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.
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
  2.    (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  3. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
  4.    (ByVal hwnd As Long, ByVal nIndex As Long, _
  5.    ByVal dwNewLong As Long) As Long
  6. Private Const GWL_STYLE = (-16)
  7. Private Const GWL_EXSTYLE = (-20)
  8. Private Declare Function SetLayeredWindowAttributes Lib "user32" _
  9.    (ByVal hwnd As Long, ByVal crKey As Long, _
  10.    ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  11. Private Const LWA_COLORKEY = &H1
  12. Private Const LWA_ALPHA = &H2
  13. Private Const WS_EX_LAYERED = &H80000
  14.  
  15.  
  16. Private m_lAlpha As Long
  17.  
  18. Private Sub Form_Load()
  19.  
  20.     m_lAlpha = 255
  21. If Settings.chkTrans.Value = 1 Then
  22.     If (m_lAlpha = 255) Then
  23.       Dim lStyle As Long
  24.       lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
  25.       lStyle = lStyle Or WS_EX_LAYERED
  26.       SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
  27.    End If
  28.    Dim lAlpha
  29.    m_lAlpha = m_lAlpha - 50
  30.    lAlpha = m_lAlpha
  31.    If (lAlpha < 0) Then
  32.       lAlpha = 0
  33.    End If
  34.    SetLayeredWindowAttributes Me.hwnd, 0, lAlpha, LWA_ALPHA
  35.  
  36.  End If
  37.  
  38. End Sub
Sep 5 '07 #1
Share this Question
Share on Google+
2 Replies


Robbie
100+
P: 180
Ali, if all you wanted to do was edit your previous post with code=vb tags, there is an Edit button...

Check this out:
http://www.vbforums.com/showthread.php?t=430271

Look in a person called schoolbusdriver's sig. There you can find a transparent picturebox control (which I've used, and it's excellent!), and a frame with a transparency effect.

Hope it's useful!

EDIT: Agh! >_o
I see what you mean now - alpha faing. ><
Well I'll keep this post here in case it helps other people.
Sep 5 '07 #2

Ali Rizwan
100+
P: 927
Ali, if all you wanted to do was edit your previous post with code=vb tags, there is an Edit button...

Check this out:
http://www.vbforums.com/showthread.php?t=430271

Look in a person called schoolbusdriver's sig. There you can find a transparent picturebox control (which I've used, and it's excellent!), and a frame with a transparency effect.

Hope it's useful!

EDIT: Agh! >_o
I see what you mean now - alpha faing. ><
Well I'll keep this post here in case it helps other people.
thanx rob i know that edit button but i ll forgotten about that time.
Sep 5 '07 #3

Post your reply

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