[RESOLVED] Semi-transparent screen
Hi guyz :wave:
I wanna create a semi-transparent screen for my password confirmation box just to give professional touch...:cool:
so is anybody having any idea about this thing, to give semitransparent or translucent...
Thanks in Advance
Waiting for Replyz
Re: Semi-transparent screen
3rd parameter of the SetLayeredWindowAttributes API call from your previous thread I posted the link for :)
Its the Alpha parameter and 0 means completely transparent. So if you use 128 (which is 50% transparency as 255 is solid opaic) you will get a semi-transparent form.
Re: Semi-transparent screen
Do i have to make change in this one:-
Code:
Option Explicit
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
ByVal hWnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1&
Private Const LWA_ALPHA = &H2&
Private Sub Form_Load()
'Set the Form transparent by color.
BackColor = RGB(127, 127, 0) 'Unique but explicit (non-system) color.
SetWindowLong hWnd, _
GWL_EXSTYLE, _
GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hWnd, BackColor, 0, LWA_COLORKEY
End Sub
i have tried editing the last line:-
Code:
SetLayeredWindowAttributes hWnd, BackColor, 0, LWA_COLORKEY
to this:-
Code:
SetLayeredWindowAttributes hWnd, BackColor, 128, LWA_COLORKEY
BUt nothing happens, its still transparent
Re: Semi-transparent screen
Here you go. Also needed to specify the alpha consct flag.
Code:
Option Explicit
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
ByVal hWnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1&
Private Const LWA_ALPHA = &H2&
Private Sub Form_Load()
'Set the Form transparent by color.
BackColor = RGB(127, 127, 0) 'Unique but explicit (non-system) color.
SetWindowLong hWnd, _
GWL_EXSTYLE, _
GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hWnd, BackColor, 128, LWA_ALPHA
End Sub
Re: Semi-transparent screen
Actually you dont need to be setting the backcolor unless you want to change it.
'BackColor = RGB(127, 127, 0) 'Unique but explicit (non-system) color.
SetLayeredWindowAttributes hWnd, 0, 128, LWA_ALPHA
Re: Semi-transparent screen
THanks again yoda
that worked!!!
you truly are genius....:afrog:
Re: [RESOLVED] Semi-transparent screen
Thanks but there is always someone that knows more or other things. The key is to continue to learn and never stop :)