CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2001
    Posts
    34

    Flash animation as ActiveX control in MFC?

    Greetings.

    How do I make my flash animation as part of my MFC program?

    I tried inserting an ActiveX control(Shockwave Flash) in my dialog and set the movie URL and base URL to "animation.swf", the animation is in the same folder as the program. However the animation does not shows, right-clicking on the control shows "Movie is not loaded".

    What are the things that I have to set?

    Advanced thanks for any help rendered.



  2. #2
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Flash help

    If you want to access al the Flash functions then you should put some code into your dialog *.cpp /*.h file.

    Like this.


    // In CBlaBlaDlg header file
    #include "shockwaveflash.h"
    //
    // In CBlaBlaDlg implementation file *.Cpp
    BOOL CBlaBlaDlg ::OnInitDialog()
    {
    CDialog::OnInitDialog();

    // Set the icon for this dialog. The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon

    // TODO: Add extra initialization here


    //--------------------------------------------------------------------------
    // "IDC_SHOCKWAVEFLASH1" is here the name for the flash control in your dialog.
    CShockwaveFlash* pFlashBox =
    static_cast<CShockwaveFlash*>(GetDlgItem(IDC_SHOCKWAVEFLASH1));

    pFlashBox->SetBackgroundColor(0xC0C0C0);
    pFlashBox->LoadMovie(1,"Flashtest.swf");
    pFlashBox->SetMenu(false); // It's not gone entirely.
    //--------------------------------------------------------------------------

    return TRUE; // return TRUE unless you set the focus to a control
    }




    I hope the little info helps

    Gr, David Smulders




    /* Regards, David Smulders */

  3. #3
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Re: Flash help

    Or the whole path is an option [file:///C:\\Flashtest.swf]


    /*Gr, David Smulders*/


    /* Regards, David Smulders */

  4. #4
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Re: Flash (correct) help

    This is the correct code:

    // *.h
    #include "shockwaveflash.h"
    //

    CString m_nStartPath;
    CString m_nStartPathFi;
    char StartPath[MAXBUFF_DIR_LENGTH];
    //
    #define MAXBUFF_DIR_LENGTH 1024


    //*.cpp

    // -------------- GetCurrentDirectory -----------------------------
    GetCurrentDirectory(MAXBUFF_DIR_LENGTH, StartPath);

    m_nStartPath = StartPath;

    if (m_nStartPath.Right(1) == "\\")
    {
    m_nStartPathFi = m_nStartPath;
    }
    else
    {
    m_nStartPathFi = (m_nStartPath + "\\");
    }

    // SetWindowText(m_nStartPathFi); // test

    // -------------- Flash Control -----------------------------

    CShockwaveFlash* pFlashBox =
    static_cast<CShockwaveFlash*>(GetDlgItem(IDC_FLASH));

    CString FileString ="file:///";
    CString m_SwfString ="Flashtest.swf";
    CString UrlString = FileString + m_nStartPathFi + m_SwfString;

    pFlashBox-> SetMovie(UrlString);

    SetWindowText(UrlString); // test

    // -------------- Flash Setting's -----------------------------

    pFlashBox->Play();
    pFlashBox->SetMenu(false); // It's not gone entirely.
    pFlashBox->SetBackgroundColor(0x00CC00);
    // --------------------------------------------------------------







    /*Gr, David Smulders*/


    /* Regards, David Smulders */

  5. #5
    Join Date
    Mar 2001
    Location
    Singapore
    Posts
    57

    Re: Flash (correct) help

    Hi, is there any way to grab a frame or save a .swf file using the active X control?


  6. #6
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Re: Flash (correct) help

    I believe the only way to write an swf file is to use a library like the one on this page.
    http://openswf.org/




    /*Gr, David Smulders*/


    /* Regards, David Smulders */

  7. #7
    Join Date
    Jul 2001
    Location
    College Place, WA
    Posts
    3

    Re: Flash control problems

    I can successfully play a Flash Movie using this code, but I can't control it. That is subsequent calls like:

    pFlashBox->Stop();
    pFlashBox->Rewind();

    do nothing.

    Do you have any ideas?

    Thanks,

    --Rudy



  8. #8
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Re: Flash control problems

    Hi,
    If you get the error C2065: 'pFlashBox' : undeclared identifier then there are some lines missing in your code I think.
    And if you can use the classWizard you can do it like this m_FlashCtrl.Stop();



    If this sample code doesn’t work for you, post some lines of you’re source code so I can look at it.


    void CFlashDlg::OnButton1()
    {
    CShockwaveFlash* pFlashBox =
    static_cast<CShockwaveFlash*>(GetDlgItem(IDC_FLASH));

    pFlashBox->Stop();
    // m_FlashCtrl.Stop(); // Put this Line in your *.h file
    // ShockwaveFlash m_TestFlash;
    }





    /*Gr, David Smulders*/


    /* Regards, David Smulders */

  9. #9
    Join Date
    Feb 2002
    Posts
    1

    Re: Flash (correct) help

    hi,I can't find "shockwaveflash.h" ,but I found an activex control named
    CShockwaveCtrl,however,I use it for playing swf,after calling the function"play",Nothing had happend.why?
    Thank


  10. #10
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    100

    Re: Flash (correct) help (flash5ocx.zip)

    Hi, I have put a sample at this link.
    I’ll hope it helps.

    http://www.dinaric.org/software/cpp/flash5ocx.zip


    /*Gr, David Smulders*/


    /* Regards, David Smulders */

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured