473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 6540
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.