473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transparent user control with click through to the control below

I'm trying to create a usercontrol that is transparent, both visibly and to
mouse clicks.

I can make the usercontrol visibly transparent by setting the
SupportsTransparentBackColor style and providing some additional processing
in CreateParams and OnPaintBackground, as detailed here:

http://www.codeproject.com/KB/edit/T...ntTextBox.aspx

This works fine, but if I click the transparent part of my control, the
mouse click is still received by my usercontrol instead of by the control
that is behind it. Is there a way to make clicks fall through the
transparent parts of the control to whatever is underneath?

Thanks,

--

(O)enone
Jun 27 '08 #1
2 6545
It sounds like you're attempting to either dynamically add the user
control or make it scalable by not having the user control refer to a
specific button underneath. The only idea I can think of without
seeing the project is to make the usercontrol some kind of container
and when it receives a click event to hit something on the underlying
control.

For instance if you had an extended panel control that only could
contain buttons and when it was clicked it would loop through every
button and fire the Click event.

You could also do what ASP.NET does with most of their controls that
have to link together and feed your usercontrol the ID of the item
that needs to be clicked and dynamically click it that way.

Another option is to have the usercontrol throw an event to the main
form when its been clicked that says its been clicked and on that
event fire the click code of the underlying control.

Jun 27 '08 #2
cfps.Christian wrote:
[...]
Another option is to have the usercontrol throw an event to the main
form when its been clicked that says its been clicked and on that
event fire the click code of the underlying control.
Thanks for the suggestions. I didn't perhaps clarify in my original post
that the control will be moving around my form, and exactly what's
underneath it could therefore change. I did consider having the control fire
an event back to its containing form telling it about clicks that it wasn't
interested in, but then I would have to go to all the effort of working out
what control (if any) was actually under the mouse cursor. As there could be
overlapping controls and all sorts, that could be a pain.

In the end I did find a solution however: setting the user control's Region
property. As the shape I want for my control consists only of a series of
rectangles, this works perfectly. The control only renders and responds to
pixels that fall within the defined region; all other parts of the control
show through the form or controls beneath, and mouse clicks are received by
those controls exactly as expected.

--

(O)enone
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9468
by: Paul Schnitter | last post by:
Update: My custom control is based on the article "Creating Visual Basic .NET controls from scratch" in "Adventures in .NET" on MSDN. It is designed to be a replacement for the VB6 shape...
7
31101
by: Chuck | last post by:
I am working in C# 2003. Can anyone tell me how to make a user control transparent. VS help doesn't help. What I want to do is draw on a user control during design time and then place the...
2
8289
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
9
7796
by: don | last post by:
I want to create a transparent form and can write something on it by using Ink. I try to set form.backcolor = color.transparent, but it dosen't accept. And everything will be transprent when i use...
3
3092
by: Steve Koon | last post by:
Any thoughts on getting this project to work or suggesting another method would be appreciated. Steve ========================================== Project: A Windows Form which acts as a...
4
3732
by: Nad | last post by:
Hello, I have a user control that has a button and a Calendar. Once you click on the button I display the calendar. Now when I move this user control to a web form, once I click on this button...
8
10582
by: Grahammer | last post by:
Is it possible to set the background of a usercontrol as transparent? I tried setting the background image of the usercontrol to a transparent GIF, but that caused MAJOR problems. I'm making...
4
2955
by: Andre Nogueira | last post by:
Hi there. I have one question... How can I create a bitmap (programmatically), paint it to a picture box and have a transparent background? I don't know what will be below the picturebox because...
1
1963
by: matthewr | last post by:
I want to create a fully-transparent fullscreen form which records clicks but also passes on the 'click' to the desktop. Specifically, I have an existing application which displays a webpage...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.