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

#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::FormCreate(TObject *Sender)
{
   if (!Flashplayercontrol::IsFlashInstalled())
   {
     ShowMessage("The application needs Flash\nFlash is not installed");
     Application->Terminate();
   }

   if (!Flashplayercontrol::IsFormTransparentAvailable())
   {
     ShowMessage("Transluency based on Flash is not available");
     Application->Terminate();
   }

   TransparentFlashPlayerControl1->MakeParentTransparent = true;
   TResourceStream* ResourceStream = new TResourceStream(0, "Movie", "FLASH");
   TransparentFlashPlayerControl1->LoadMovieFromStream(0, ResourceStream);
   TransparentFlashPlayerControl1->Play();
   delete ResourceStream;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::FormKeyPress(TObject *Sender, char &Key)
{
  if (Key == VK_ESCAPE) Close();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::FormMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  if (MouseCapture)
  {
    TPoint pt;
    pt.x = X;
    pt.y = Y;
    pt = ClientToScreen(pt);
    Left = pt.x + FWindowLeftTop.x - FStartPoint.x;
    Top = pt.y + FWindowLeftTop.y - FStartPoint.y;
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::CloseMenuItemClick(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::MinimizeMenuItemClick(TObject *Sender)
{
  Application->Minimize();
}
//---------------------------------------------------------------------------

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

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

void __fastcall TMainForm::TransparentFlashPlayerControl1MouseDown(
      TObject *Sender, TMouseButton Button, TShiftState Shift, int X,
      int Y)
{
  if (!MouseCapture)
  {
    MouseCapture = true;
    FStartPoint.x = X;
    FStartPoint.y = Y;
    FStartPoint = TransparentFlashPlayerControl1->ClientToScreen(FStartPoint);
    FWindowLeftTop.x = Left;
    FWindowLeftTop.y = Top;
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::TransparentFlashPlayerControl1MouseUp(
      TObject *Sender, TMouseButton Button, TShiftState Shift, int X,
      int Y)
{
  MouseCapture = false;
}
//---------------------------------------------------------------------------

