Jaki jest najlepszy sposób, aby aplikacja Delphi była całkowicie pełnoekranowa?

Jaki jest najlepszy sposób, aby aplikacja delphi (delphi 2007 dla win32 tutaj) była całkowicie pełnoekranowa, usuwając obramowanie aplikacji i zasłaniając pasek zadań systemu windows ?

Szukam czegoś podobnego do tego, co robi IE po wciśnięciu F11.

Chciałbym, aby to była opcja run time dla użytkownika, a nie decyzja o czasie projektowania przez moje dobre ja.

Jak wspomniano w zaakceptowanej odpowiedzi

BorderStyle := bsNone; 
To była część sposobu, aby to zrobić. Dziwnie trzymałem uzyskanie błędu E2010 Incompatible types: 'TFormBorderStyle' and 'TBackGroundSymbol' Podczas używania tej linii(inny typ miał zdefiniowaną bsNone).

Aby to przezwyciężyć musiałem użyć:

BorderStyle := Forms.bsNone;
Author: Roddy, 2008-08-18

9 answers

Cóż, to zawsze działało dla mnie. Wydaje się prostsze...

procedure TForm52.Button1Click(Sender: TObject);
begin
  BorderStyle := bsNone;
  WindowState := wsMaximized;
end;
 29
Author: Roddy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-08-18 11:30:00

W wyszukiwarce Google pojawiły się następujące, dodatkowe metody:

(choć myślę, że najpierw wypróbowałbym metodę Roddy ' ego)

Ręcznie wypełnij ekran (from: About Delphi)

procedure TSomeForm.FormShow(Sender: TObject) ;
var
   r : TRect;
begin
   Borderstyle := bsNone;
   SystemParametersInfo
      (SPI_GETWORKAREA, 0, @r,0) ;
   SetBounds
     (r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top) ;
end;

Wariacja na temat Roddy

FormStyle := fsStayOnTop;
BorderStyle := bsNone;
Left := 0;
Top := 0;
Width := Screen.Width;
Height := Screen.Height;

Sposób na WinAPI (by Peter Below from TeamB)

private  // in form declaration
    Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);
      message WM_GETMINMAXINFO;

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.Button2Click(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 ));
  //  Label2.caption := IntToStr(GetDeviceCaps( Canvas.handle, VERTRES ));
  End
  Else
    BoundsRect := Rect;
end; 
 10
Author: onnodb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-08-18 11:41:42

Zmaksymalizuj formularz i ukryj pasek tytułu . Linia maximize jest wykonana z pamięci, ale jestem prawie pewien, że WindowState jest właściwością, którą chcesz.

Jest też ten artykuł, ale wydaje mi się to zbyt skomplikowane.

procedure TForm1.FormCreate(Sender: TObject) ;
begin
   //maximize the window
   WindowState := wsMaximized;
   //hide the title bar
   SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);
   ClientHeight := Height;
end;

Edit: oto pełny przykład z opcjami "Pełny ekran" i "przywróć". Podzieliłem poszczególne części na małe procedury dla maksymalnej jasności, więc to może być znacznie skompresowane na kilka linii.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    btnGoFullScreen: TButton;
    btnNotFullScreen: TButton;
    btnShowTitleBar: TButton;
    btnHideTitleBar: TButton;
    btnQuit: TButton;
    procedure btnGoFullScreenClick(Sender: TObject);
    procedure btnShowTitleBarClick(Sender: TObject);
    procedure btnHideTitleBarClick(Sender: TObject);
    procedure btnNotFullScreenClick(Sender: TObject);
    procedure btnQuitClick(Sender: TObject);
  private
    SavedLeft : integer;
    SavedTop : integer;
    SavedWidth : integer;
    SavedHeight : integer;
    SavedWindowState : TWindowState;
    procedure FullScreen;
    procedure NotFullScreen;
    procedure SavePosition;
    procedure HideTitleBar;
    procedure ShowTitleBar;
    procedure RestorePosition;
    procedure MaximizeWindow;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnQuitClick(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TForm1.btnGoFullScreenClick(Sender: TObject);
begin
  FullScreen;
end;

procedure TForm1.btnNotFullScreenClick(Sender: TObject);
begin
  NotFullScreen;
end;

procedure TForm1.btnShowTitleBarClick(Sender: TObject);
begin
  ShowTitleBar;
end;

procedure TForm1.btnHideTitleBarClick(Sender: TObject);
begin
  HideTitleBar;
end;

procedure TForm1.FullScreen;
begin
  SavePosition;
  HideTitleBar;
  MaximizeWindow;
end;

procedure TForm1.HideTitleBar;
begin
  SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);
  ClientHeight := Height;
end;

procedure TForm1.MaximizeWindow;
begin
  WindowState := wsMaximized;
end;

procedure TForm1.NotFullScreen;
begin
  RestorePosition;
  ShowTitleBar;
end;

procedure TForm1.RestorePosition;
begin
  //this proc uses what we saved in "SavePosition"
  WindowState := SavedWindowState;
  Top := SavedTop;
  Left := SavedLeft;
  Width := SavedWidth;
  Height := SavedHeight;
end;

procedure TForm1.SavePosition;
begin
  SavedLeft := Left;
  SavedHeight := Height;
  SavedTop := Top;
  SavedWidth := Width;
  SavedWindowState := WindowState;
end;

procedure TForm1.ShowTitleBar;
begin
  SetWindowLong(Handle,gwl_Style,GetWindowLong(Handle,gwl_Style) or ws_Caption or ws_border);
  Height := Height + GetSystemMetrics(SM_CYCAPTION);
  Refresh;
end;

end.
 2
Author: JosephStyons,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-08-18 13:45:42

Umieścić w formularzu onShow kod zdarzenia:

  WindowState:=wsMaximized;

I do OnCanResize to:

  if (newwidth<width) and (newheight<height) then
    Resize:=false;
 2
Author: Taras,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-08-08 14:51:48

Jak ograniczyć podformułę w formularzu głównym, jakby była to aplikacja MDI. ale bez bólu głowy! (Uwaga: odpowiedzi na tej stronie pomogły mi to zadziałać, dlatego opublikowałem moje rozwiązanie tutaj)

private
{ Private declarations }
  StickyAt: Word;
  procedure WMWINDOWPOSCHANGING(Var Msg: TWMWINDOWPOSCHANGING); Message M_WINDOWPOSCHANGING;
  Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
Później...
    procedure TForm2.WMWINDOWPOSCHANGING(var Msg: TWMWINDOWPOSCHANGING);
    var
      A, B: Integer;
      iFrameSize: Integer;
      iCaptionHeight: Integer;
      iMenuHeight: Integer;
    begin

      iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);
      iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);
      iMenuHeight := GetSystemMetrics(SM_CYMENU);

      // inside the Mainform client area
      A := Application.MainForm.Left + iFrameSize;
      B := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight;

      with Msg.WindowPos^ do
      begin

        if x <= A + StickyAt then
          x := A;

        if x + cx >= A + Application.MainForm.ClientWidth - StickyAt then
          x := (A + Application.MainForm.ClientWidth) - cx + 1;

       if y <= B + StickyAt then
         y := B;

       if y + cy >= B + Application.MainForm.ClientHeight - StickyAt then
         y := (B + Application.MainForm.ClientHeight) - cy + 1;

      end;
end;
I jeszcze więcej...
Procedure TForm2.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);
var
  iFrameSize: Integer;
  iCaptionHeight: Integer;
  iMenuHeight: Integer;
Begin
  inherited;
  iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);
  iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);
  iMenuHeight := GetSystemMetrics(SM_CYMENU);
  With msg.MinMaxInfo^.ptMaxPosition Do
  begin
    // position of top when maximised
    X := Application.MainForm.Left + iFrameSize + 1;
    Y := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight + 1;
  end;
  With msg.MinMaxInfo^.ptMaxSize Do
  Begin
     // width and height when maximized
     X := Application.MainForm.ClientWidth;
     Y := Application.MainForm.ClientHeight;
  End;
  With msg.MinMaxInfo^.ptMaxTrackSize Do
  Begin
     // maximum size when maximised
     X := Application.MainForm.ClientWidth;
     Y := Application.MainForm.ClientHeight;
  End;
  // to do: minimum size (maybe)
End;
 1
Author: Freddie Bell,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-07-01 12:49:50

Musisz upewnić się, że pozycja formularza jest poDefaultPosOnly.

Form1.Position := poDefaultPosOnly;
Form1.FormStyle := fsStayOnTop;
Form1.BorderStyle := bsNone;
Form1.Left := 0;
Form1.Top := 0;
Form1.Width := Screen.Width;
Form1.Height := Screen.Height;

Przetestowany i działa na Win7 x64.

 0
Author: Edijs Kolesnikovičs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-07-29 14:46:01

Hm. Patrząc na odpowiedzi wydaje mi się, że pamiętam, jak radziłem sobie z tym około 8 lat temu, kiedy zakodowałem grę. Aby ułatwić debugowanie, użyłem kontekstu urządzenia normalnego, Delphi formularza jako źródła dla pełnoekranowego wyświetlacza.

Chodzi o to, że DirectX jest w stanie uruchomić dowolny kontekst urządzenia na pełnym ekranie-w tym ten przydzielony przez formularz.

Aby dać aplikacji "prawdziwe" pełnoekranowe możliwości, znajdź bibliotekę DirectX dla Delphi i prawdopodobnie będzie ona zawierać to, czego potrzebujesz po wyjęciu z pudełka.

 0
Author: Jon Lennart Aasenden,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-01 22:35:34

W moim przypadku jedynym działającym rozwiązaniem jest:

procedure TFormHelper.FullScreenMode;
begin
  BorderStyle := bsNone;
  ShowWindowAsync(Handle, SW_MAXIMIZE);
end;
 0
Author: Jacek Krawczyk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-11-09 13:46:27

Try:

Align = alClient    
FormStyle = fsStayOnTop

To zawsze wyrównuje się do głównego Monitora;

 -1
Author: Noener,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-05-15 13:04:03