943,696 Members | Top Members by Rank

Ad:
Jan 9th, 2008
0

Control Transparant Form

Expand Post »
Hi guys/gals,
i need to make transparant form and it can be changing by user. i stuck cause i didn't know how to start..

OK.Best Regards..
Reputation Points: 38
Solved Threads: 6
Junior Poster in Training
Sawamura is offline Offline
65 posts
since Nov 2007
Jan 9th, 2008
0

Re: Control Transparant Form

Pardon me for asking, why have a form you can't see ?

Denis
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007
Jan 10th, 2008
0

Re: Control Transparant Form

i mean it can be change like opacity
Reputation Points: 38
Solved Threads: 6
Junior Poster in Training
Sawamura is offline Offline
65 posts
since Nov 2007
Jan 10th, 2008
2

Re: Control Transparant Form

you mean the form can be change like opacity.If i right then try this following code :
add this following code to module :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long,ByVal nIndex As Long) As Long
  2. Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long,ByVal nIndex As Long,ByVal dwNewLong As Long) As Long
  3. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long,ByVal nCmdShow As Long) As Long
  4. 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.  
  6. Private Const GWL_EXSTYLE As Long = -20
  7. Private Const WS_EX_LAYERED As Long = &H80000
  8. Private Const LWA_ALPHA As Long = &H2
  9.  
  10. Public Function Transparant(hwnd As Long, percent As Integer,pil As Boolean)
  11. Dim before as Long
  12. before = GetWindowLong(hwnd,GWL_EXSTYLE)
  13. If pil = true then
  14. before = before Or WS_EX_LAYERED
  15. SetWindowLong hwnd, GWL_EXSTYLE, before
  16. SetLayeredWindowAttributes hwnd, 0, 255 * (percent / 100), LWA_ALPHA
  17. Else
  18. before = before And Not WS_EX_LAYERED
  19. SetWindowLong hwnd, GWL_EXSTYLE, before
  20. End If
  21. End Function

you can call the function like this :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Transparant Form1.hwnd, val(txtPercent.text), true
you can change text box with other control to get value as percent

Ok. Hope it helps..
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007
Jan 10th, 2008
0

Re: Control Transparant Form

in .net its so much easier you can use me.opacity
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,501 posts
since Apr 2005
Jan 10th, 2008
0

Re: Control Transparant Form

wow thanks all for excellent reply...
thanks jx_man your code running nice..
Reputation Points: 38
Solved Threads: 6
Junior Poster in Training
Sawamura is offline Offline
65 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: need help in game
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: add to combo box from access with where statment





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC