怎么样在delphi里实现全屏????(100分)

  • 主题发起人 主题发起人 westmoon
  • 开始时间 开始时间
W

westmoon

Unregistered / Unconfirmed
GUEST, unregistred user!
最近我在做一个播放器,想有个全屏功能,哪位高手能否告知实现方法?
 

新建一个form,去掉标题栏.
 
procedure TForm1.FormCreate(Sender: TObject);
begin


BorderStyle:= bsNone;
Height := screen.height;
Width := screen.width;
Position :=poScreenCenter;
FormStyle:= fsStayOnTop;
//这个一定要

end;
 
可以这样:
form1.BorderStyle := bsNone;
form1.WindowState := wsMaximized;
 
把BorderStyle 设为bsNone;
再最大化就全屏了。
 
上面的不行,没去掉任务栏。
我有一个例子,要的给我E-MAIL:inhu@21cn.com
 
谁说不行??? 自己去试试。
 
to zw84611:
"FormStyle:= fsStayOnTop;"只是将窗口置于最顶层,与全屏无关,并非一定要
 
用setwindowlong函数吧.
 
SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE)
and not WS_CAPTION);
看看下面这个程序,是否对你有帮助.
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, AxCtrls, OleCtrls, VCF1, Chartfx3;

type
TForm1 = class(TForm)
Chartfx1: TChartfx;
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure WMSysCommand(var Msg: TWMSysCommand);message WM_SYSCOMMAND;
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin

if (Msg.CmdType=SC_MAXIMIZE) then

begin

SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);
self.WindowState:=wsMaximized;
end
else

DefaultHandler(Msg);
Application.ProcessMessages;
end;


procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin

if Key=VK_ESCAPE then

begin

showmessage('Ok');
SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) or WS_CAPTION);
WindowState:=wsNormal;
end;

end;


end.

 
程序中有点BUG,只是全屏这部分你可以参考一下.
 
请大家试试我这个,这是我做的一个考试系统的相关部分:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Image1: TImage;
Panel3: TPanel;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Image5: TImage;
Image6: TImage;
Image7: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Panel4: TPanel;
Image8: TImage;
Label6: TLabel;
Panel5: TPanel;
Label7: TLabel;
Label8: TLabel;
Button2: TButton;
Button1: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Image8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

uses Unit2, MainFrm;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var temp:integer;
begin

left:=0;
top:=0;
width:=screen.width;
height:=screen.height;
systemParametersInfo(SPI_SCREENSAVERRUNNING,1,@temp,0);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
temp:integer;
begin

systemParametersInfo(SPI_SCREENSAVERRUNNING,0,@temp,0);
close;
LoginForm.Close
LoginForm.Free;
end;


procedure TForm1.Image1Click(Sender: TObject);
begin

application.MessageBox('对不起,考试时本功能已经被屏蔽!','提示',MB_OK + MB_DEFBUTTON1);
end;


procedure TForm1.Image2Click(Sender: TObject);
begin

application.MessageBox('对不起,考试时本功能已经被屏蔽!','提示',MB_OK + MB_DEFBUTTON1);
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

Panel5.Visible:=False
end;


procedure TForm1.Image8Click(Sender: TObject);
begin

Panel5.Visible:=True
end;


end.
 
用DirectDraw可以实现,效果就像游戏那样的全屏。很爽
 
后退
顶部