Embedding flash in winform (using the EmbedMovie property)

Embedding Flash in WinForms can be achieved by using the WebBrowser control. It is important to note that the Flash plugin must already be installed on the user’s computer.

Here is a sample code demonstrating how to embed Flash in WinForms.

using System;
using System.Windows.Forms;

namespace WinFormsFlashEmbed
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            // 设置WebBrowser控件的属性
            webBrowser1.AllowWebBrowserDrop = false;
            webBrowser1.IsWebBrowserContextMenuEnabled = false;
            webBrowser1.WebBrowserShortcutsEnabled = false;
            webBrowser1.ObjectForScripting = this;

            // 加载Flash文件
            webBrowser1.Navigate("path_to_flash_file.swf");
        }
    }
}

Please note that “path_to_flash_file.swf” should be replaced with the actual path to your Flash file.

Add a WebBrowser control to the window design and name it “webBrowser1.” Next, associate the MainForm_Load event with the MainForm_Load method.

This code will initialize a WebBrowser control and load the specified Flash file when the form is loaded.

Hope this can assist you in successfully embedding Flash in WinForms.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds