可以自己做一個窗體﹐要怎么控制都可以﹐下面是我在其它應用上的一個單元。
其中就生成一個窗體﹐這里只控制了它的標題﹐大小和圖標﹐你可以參考參考。
unit u_Machine;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,BelButton,MPlayer;
Type
TMac=Class
private
FForm:TForm;
FCanvas:TCanvas;
FBmpBack:TBitmap;
FBmpFore:TBitmap;
FintButton:Integer;
FTimBtn:TTimer;
FDisplay:TForm;
MPlayer:TMediaPlayer;
FButton:Array [1..16] of TBelButton;
FBtnPos:Array [1..16] of TPoint;
public
constructor Create(AForm:TForm);
destructor Destroy;override;
procedure ShowButton(Sender:TObject);
procedure PlayMpeg(Sender:TObject);
procedure DisplayResize(Sender:TObject);
procedure Show;
procedure Hide;
end;
implementation
uses u_Common,u_Effect;
{ TMac }
constructor TMac.Create(AForm:TForm);
var
i:integer;
ico:TIcon;
begin
FForm:=AForm;
FCanvas:=FForm.Canvas;
FintButton:=1;
FBmpBack:=TBitmap.Create;
FBmpBack.LoadFromFile(BmpName[59]);
////背景畫面---1
FBmpFore:=TBitmap.Create;
FBmpFore.LoadFromFile(BmpName[60]);
//前景畫面---2
FTimBtn:=TTimer.Create(nil);
FTimBtn.Interval:=1;
FTimBtn.OnTimer:=ShowButton;
FTimBtn.Enabled:=False;
MPlayer:=TMediaPlayer.Create(FForm);
MPlayer.Parent:=FForm;
MPlayer.Visible:=False;
FDisplay:=TForm.Create(FForm);
FDisplay.Position:=poScreenCenter;
FDisplay.FormStyle:=fsStayOnTop;
FDisplay.Width:=400;
FDisplay.Height:=300;
ico:=TIcon.Create;
ico.LoadFromFile(GetPicPath+'ky.ico');
FDisplay.Icon:=ico;
ico.Free;
FDisplay.Caption:='現場鏡頭片段';
FDisplay.OnResize:=DisplayResize;
MPlayer.Display:=FDisplay;
MPlayer.DisplayRect:=FDisplay.ClientRect;
FBtnPos[1].x:=13;
FBtnPos[1].y:=125;
FBtnPos[2].x:=13;
FBtnPos[2].y:=225;
FBtnPos[3].x:=13;
FBtnPos[3].y:=329;
FBtnPos[4].x:=13;
FBtnPos[4].y:=428;
FBtnPos[5].x:=180;
FBtnPos[5].y:=125;
FBtnPos[6].x:=180;
FBtnPos[6].y:=227;
FBtnPos[7].x:=180;
FBtnPos[7].y:=329;
FBtnPos[8].x:=180;
FBtnPos[8].y:=428;
FBtnPos[9].x:=346;
FBtnPos[9].y:=127;
FBtnPos[10].x:=346;
FBtnPos[10].y:=227;
FBtnPos[11].x:=346;
FBtnPos[11].y:=329;
FBtnPos[12].x:=360;
FBtnPos[12].y:=428;
FBtnPos[13].x:=585;
FBtnPos[13].y:=127;
FBtnPos[14].x:=585;
FBtnPos[14].y:=227;
FBtnPos[15].x:=585;
FBtnPos[15].y:=329;
FBtnPos[16].x:=585;
FBtnPos[16].y:=428;
for i:=1 to 16do
begin
FButton:=TBelButton.Create(FForm);
FButton.Parent:=FForm;
FButton.Tag:=i;
FButton.Visible:=False;
FButton.OnClick:=PlayMpeg;
end;
for i:=1 to 4do
begin
FButton.Left:=FBtnPos.x;
FButton.Top:=FBtnPos.y;
FButton.Width:=130;
FButton.Height:=50;
end;
for i:=5 to 8do
begin
FButton.Left:=FBtnPos.x;
FButton.Top:=FBtnPos.y;
FButton.Width:=160;
FButton.Height:=50;
end;
for i:=9 to 12do
begin
FButton.Left:=FBtnPos.x;
FButton.Top:=FBtnPos.y;
FButton.Width:=200;
FButton.Height:=55;
end;
for i:=13 to 16do
begin
FButton.Left:=FBtnPos.x;
FButton.Top:=FBtnPos.y;
FButton.Width:=200;
FButton.Height:=55;
end;
end;
destructor TMac.Destroy;
var
i:integer;
begin
for i:=1 to 16do
FButton.Free;
FBmpBack.Free;
FBmpFore.Free;
FTimBtn.Free;
MPlayer.Free;
inherited;
end;
procedure TMac.DisplayResize(Sender: TObject);
begin
MPlayer.DisplayRect:=FDisplay.ClientRect;
end;
procedure TMac.Hide;
var
i:integer;
begin
FTimBtn.Enabled:=False;
for i:=1 to 16do
FButton.Visible:=False;
MPlayer.Close;
FDisplay.Close;
end;
procedure TMac.PlayMpeg(Sender: TObject);
var
S:String;
T:Integer;
begin
//MPlayer.Close;
T:=(Sender as TBelButton).Tag;
S:=GetAppPath+'Mpeg/';
S:=S+'M';
S:=S+Copy('00',1,2-Length(IntToStr(T)))+IntToStr(T);
S:=S+'.Mpg';
MPlayer.FileName:=S;
MPlayer.Open;
MPlayer.DisplayRect:=FDisplay.ClientRect;
FDisplay.Show;
MPlayer.Play;
end;
procedure TMac.Show;
begin
FCanvas.Draw(0,0,FBmpBack);
FintButton:=1;
FTimBtn.Enabled:=True;
end;
procedure TMac.ShowButton(Sender: TObject);
var
i:Integer;
begin
if FintButton<20 then
//20
inc(FintButton)
else
begin
for i:=1 to 16do
FButton.Visible:=True;
FCanvas.Draw(0,0,FBmpFore);
FTimBtn.Enabled:=False;
end;
end;
end.
有問題請來信﹕fancy105@163.com