-
June 3rd, 2009, 06:12 PM
#16
Re: Tranparent color...
Post what you have so far, and we'll see if it is a problem or not...
-
June 4th, 2009, 07:24 AM
#17
Re: Tranparent color...
I posted it above but here it is again. This code makes a colour on a form totally transparent where you see through the form. I want the exact same effect but this time, you see throught the control like shown in the pictures above.
Code:
Private Declare Function SetWindowLongptr 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 Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20) ' Transparent color
Private Const GWL_STYLE = (-16) ' Expandable borders
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20
Private Const WS_EX_APPWINDOW = &H40000
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Const COL_TRANS = &HFF ' Transparent Red
Private Sub Form_Load()
Dim Alpha As Byte
Dim MaskColour As Long
Alpha = 200
MaskColour = COL_TRANS
' Whatever control you want to make the backcolor transparent
' Set the backcolor to the transparent color
Picture1.BackColor = MaskColour
Option1.BackColor = MaskColour
Check1.BackColor = MaskColour
Me.BackColor = MaskColour
Text1.BackColor = MaskColour
Command1.BackColor = MaskColour
' Apply Transparency
SetWindowLongptr Me.hwnd, GWL_EXSTYLE, WS_EX_LAYERED Or WS_EX_APPWINDOW
SetLayeredWindowAttributes Me.hwnd, MaskColour, Alpha, LWA_COLORKEY ' Or LWA_ALPHA
End Sub
David Richard
-
June 4th, 2009, 07:52 PM
#18
Re: Tranparent color...
Take a look at my code, and use F8 to step thru it line by line as you move the slider.
Me, in the case below, refers to FORM1.ME (shorthand). If you want Picture1 to blend, then use Picture1.hWnd to vary the blend.
Code:
Private Sub sldAlpha_Change()
Dim bAlpha As Byte
bAlpha = CByte(sldAlpha.Value)
' Set the new alpha level
SetLayeredWindowAttributes Me.hWnd, 0&, bAlpha, LWA_ALPHA
Me.Refresh
End Sub
-
June 5th, 2009, 03:22 AM
#19
Re: Tranparent color...
Yesterday, I found/modified code that did nearly exactly what you wanted except that the area of the picture box you could click through. Meaning that the form did not recieve any mousemove or click events. Also as part of this description, if the picture boxes zorder=0 then it would also bore holes through any control behind it and in reverse, other controls would hide portions of the picturebox so you would get a funny shaped hole in your form.
I searched several sites yesterday in hopes of answering your question, and the best I can come up with is that user control or use a seperate form for your effect.
However, if you find another way, please post the code.
Thanks and Good Luck
-
June 5th, 2009, 07:16 AM
#20
Re: Tranparent color...
I have tried everything that you guys posted here and I got no solution. It IS indeed a hard thing to do and find on the net. Before posting here, I searched a lot on Internet and tried to find a way to do this.
I did not want to use a UserControl because of all then hassle of programming it's parameters to set up the effect I wanted but it seems impossible for now to have the effect wanted with a simple PictureBox.
I want to thank everyone who has tried to help at its best to find a solution to this problem. I'm probably sure that this post will be way back in pages after this but at least, if it's contents can help someone else than at least no-one help for nothing.
Thanks again to everyone.
David Richard
David Richard
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|