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

Transparent Form...

Ali Rizwan
100+
P: 927
Hi all,
I know how to make a form transparent and how to create fadein and out effects on forms and controls both. But i dont know how can i make a form transparent but the controls are not transparent they must be visible. Or you can say i want to make my form transparent but i dont want to make controls on the form transparent.

Thanx
>> ALI <<
May 9 '08 #1
Share this Question
Share on Google+
8 Replies


Dököll
Expert 100+
P: 2,364
Hi all,
I know how to make a form transparent and how to create fadein and out effects on forms and controls both. But i dont know how can i make a form transparent but the controls are not transparent they must be visible. Or you can say i want to make my form transparent but i dont want to make controls on the form transparent.

Thanx
>> ALI <<
What type of controls are you referring to, Ali? And why do they need to remain transparent. Perhaps there is another way to achieve if you could cpould post the working code.

In a bit!

Dököll
May 11 '08 #2

Ali Rizwan
100+
P: 927
What type of controls are you referring to, Ali? And why do they need to remain transparent. Perhaps there is another way to achieve if you could cpould post the working code.

In a bit!

Dököll
The code is large. You can check my code in How to section. I have posted my codes to fade or making transparent form and controls.
But i dont want it that way. When i use that code form make transparent itself and all the controls on it. but i dont want to make controls trasparent.

Thanx
>> ALI <<
May 14 '08 #3

daniel aristidou
100+
P: 491
Hey ali.
In newer versions of vb.
Set the background colour to a colour unused in the rest of your controls.
Then under the forms properties set the "Transparency colour/key" equal to that of your form.

i think you are using vb6.....which means...complications....and therfore this probably is not an option
May 14 '08 #4

jamesd0142
100+
P: 469
Hey ali.
In newer versions of vb.
Set the background colour to a colour unused in the rest of your controls.
Then under the forms properties set the "Transparency colour/key" equal to that of your form.

i think you are using vb6.....which means...complications....and therfore this probably is not an option

Wow i tested this in vb2005, its neat!

James
May 14 '08 #5

Ali Rizwan
100+
P: 927
James and deniel i know and i have done this a long time ago in vb2008 by setting form's transperent color. I got an idea about doing it in vb6.

I ll upload a file but the way i m trying to do is a bit different, But stiil there is a problem i want to make the form semitransperent not completely transperent. and i knw this cannot be done in vb2008 too.

Thanx
>> ALI <<
May 14 '08 #6

daniel aristidou
100+
P: 491
i want to make the form semitransperent not completely transperent. and i knw this cannot be done in vb2008 too.

Thanx
>> ALI <<
Ali i think it can be done in vb08:
using silverlight.
insert a WPF user control..and this allows you to set a transparency% and amazing graphics....and shadows...etc.
Or you could convert your application:
instead of windows application
select Presentation application.
May 15 '08 #7

P: 68
Ali i think it can be done in vb08:
using silverlight.
insert a WPF user control..and this allows you to set a transparency% and amazing graphics....and shadows...etc.
Or you could convert your application:
instead of windows application
select Presentation application.

Try by this:
Expand|Select|Wrap|Line Numbers
  1. Private Const GWL_EXSTYLE As Long = -20
  2. Private Const WS_EX_LAYERED As Long = &H80000  
  3. Private Const LWA_ALPHA As Long = &H2  
  4. Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long  Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long  
  5. Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long  
  6. Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long  
  7. Dim alpha As Integer  
  8. Const MAXALPHA As Integer = 250  
  9. Const MINALPHA As Integer = 0  
  10. Private Sub SetTrans(ByVal OB_Hwnd As Long, ByVal OB_Val As Integer)  On Error Resume Next     
  11. Dim Attrib As Long     
  12. Attrib = GetWindowLong(OB_Hwnd, GWL_EXSTYLE)     
  13. SetWindowLong OB_Hwnd, GWL_EXSTYLE, Attrib Or WS_EX_LAYERED     SetLayeredWindowAttributes OB_Hwnd, RGB(0, 0, 0), OB_Val, LWA_ALPHA     
  14. FTransVal = OB_Val     
  15. Exit Sub 
  16. End Sub  
  17. Private Sub Command1_Click()  
  18. If MAXALPHA = alpha Then  
  19. Exit Sub  
  20. End If  
  21. SetTrans Me.hwnd, alpha  
  22. alpha = alpha + 10  
  23. End Sub  Private 
  24. Sub Command2_Click()  
  25. If MINALPHA = alpha Then  
  26. Exit Sub 
  27. End If  
  28. SetTrans Me.hwnd, alpha  
  29. alpha = alpha - 10  
  30. End Sub  
  31. Private Sub Form_Load()  
  32. alpha = MAXALPHA  
  33. End Sub  
  34.  
May 15 '08 #8

Ali Rizwan
100+
P: 927
Are you sure this will set transperency to form only not to controls.

Thanx
>> ALI <<
May 15 '08 #9

Post your reply

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