简体   繁体   English

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

[英]How to make Transparent Web-browser control

I have a system windows forms where i show the web browser control over the media-player control as shown in image below, 我有一个系统窗口表单,其中显示了对媒体播放器控件的Web浏览器控件,如下图所示, 在此处输入图片说明

I want to make Transparent web browser control . 我想做透明的Web浏览器控件 I have try many things but i am not able to make transparency over web browser control, i have try : 我已经尝试了很多东西,但是我无法通过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; 

My code is : 我的代码是:

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;
        } 
    }    
}

you have to make another form with a web browser control set the opacity 50% in the form properties and then call on button or by some other method it will be work: 您必须使用Web浏览器控件制作另一个表单,并在form properties中将opacity 50%设置为opacity 50% ,然后调用按钮或通过其他方法进行操作:

private void button1_Click(object sender, EventArgs e)
        {

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

By this technique u can set the opacity over web browser control/full form 通过这种技术,您可以通过网络浏览器控件/完整格式设置opacity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM