Delphi 按F11程序全屏


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    OriginalBounds: TRect;
    OriginalWindowState: TWindowState;
    ScreenBounds: TRect;
    procedure SwitchFullScreen;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
const
  KeyF11 = 122;
begin
  if Key = KeyF11 then SwitchFullScreen;
end;
 
procedure TForm1.SwitchFullScreen;
begin
  if BorderStyle <> bsNone then begin
    // To full screen
    OriginalWindowState := WindowState;
    OriginalBounds := BoundsRect;
 
    BorderStyle := bsNone;
    ScreenBounds := Screen.MonitorFromWindow(Handle).BoundsRect;
    with ScreenBounds do
      SetBounds(Left, Top, Right - Left, Bottom - Top) ;
  end else begin
    // From full screen
    {$IFDEF MSWINDOWS}
    BorderStyle := bsSizeable;
    {$ENDIF}      
    if OriginalWindowState = wsMaximized then
      WindowState := wsMaximized
    else
      with OriginalBounds do
        SetBounds(Left, Top, Right - Left, Bottom - Top) ;
    {$IFDEF LINUX}
    BorderStyle := bsSizeable;
    {$ENDIF}  
  end;
end;

end.

相关阅读 >>

Delphi的combobox不能输入只能选择

Delphi idhttp上传图给asp完美解决

Delphi datasnap传输流/文件问题

Delphi 得到cxgrid筛选后的记录数

Delphi xe7中stringgrid组件的使用

重新组织编写Delphi的md2、md4、md5类

Delphi cxdbtreelist:最简单的节点图标添加方法

Delphi ansiendstext 用法之一(路径结尾自动加\)

Delphi 对zlib单元进行再封装

Delphi 图像识别技术(逐行扫描识别)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...