问题
I'm trying to make a mouse transparent form in win8 and winforms, that contains controls that are clickable.
I'm able to make the form mouse transparent, using this code
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
(on win8 the WndProc approach does not work)
But when I make the form mouse transparent, the controls that are contained in this form are also mouse transparent
What can I do?
回答1:
You can create a Form and set both BackColor
and TransparencyKey
properties to Color.Magenta
.
Screenshot:
Click pass through window and reaches to what behind it, but of you click on button 1, button will be clicked.
Note: The trick works for some colors, for example if you use Color.Red it will be transparent but handles clicks, but using Magenta the form will be mouse transparent too.
来源:https://stackoverflow.com/questions/32920402/win8-winforms-mouse-transparent-form-with-clickable-controls-in-it