Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Semi-Transparent picturebox on a transparent form

Status
Not open for further replies.

SpiroChronis

Programmer
Mar 30, 2005
10
ZA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top