0
我在Windows窗体应用程序中使用Webview(实际上是Geckofx),并希望在Webview上方具有透明的拖放布局 - 如果可能,还应该通过鼠标事件到Webview。 这可能吗?C#Winforms:透明拖放叠加
我在Windows窗体应用程序中使用Webview(实际上是Geckofx),并希望在Webview上方具有透明的拖放布局 - 如果可能,还应该通过鼠标事件到Webview。 这可能吗?C#Winforms:透明拖放叠加
我的解决办法是,也传递到底层父窗体
public class TransparentPanel : Panel
{
Timer Wriggler = new Timer();
public TransparentPanel()
{
Wriggler.Tick += new EventHandler(TickHandler);
this.Wriggler.Interval = 500;
this.Wriggler.Enabled = true;
}
protected void TickHandler(object sender, EventArgs e)
{
this.InvalidateEx();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}
protected void InvalidateEx()
{
if (Parent == null)
{
return;
}
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}
protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x0084;
const int HTTRANSPARENT = (-1);
if (m.Msg == WM_NCHITTEST)
{
m.Result = (IntPtr)HTTRANSPARENT;
}
else
{
base.WndProc(ref m);
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Do not allow the background to be painted
}
}
你说的拖放布局意味着所有事件的透明面板? – mjwills
只是一个透明视图(即面板),其唯一目的是检测拖放事件 –