如何进行透明的Web浏览器控制

时间:2015-05-04 09:03:39

标签: c# .net

我有一个系统窗口表单,其中我显示了对媒体播放器控件的Web浏览器控制,如下图所示,     enter image description here

我想要透明的网络浏览器控制。我尝试了很多东西但是我无法通过Web浏览器控制实现透明度,我尝试了:

this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.FromArgb(0, 0, 0, 0);
            this.TransparencyKey = Color.Red;
            this.BackColor = Color.Magenta;
            this.TransparencyKey = Color.Magenta;*/
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent; 

我的代码是:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.DirectX.AudioVideoPlayback;
using System.Windows.Forms;

namespace Windows_Video
{
    public partial class Form1 : Form
    {
        Video vdo;

        public string mode = "play";
        public string PlayingPosition, Duration;

        public Form1()
        {

            InitializeComponent();
          //  VolumeTrackBar.Value = 4;

        }
        private void Form1_Load(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.textBox1.Text = openFileDialog1.FileName;
            }
            axWindowsMediaPlayer1.URL = textBox1.Text;
            axWindowsMediaPlayer1.Ctlcontrols.play();

        }
    private void button1_Click(object sender, EventArgs e)
        {
         /*   OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.textBox1.Text = openFileDialog1.FileName;
            }*/
        }    

        private void button2_Click(object sender, EventArgs e)
        {

        //    axWindowsMediaPlayer1.URL = textBox1.Text;
         //   axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //this.BackColor = System.Drawing.Color.Transparent;
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent;
        } 
    }    
}

1 个答案:

答案 0 :(得分:1)

你必须使用网页浏览器控件创建另一个表单,在opacity 50%中设置form properties,然后按下按钮或其他方法,它将起作用:

private void button1_Click(object sender, EventArgs e)
        {

            Form2 min = new Form2();
            min.Show();
        }  

通过这种技术,您可以通过Web浏览器控件/完整表单设置opacity