2017-10-08 17 views
0

WindowsフォームアプリケーションでWebview(実際にはGeckofx)を使用していますが、透明なドラッグアンドドロップレイアウトをWebviewの上に置いておきたい場合は、可能であればマウスイベントWebviewに。 これは可能ですか?C#Winforms:透明なドラッグアンドドロップオーバーレイ

+0

に上のすべてのイベントを渡し透明パネルでありますか – mjwills

+0

ドラッグアンドドロップイベントを検出する唯一の目的を持つ透明なビュー(パネル) –

答えて

1

私のソリューションは、あなたがドラッグ・アンド・ドロップ・レイアウトとはどういう意味ですか?また、基本となる親フォーム

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 
    } 
} 
関連する問題