//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "MainUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FlashPlayerControl"
#pragma resource "*.dfm"
#pragma resource "res\\movie.res"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ButtonPlayEmbeddedSWFClick(TObject *Sender)
{
  TResourceStream* ResourceStream = new TResourceStream(0, "Movie", "SWF");
  FlashPlayerControl1->LoadMovieFromStream(0, ResourceStream);
  delete ResourceStream;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::ButtonPlayFromFileClick(TObject *Sender)
{
  if (OpenSWFDialog->Execute())
  {
    FlashPlayerControl1->Movie = OpenSWFDialog->FileName;
    FlashPlayerControl1->Play();
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::ButtonSaveAsBitmapClick(TObject *Sender)
{
  TPicture* Picture = new TPicture;
  Graphics::TBitmap* Bitmap = FlashPlayerControl1->CreateFrameBitmap();
  Picture->Bitmap = Bitmap;

  if (SaveAsBitmapDialog->Execute())
    Picture->SaveToFile(SaveAsBitmapDialog->FileName);

  delete Bitmap;
  delete Picture;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::ButtonSiteClick(TObject *Sender)
{
  ShellExecute(0, NULL, "http://www.f-in-box.com/delphi/", NULL, NULL, SW_SHOW);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::ButtonOrderClick(TObject *Sender)
{
  ShellExecute(0, NULL, "http://www.f-in-box.com/delphi/order.html", NULL, NULL, SW_SHOW);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::FormCreate(TObject *Sender)
{
  if (!Flashplayercontrol::IsFlashInstalled())
  {
    ShowMessage("The application needs Flash\nFlash is not installed");
    Application->Terminate();
  }

  TResourceStream* ResourceStream = new TResourceStream(0, "Movie", "SWF");
  FlashPlayerControl1->LoadMovieFromStream(0, ResourceStream);
  delete ResourceStream;

  OpenSWFDialog->InitialDir = ExtractFileDir(Application->ExeName);
  SaveAsBitmapDialog->InitialDir = ExtractFileDir(Application->ExeName);
}
//---------------------------------------------------------------------------

