How to display Flash animation in Visual C++ 6

Wanna display flash swf movie file in your VC++ application. Dont worry! Here I give the steps below:

1. Start Visual C++ 6.0 wizard, select type and name of new MFC application project: FlashViewer. Click OK to start MFC Application Wizard:

2. Select Dialog based project type and click Next. Next page will appear:

3. Select aboutbox, 3d control and ActiveXControls and Click Finish to create new project. Visual C++ IDE will display summary information for new project: Click OK to open new dialog based project in VC++ IDE:

Now we have to import Shockwave ActiveX control to controls toolbar to display flash file in our application.

4. Go to Project menu, select Add To Project sub-menu and then click Components and Controls command: Visual C++ will display “Components and Controls Gallery” dialog.

5. Click on “Registered ActiveX Controls” to display list of available ActiveX controls:

6. Find and select Shockwave Flash Object ActiveX control in the list of available controls and click “Insert” to add this control to controls toolbar.

Registered ActiveX controls

VC will generate special C++ class that will help to interact with this control:

7. Click OK and VC will generate new “CShockwaveFlash” class in ShockwaveFlash.cpp and ShockwaveFlash.h files.

8. “Shockwave Flash Object” control will appear on controls toolbar:

9. Click on “Shockwave Flash Object” icon and then click on dialog form. Answer “OK” to add new component to dialog:

Confirmation message box

10. New control will be added. Now we will add dialog class member that will handle Flash control. Right-click on dialog and select “Class Wizard” to invoke Class Wizard:

11. Class Wizard dialog will appear. Select Member Variables tab and click Add Variable… button to add new variable:

Enter name of new varaible: m_FlashPlayer and click OK:

Add Member dialog

12. Now click OK to close MFC ClassWizard.

Now we will place code that will load “nightFall.swf” into flash player control.

13. Right-click on dialog form and select “Events..” to invoke Events dialog:Select and double-click on WM_INITDIALOG caption.

14. Code Editor window will appear. CDisplayFlashDlg::OnInitDialog() function is responsible for handling initialization code so we will add our code here.

Add this line below // TODO: Add extra initialization here:


15. Run application by pressing F5 or using Build menu:

You will see application that will display NightFall.SWF flash movie using Shockwave Flash Object ActiveX control:

You can download the source code of this example here: