Solution to failed to import activex when importing flash

Source: Internet
Author: User

4. Insert Shockwave Flash Object

Right-click the Toolbox and Choose "Choose Items..." to add COM Components.

Tricky Point: A Macromedia Flash Factory Object in COM Component is also linked to C: \ Windows \ System32 \ Macromed \ Flash \ Flash9c. ocx, but do not select this Component here. Otherwise, "Failed to import the ActiveX control" may appear. You can use regsvr32.exe Flash9c. ocx registers Flash9c in the command line. ocx control. The following registration success prompt is displayed:

 

--------------------------------------------------

Http://blogs.msdn.com/ B /jijia/archive/2007/06/07/wpf-flash-activex.aspx

How to embed Flash (ActiveX) in WPF)
Jijia Huang


7 Jun 2007 AM

  • 3
Background

A recent Partner wants to embed the previous Flash into a brand new WPF Application and.. NET 3.0 rich user experience combined with Flash animation to better serve its users.

Embedding Flash is equivalent to embedding an ActiveX control. Some Tricky points should be noted during the embedding process. The steps for embedding Flash control in WPF Application are briefly described below, and remind you of some issues that need attention.

Development Environment

Visual Studio 2008 Beta1 (Code name: Orcas), Windows Vista, Flash Player 9,

Method

1. Create a WPF Application.

First, create a WPF Application named FlashinWPF

2. Set the Window attribute.

Modify the Window attribute in XAML, add the Loaded event, and set the x: Name of the default Grid to "FlashGrid". The Code is as follows:

<Window x: Class = "FlashinWPF. Window1"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "Flash in WPF" Loaded = "WindowLoaded" Height = "500" Width = "600">
<Grid x: Name = "FlashGrid">
</Grid>
</Window>

3. Create a Windows Forms Control Library

As a display layer project, WPF Application cannot insert COM Component itself. Therefore, you need to use Windows Form to introduce ActiveX control.

 

4. Insert Shockwave Flash Object

Right-click the Toolbox and Choose "Choose Items..." to add COM Components.

 

Tricky Point:In COM Component, a Macromedia Flash Factory Object is also linked to C: \ Windows \ System32 \ Macromed \ Flash \ Flash9c. ocx, but do not select this Component here. Otherwise, "Failed to import the ActiveX control" may appear. You can use regsvr32.exe Flash9c. ocx registers Flash9c in the command line. ocx control. The following registration success prompt is displayed:

 

 

5. Create a Flash Object

After a Shockwave Flash Object is added, an Object named AxShockwaveFlashObjects is automatically added to the Flash Control project.

The axShockwaveFlash1 object is added by default in UserControl1.Designer. cs.

Private AxShockwaveFlashObjects. AxShockwaveFlash axShockwaveFlash1;

6. Compile Flash Control

 

7. Add Reference in FlashinWPF

Added AxInterop. ShockwaveFlashObjects. dll compiled in Flash Control.

 

Add DLL used to integrate ActiveX in Windows Form

 

Add Windows Form DLL

 

8. Modify the Codebehind of the Window.

The code and comments of Window1.xaml. cs are as follows:

Private void WindowLoaded (object sender, RoutedEventArgs e)
{
// Create a host Object
System. Windows. Forms. Integration. WindowsFormsHost host = new System. Windows. Forms. Integration. WindowsFormsHost ();

// Instantiate axShockwaveFlash1
AxShockwaveFlashObjects. AxShockwaveFlash axShockwaveFlash1 = new AxShockwaveFlashObjects. AxShockwaveFlash ();

// Load. axShockwaveFlash1
Host. Child = axShockwaveFlash1;

// Embed the host object into FlashGrid
This. FlashGrid. Children. Add (host );

// Set the relative path of the. swf File
String swfPath = System. Environment. CurrentDirectory;
SwfPath + = @ "\ sample.swf ";
AxShockwaveFlash1.Movie = swfPath;
}

 

9. Add a. swf File

Select Always Copy to Output Directory to use the WPF Applicaiton to call the Flash

 

10. Success

 

Click here to download this project file.

Tips

You can use the powerful Object Browser in Visual Studio to view various FlashObjects methods and abstract classes, as shown in

Technorati tags: WPF, Flash, ActiveX, AxHost, AxShockwaveFlashObjects FlashinWPF.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.