954,141 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Control Transparant Form

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..

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

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

Denis

DenisOxon
Posting Whiz
355 posts since Jan 2007
Reputation Points: 22
Solved Threads: 19
 

i mean it can be change like opacity

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

you mean the form can be change like opacity.If i right then try this following code :
add this following code to module :

Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long,ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long,ByVal nIndex As Long,ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long,ByVal nCmdShow 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

Private Const GWL_EXSTYLE As Long = -20
Private Const WS_EX_LAYERED As Long = &H80000
Private Const LWA_ALPHA As Long = &H2

Public Function Transparant(hwnd As Long, percent As Integer,pil As Boolean)
	Dim before as Long
	before = GetWindowLong(hwnd,GWL_EXSTYLE)
	If pil = true then
		before = before Or WS_EX_LAYERED
		SetWindowLong hwnd, GWL_EXSTYLE, before
		SetLayeredWindowAttributes hwnd, 0, 255 * (percent / 100), LWA_ALPHA
	Else
		before = before And Not WS_EX_LAYERED
		SetWindowLong hwnd, GWL_EXSTYLE, before
	End If
End Function


you can call the function like this :

Transparant Form1.hwnd, val(txtPercent.text), true

you can change text box with other control to get value as percent

Ok. Hope it helps..

Jx_Man
Nearly a Senior Poster
3,328 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

in .net its so much easier you can use me.opacity

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
 

wow thanks all for excellent reply...
thanks jx_man your code running nice..

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You