毕业设计中要实现课件远程浏览,现在打开本地的powerpoitn文件显示在窗体的axWebBrowser1上,我希望能在powerpoint使用画笔画东西,可是axWebBrowser1没有鼠标等事件,所以我想拉一个panel控件覆盖在axWebBrowser1控件上,然后直接在panel上画画,但是要让panel完全透明,这样才能看到axWebBrowser1上的内容,这样一来好象就是直接画在axWebBrowser1上了,请问能实现这样的透明吗?

解决方案 »

  1.   

    继承 Panel,创建一个新控件类。
    在构造方法中,添加以下几句:
    // Set control styles
    this.SetStyle(ControlStyles.DoubleBuffer, true);
    this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
    this.SetStyle(ControlStyles.UserPaint, true);
    this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
    this.BackColor = Color.Transparent;
    /// <summary>
    /// Raises the PaintBackground event
    /// </summary>
    /// <param name="e">A PaintEventArgs that contains the event data</param>
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
    // don't let windows paint our background as it will be black
    // (we'll paint the background in OnPaint instead)
    }/// <summary>
    /// Raises the Paint event
    /// </summary>
    /// <param name="e">A PaintEventArgs that contains the event data</param>
    protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaintBackground(e);// 做一些其他的绘出操作
    ...// 下面的事件是否需要再引发,自己看着办。
    // 如果不需要,删掉它。 
    if (this.Paint != null)
          this.Paint(this, e);
    }
      

  2.   

    后面两个方法,是 override ,注意了。
    有没有用,自己试试吧。反正我要实现透明控件,都是这么做的。不过,楼主的实践环境我未曾做过。