SpiroChronis
Programmer
Hello All,
I have a transparent form. And i need to place a semi transparent picturebox on this transparent form. My problem is that I set the picturebox as being semi-transparent but for some reason you can't even slightly see what is behind the form.
Please, please help. here is the code so far:
'this is for the transparent form
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.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2&
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Private Sub Form_Load()
dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
dwExStyle = dwExStyle Or WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, dwExStyle
BackColor = RGB(1, 0, 0) ' this is what will be transparant
SetLayeredWindowAttributes hWnd, RGB(1, 0, 0), 0, LWA_COLORKEY
End Sub
'this is for the picturebox
Dim Num As Byte, nN%, nBlend&
nBlend = vbBlue - CLng(200) * (vbYellow + 1)
AlphaBlend frmDraw.hDC, conX, conY, width, height, frmDraw.picsrc.hDC, 0, 0, frmDraw.picsrc.ScaleWidth, frmDraw.picsrc.ScaleHeight, nBlend
I have a transparent form. And i need to place a semi transparent picturebox on this transparent form. My problem is that I set the picturebox as being semi-transparent but for some reason you can't even slightly see what is behind the form.
Please, please help. here is the code so far:
'this is for the transparent form
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.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2&
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Private Sub Form_Load()
dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
dwExStyle = dwExStyle Or WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, dwExStyle
BackColor = RGB(1, 0, 0) ' this is what will be transparant
SetLayeredWindowAttributes hWnd, RGB(1, 0, 0), 0, LWA_COLORKEY
End Sub
'this is for the picturebox
Dim Num As Byte, nN%, nBlend&
nBlend = vbBlue - CLng(200) * (vbYellow + 1)
AlphaBlend frmDraw.hDC, conX, conY, width, height, frmDraw.picsrc.hDC, 0, 0, frmDraw.picsrc.ScaleWidth, frmDraw.picsrc.ScaleHeight, nBlend