Click here to Skip to main content
15,919,358 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Semi Transparent Controls Pin
Dave Kreskowiak4-Sep-07 2:17
mveDave Kreskowiak4-Sep-07 2:17 
GeneralRe: Semi Transparent Controls Pin
errorfunktion4-Sep-07 3:21
errorfunktion4-Sep-07 3:21 
GeneralRe: Semi Transparent Controls Pin
Tom Deketelaere4-Sep-07 3:45
professionalTom Deketelaere4-Sep-07 3:45 
GeneralRe: Semi Transparent Controls Pin
errorfunktion4-Sep-07 3:57
errorfunktion4-Sep-07 3:57 
GeneralRe: Semi Transparent Controls Pin
Dave Kreskowiak4-Sep-07 4:29
mveDave Kreskowiak4-Sep-07 4:29 
GeneralRe: Semi Transparent Controls Pin
errorfunktion4-Sep-07 13:23
errorfunktion4-Sep-07 13:23 
GeneralRe: Semi Transparent Controls Pin
Dave Kreskowiak4-Sep-07 15:46
mveDave Kreskowiak4-Sep-07 15:46 
GeneralSemi Transparent Controls, Works! Pin
errorfunktion5-Sep-07 0:28
errorfunktion5-Sep-07 0:28 
Well I got it working. Here's a couple of screenshots:

http://rapidshare.com/files/53533392/tccontrol1.bmp.html
http://rapidshare.com/files/53531028/tcontrol2.bmp.html


In the forms paint event I have drawn a circle in the upper left corner.
I have also placed a button in the upper left corner.
The arrow shaped thingy is my control.


All You need is a derived control in my case:

Public Class TransparentControl
Inherits Control
'Set These Options:
Public Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
BackColor = Color.Transparent 'It might be necessary to override the base 'backcolor property

'Add some code to the paint event to draw the control and use a color with alpha level less then 255.

'As you can see in the first screen capture the form background is visible, but the control is obscured.
' To make the button also visible through the control you can use the button's draw to bitmap method and set that bitmap as
' the controls background image.
' Right now this code is in the button's paint event handler and it makes things a bit twitchy.
There's probably a better position for it.

Private Sub Button1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Button1.Paint
Dim control_rect As New Rectangle(Me.TransparentControl1.Location, Me.TransparentControl1.Size)

Dim button_rect As New Rectangle(Me.Button1.Location, Me.Button1.Size)
'Checks If the control area's recangle interesects with the button's
If control_rect.IntersectsWith(button_rect) Then
'Find the area of the intersection
control_rect.Intersect(button_rect)
'Offset the area of intersection to account for the different positions
control_rect.Offset(-Me.TransparentControl1.Location.X, -Me.TransparentControl1.Location.Y)
Dim im As New Bitmap(Me.TransparentControl1.Width, Me.TransparentControl1.Height)
Me.Button1.DrawToBitmap(im, control_rect)
Me.TransparentControl1.BackgroundImage = im
End If

End Sub

That's It.

Thanks for the help Dave

Gary


GeneralRe: Semi Transparent Controls, Works! Pin
Dave Kreskowiak5-Sep-07 2:09
mveDave Kreskowiak5-Sep-07 2:09 
QuestionWeb Service timeout Pin
Diego F.4-Sep-07 1:33
Diego F.4-Sep-07 1:33 
AnswerRe: Web Service timeout Pin
Kschuler4-Sep-07 4:10
Kschuler4-Sep-07 4:10 
QuestionInstallation of application Pin
Roes1234-Sep-07 0:14
Roes1234-Sep-07 0:14 
AnswerRe: Installation of application Pin
ncjlee4-Sep-07 3:31
ncjlee4-Sep-07 3:31 
GeneralRe: Installation of application Pin
Roes1234-Sep-07 3:41
Roes1234-Sep-07 3:41 
QuestionHowto dynamic call of a method Pin
Stephan Pilz3-Sep-07 23:49
Stephan Pilz3-Sep-07 23:49 
AnswerRe: Howto dynamic call of a method Pin
Guffa3-Sep-07 23:54
Guffa3-Sep-07 23:54 
GeneralRe: Howto dynamic call of a method Pin
Stephan Pilz3-Sep-07 23:57
Stephan Pilz3-Sep-07 23:57 
AnswerRe: Howto dynamic call of a method Pin
Salman Sheikh3-Sep-07 23:58
Salman Sheikh3-Sep-07 23:58 
GeneralRe: Howto dynamic call of a method Pin
Stephan Pilz4-Sep-07 0:03
Stephan Pilz4-Sep-07 0:03 
AnswerRe: Howto dynamic call of a method Pin
Pascal Ganaye4-Sep-07 6:03
Pascal Ganaye4-Sep-07 6:03 
QuestionGet blank CD/DVD disk space Pin
helelark1233-Sep-07 21:37
helelark1233-Sep-07 21:37 
AnswerRe: Get blank CD/DVD disk space Pin
Dave Kreskowiak4-Sep-07 5:32
mveDave Kreskowiak4-Sep-07 5:32 
GeneralRe: Get blank CD/DVD disk space Pin
helelark1234-Sep-07 19:14
helelark1234-Sep-07 19:14 
GeneralRe: Get blank CD/DVD disk space Pin
Dave Kreskowiak5-Sep-07 2:02
mveDave Kreskowiak5-Sep-07 2:02 
AnswerRe: Get blank CD/DVD disk space Pin
Lucky Sheikh6-Sep-07 20:33
Lucky Sheikh6-Sep-07 20:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.