Как развернуть форму на весь экран, как в играх

{codecitation class=»brush: pascal; gutter: false;» width=»600px»}

interface

uses

Windows, Messages, SysUtils, Classes, Controls,

Forms,

StdCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

procedure WMGetMinMaxInfo(var msg: TWMGetMinMaxInfo);

message WM_GETMINMAXINFO;

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMGetMinMaxInfo(var msg:

TWMGetMinMaxInfo);

begin

inherited;

with msg.MinMaxInfo^.ptMaxTrackSize do begin

X := GetDeviceCaps( Canvas.handle, HORZRES )

(Width — ClientWidth);

Y := GetDeviceCaps( Canvas.handle, VERTRES )

(Height — ClientHeight );

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

const

Rect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);

FullScreen: Boolean = False;

// Разворачиваем на весь экран

begin

FullScreen := not FullScreen;

if FullScreen then begin

Rect := BoundsRect;

SetBounds( Left — ClientOrigin.X,

Top — ClientOrigin.Y, GetDeviceCaps( Canvas.handle,

HORZRES )

(Width — ClientWidth), GetDeviceCaps( Canvas.handle,

VERTRES )

(Height — ClientHeight ));

end

else BoundsRect := Rect;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

Close;

end;

end.

{/codecitation}

Добавить комментарий