Try this for yourself: Create a custom control with a red background and then create another custom control with a transparent background. Lay down the red custom control on a Form, and then lay down the transparent custom control on-top of the red control such that its entirely contained within it. Run the application. Instead of the transparent control displaying the color directly below it (red), it displays the content of the Form below the red control.
I'm trying to overlay two custom controls. The background control is a custom oscilloscope screen with dozens of custom properties, events and methods. The Foreground control is a custom enunciator control (actually a series of them) that has, among other things, transparent content. Even though the foreground control's backcolor property is set to transparent, all I get is a block of color identical to the Form's background color. I don't even have to draw on the foreground control. I always get a block of color equal to the Form's background content.
See the attached application if you like.
Sam HobbsPosted Jun 4, 2011, 1:02 AM
LarryPosted Jun 4, 2011, 12:03 AM
http://www.c-sharpcorner.com/UploadFile/Nildo/NSA106032008213555PM/NSA1.aspx
However, since I draw dynamic content on the control below it, it makes the top-level control flicker.
Something tells me that if this were Apple or Linux technology, it would simply just work. Microsoft technology "solutions" are plagued with these type of problems.
Sam HobbsPosted Jun 3, 2011, 11:48 PM
LarryPosted Jun 3, 2011, 9:55 PM
Thanks for responding.
For some reason, this technique does not work either. The control is transparent, but only to the Form below it. Not for any other control (or object) placed between it and the Form.
Sam HobbsPosted Jun 3, 2011, 7:16 PM
FroglegPosted Jun 3, 2011, 6:55 PM
Public Class Form1
Dim ctrlRect, mouseRect As Rectangle
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ctrlRect = New Rectangle(92, 66, 50, 65)
mouseRect = New Rectangle(0, 0, 1, 1)
End Sub
Private Sub Red1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Red1.Paint
e.Graphics.DrawRectangle(Pens.Black, 92, 66, 50, 65)
End Sub
Private Sub Red1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Red1.MouseDown
mouseRect.X = e.X
mouseRect.Y = e.Y
If mouseRect.IntersectsWith(ctrlRect) Then
MessageBox.Show("On the control")
End If
End Sub
End Class