【问题标题】:C# Hide cursor while allowing mouse events to pass through a transparent windowC#隐藏光标,同时允许鼠标事件通过透明窗口
【发布时间】:2014-04-14 20:30:25
【问题描述】:

我正在使用此代码使全屏窗口透明并允许鼠标​​事件通过该窗口:

Cursor.Hide();
this.BackColor = System.Drawing.Color.Green;
this.TransparencyKey = System.Drawing.Color.White;
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);

但是现在当窗口是透明的 Cursor.Hide(); 不再工作了......如何解决这个问题?

【问题讨论】:

  • 您是否在使用其他控件,例如表单中的面板?
  • 不,这是空白窗口。

标签: c# winforms cursor mouseevent transparency


【解决方案1】:

您可以制作一个“空白”光标,并设置

myForm.Cursor = blankCursor;

这将使该特定表单显示一个特定的光标,它可以是完全透明的。

【讨论】:

  • System.Windows.Forms.Cursor 不包含“无”的定义。
  • @mgulan 对不起...我对 wpf 感到困惑
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多