473,772 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transparent form that intercepts mouse events

Hi,
I am trying (with little (no) success) to create a transparent form
that can capture mouse events. Put another way, i would like to show
the other windows that are behind my form (like setting the form
transparency key to the form backcolor), but i dont want the mouse
clicks to pass through my form and on to the windows behind.

Can i perhaps do this with a message filter? by deregistering the
filter that must already be there to pass the mouse clicks on? or maybe
by overriding WndProc and handling the mouse events there?

If anyone has any ideas as to how i might accomplish this, then i will
herald them as an intellectual leviathan!

James Randle.

Dec 17 '06 #1
2 5485

Hi,
If you create a form with the same dimensions and location of your
current form, then all messages will go to that form anyway. Here's
some code that creates a transparent form and displays it over the
current form when the button is clicked. When this new form is shown,
all windows messages go to it and so nothing is accessible on the form
underneath. The form is a standard form with a button and a label.
When the button is clicked, the new (transparent) form is show on top
of it.

Hope this helps.

Cheers,

Steve Dunn.
http://stevedunns.blogspot.com

public partial class Form1 : Form
{
private Form _form;

public Form1()
{
InitializeCompo nent();

_form = new Form();
_form.FormBorde rStyle = FormBorderStyle .None;
_form.Opacity = .5;
_form.ShowInTas kbar = false;
_form.KeyDown += delegate(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
_form.Hide();
label1.Text = @"We're not covered";
}
};
}
private void button1_Click(o bject sender, EventArgs e)
{
_form.Show(this );
_form.Bounds = this.Bounds;
_form.Location = this.Location;
label1.Text = @"We're covered. Press escape";
}
}

On Dec 17, 3:39 pm, "pigeonrand le" <pigeonran...@h otmail.comwrote :
Hi,
I am trying (with little (no) success) to create a transparent form
that can capture mouse events. Put another way, i would like to show
the other windows that are behind my form (like setting the form
transparency key to the form backcolor), but i dont want the mouse
clicks to pass through my form and on to the windows behind.

Can i perhaps do this with a message filter? by deregistering the
filter that must already be there to pass the mouse clicks on? or maybe
by overriding WndProc and handling the mouse events there?

If anyone has any ideas as to how i might accomplish this, then i will
herald them as an intellectual leviathan!

James Randle.
Dec 17 '06 #2
seems like this would be best accomplished by a hook.

http://support.microsoft.com/kb/318804/
http://msdn.microsoft.com/newsgroups...0379e54c9b&p=1

just some links for you...

hope this helps
--
-iwdu15
Dec 18 '06 #3

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

Similar topics

1
11984
by: Trevor Fairchild | last post by:
I am working on an Application which I have based on several frames. There is one central frame, and, as required, the other frames 'slide' out from behind it. The problem is that this requires a large form to keep room for all of the various slides. I want to have the form transparent, and have mouse events pass-through to whatever is behind it. I have done some searching and have found the commands to make a form transparent - but...
2
7389
by: Henrik | last post by:
Hi how can i make the backcolor of a form transparent best regards Henrik
5
6671
by: 2003et | last post by:
How To Create Transparent Windows Controls? Thanks
2
8312
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
7819
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
3104
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
0
1680
by: Per Larsson | last post by:
I have been nagging for help on this subject for quite some time now. Finally got it sorted out by my self. Here is the code if some one else ever need it. 'Declarations: Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" _ (ByVal hwnd As System.IntPtr, ByVal nIndex As Integer) As Integer
0
1319
by: anishkphilip | last post by:
Hi, I've a Panel on a Windows form. I've set the TransparencyKey property of the Form as the BackColor of the panel so that the portion of the Form occupied by the panel will be transparent. I want to get the mouse events on this panel. But when the Panel is transparent, all the mouse events are going to the window below the application. How can I get these events in the Panel?
1
1990
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
9454
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
10106
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
10039
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
8937
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...
0
6716
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.