点击“通过”按钮透明的形式 [英] Clicking "through" a transparent form

查看:48
本文介绍了点击“通过”按钮透明的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写的程序有两种形式,一种是主控制形式,另一种是完全透明的,除了1像素边框,4个角的尺寸调整手柄和中间的移动手柄。当您单击主窗体中的按钮时,将截取第二个窗体所概述的屏幕部分的屏幕截图。这很好用,但我遇到了一个问题。


第二种形式只是一个没有表格边框的表格,具有任意背景颜色(栗色),具有透明度键设置为该颜色,以便表单是透明的。不幸的是,这意味着如果我将表单设置在另一个窗口上,我就无法控制该窗口下面的内容,这意味着如果主控制窗口最终位于表单下方,我就不能单击该按钮我必须将表单移开,以便我可以进入控制窗口。


有没有办法让截屏框显示在所有其他窗口的顶部,但仍然允许我点击它来控制它下面的任何东西?一个例子是Camtasia Recorder。它有一个边界框,你可以移动和调整大小以指定你想要记录的屏幕部分,但你仍然可以控制它下面的任何窗口。

The program I''m writing has 2 forms, a main control form, then another that is completely transparent except for a 1 pixel border, sizing handles at the 4 corners, and a moving handle in the middle. When you click a button in the main form a screenshot is taken of the portion of the screen outlined by the second form. This works great, but I''ve run into an issue.

The second form is simply a form without a form border, with an arbitrary background color (maroon), with the transparency key set to that color, so that the form is transparent. Unfortunately, this means that if I set the form over another window, I can''t control what''s underneath that window, which means that if the main control window ends up underneath the form, I can''t click the button and I have to move the form out of the way so I can get at the control window.

Is there a way that I can make the screenshot box appear on top of all other windows, but still allow me to click through it to control whatever is underneath it? An example of this would be Camtasia Recorder. It has a bounds box that you can move and resize to specify the portion of the screen that you want to record, but you can still control any windows that might be underneath it.

推荐答案

我试图重现这一点,但如果我使表格透明,我可以点击通过它和底层的Control获得了鼠标事件。


我只是创建了一个Form,设置了它的BackColor,它的TransparencyKey为Color.Red而且它是' FormBorderStyle为None,它可以工作。


也许你可以告诉我你还有什么改变,这样我就可以重现这种行为,所以对我来说更容易帮助。
I''ve tried to reproduce this, but if I make a Form transparent, I can click "through" it and the underlying Control gets the mouse-event.

I simply created a Form, set it''s BackColor and it''s TransparencyKey to Color.Red and it''s FormBorderStyle to None and it works.

Maybe you can tell me what else you''ve changed, so that I can reproduce this behavior, so it would be easier to help for me.


这里是当前版本的构建:

截图1.1


这里是来源:

< a rel =nofollowhref =http://infectionist.com/extras/csharp/screenshot/Screenshot2_1.1_src.zip\"target =_ blank>截图1.1来源


当我在屏幕截图边界下移动控制窗口时,我无法控制主窗口。我目前设置它,以便主窗体的背景颜色变为红色,如果它相交或包含在屏幕截图边界窗体中。据我记得,我完全按照你的方式做了。我的BackColor是Maroon,FormBorderStyle是None,而TransparencyKey是Maroon。唯一的区别是我将ShowIcon和ShowInTaskbar设置为false,并使用设置文件设置大小和位置。


有一个面板设置为停靠模式填充( backcolor透明),所以我可以在边界上有一个单像素边框,但我尝试删除它,即使没有它我也无法与边界窗口下的对象进行交互,所以不可能。


希望我的源代码有帮助。
Well here is a build of the current version:

Screenshot 1.1

And here''s the source:

Screenshot 1.1 Source

When I move the control window underneath the screenshot bounds, I cannot control the main window. I currently have it set up so that the main form''s background color changes to red if it intersects or is contained within the screenshot bounds form. As far as I remember I did exactly what you did. My BackColor is Maroon, FormBorderStyle is None, and TransparencyKey is Maroon. The only other differences are that I have ShowIcon and ShowInTaskbar set to false, and Size and Location are set using a settings file.

There is a panel that is set to dock mode Fill (backcolor transparent), so that I can have a single-pixel border on the bounds, but I tried deleting it and even without it I couldn''t interact with objects under the bounds window, so that can''t be it.

Hopefully my source code helps.


我开始你的exe并且运行良好。如果我将透明表单拖到主表单上,主表单变为红色,但我仍然可以点击覆盖表单上的表单。按钮。

我正在使用Windows XP,也许它只是在你正在使用的操作系统上工作?
I started your exe and it worked well. If I drag the transparent form over the main-form, the main-form gets red but I can still click trough the form on the "covered" button.
I''m using Windows XP, maybe it just doesn''t work on the os you are using?


这篇关于点击“通过”按钮透明的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆