Win8 - Winforms mouse transparent form with clickable controls in it

限于喜欢 提交于 2019-12-11 03:45:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!