こんにちは、ガラスのような透明なフォームを取得しようとしていました。これにより、クリックスルーとすべてのマウスイベントがガラスの背後のウィンドウまたはアイテムに渡されます。
だから、これは私が WindowForms で書いたコードです:
namespace ClickThroughMe
{
public partial class ClickThroughForm : Form
{
private int currentWindowStyle;
public ClickThroughForm()
{
InitializeComponent();
}
private void ClickThroughForm_Load(object sender, EventArgs e)
{
// Grab the Extended Style information for this window and store it.
currentWindowStyle = WindowLibrary.User32Wrappers.GetWindowLong(this.Handle, User32Wrappers.GWL.ExStyle);
// Set our window to "transparent", or invisible to the mouse.
SetFormToTransparent();
// Make our window the top-most form.
this.TopMost = true;
}
private void SetFormToTransparent()
{
// This creates a new extended style for our window, making it transparent to the mouse.
User32Wrappers.SetWindowLong(this.Handle, User32Wrappers.GWL.ExStyle,
(User32Wrappers.WS_EX) currentWindowStyle |
User32Wrappers.WS_EX.Layered |
User32Wrappers.WS_EX.Transparent);
}
}
}
このコードの問題は、不透明度によってウィンドウ全体が透明になるが、ボタンやスライダーなどのコントロールはクリック可能性を保持しないことです。
だから私はそれをより良くするために助けが必要です。
1)コントロールを完全に不透明にする(必要ではないが重要)
2)コントロールのクリック可能性と操作性を維持する(MUST)
結果を得るのに役立つ場合は、プロジェクトを WPF に変更することもできます。
ありがとうございました。