Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click-through in C# Form

Tags:

c#

I've created a semi-transparent form. I'd like for people to be able to click on the form area, and for form not handle the click. I'd like whatever is underneath the form to receive the click event instead.

like image 806
caesay Avatar asked May 09 '10 16:05

caesay


People also ask

What is click-through meaning?

: to click on (a link, such as a link for a promotion or advertisement) on a web page that opens a new page or site They have been pressing all Web sites, including those dedicated to journalism, to accept payment completely or partially based on the number of people clicking through an advertisement or even on the ...

What is the meaning of CTR in c++?

CTR stands for click-through rate.

How do you make a window click-through?

You can press the shortcut (ALT+A, which is changeable by clicking the toolbar icon) or you can hover your mouse over the top of a window and click the down arrow that appears, then select "Opacity." WindowTop also has the click-through feature that Peek Through has.


1 Answers

You can do this with SetWindowLong:

int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);

There are a few magic numbers in here:

  • -20 – GWL_EXSTYLE

    Retrieves the extended window styles.

  • 0x80000 – WS_EX_LAYERED

    Creates a layered window.

  • 0x20 – WS_EX_TRANSPARENT

    Specifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.

There are numerous articles all over the web on how to do this, such as this one.

like image 144
Joey Avatar answered Oct 21 '22 00:10

Joey