473,606 Members | 2,171 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
SupportsTranspa rentBackColor style and providing some additional processing
in CreateParams and OnPaintBackgrou nd, 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 6559
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
9487
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 control. My control draws a shape (circle, square, rectangle ...)
7
31118
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 control on another form. All I want to see is the drawing and I want anything behind the drawing to show through. TransparencyKey and Opacity don't compile.
2
8299
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 showing one transparent form (form3) when ever user preseed left mouse button. 3) The form3 has one transparent user control (usercontrol2) that paints circles. That measn the circles will show on top the usercontrol1 image. 4) The form3 border style...
9
7809
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 Opacity. Finally, i try to use transparencykey, but any mouse actions will be transferred to the windows below the transparent area. Any solutions? thx
3
3099
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 Whiteboard. The Form contains 3
4
3738
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 the Calendar displays but it's transparent so other controls like labels on the web form which are supposed to be behind the Calendar can be seen. How do I make sure the Calendar is not transparent?
8
10596
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 some controls that aren't rectangular and it won't be pretty if I end up with a grey rectangle behind each one. http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGivingYourControlTransparentBackground.asp?frame=true
4
2963
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 the user can move it around, so there could be a textbox, another picture, a button or nothing below the picture box. Setting the background color of the bitmap and of the picturebox to color.transparent does not seem to work. Another...
1
1974
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 fullscreen. I want my new application to run transparently over the top of the existing app, and when the user clicks the mouse button, my transparent application records the location of the click while 'passing on' the click to the application below...
0
7951
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8430
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6770
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5966
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5465
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3930
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1296
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.