Description
This example creates an Elliptic panel on which a movie is displayed.
Form1 contains the following components:
EllipticPanel.cpp
1) a TOpenDialog component to select the file we want to open.
2) a TButton to open the clip.
3) a TMediaPlayer component to play the clip.
4) a TPanel component on which the movie is displayed.
#include "EllipticPanel.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
Update();
Screen->Cursor = crHourGlass;
MediaPlayer1->FileName=OpenDialog1->FileName;
try
{
MediaPlayer1->Open();
}
catch (...)
{
Application->MessageBox( "Exception: Open File",
mtWarning, MB_ICONWARNING | MB_OK );
}
Screen->Cursor = crArrow;
MediaPlayer1->DisplayRect = Rect(0, 0, 0, 0);
Panel1->Top = 200;
Panel1->Width = MediaPlayer1->DisplayRect.Right;
Panel1->Height = MediaPlayer1->DisplayRect.Bottom;
Panel1->Visible = true;
//Win32 API
HRGN hRegion = CreateEllipticRgn( 0, 0, Panel1->Width, Panel1->Height );
//Win32 API
SetWindowRgn( Panel1->Handle, hRegion, true);
}
EllipticPanel.h
#ifndef EllipticPanelH
#define EllipticPanelH
//-----------------------------------------------------------------------
#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\ExtCtrls.hpp>
#include <vcl\MPlayer.hpp>
#include <vcl\Dialogs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TPanel *Panel1;
TMediaPlayer *MediaPlayer1;
TOpenDialog *OpenDialog1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
extern TForm1 *Form1;
Copyright © 1997-2002 Rodolfo A. Frino. All rights reserved.