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

Recommended Answers

All 5 Replies

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

Denis

i mean it can be change like opacity

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

commented: really complex +1
commented: confusing but this a nice code +1

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.