<p>What is the best way to make a delphi application (delphi 2007 for win32 here) go completely full screen, removing the application border and covering windows task bar ?</p>

<p>I am looking for something similar to what IE does when you hit F11.</p>

<p>I wish this to be a run time option for the user not a design time decision by my good self.</p>

<p>As Mentioned in the accepted answer </p>

<pre><code>BorderStyle := bsNone; 
</code></pre>

<p>was part of the way to do it.  Strangely I kept getting a <code>E2010 Incompatible types: 'TFormBorderStyle' and 'TBackGroundSymbol'</code> error when using that line (another type had <code>bsNone</code> defined).</p>

<p>To overcome this I had to use : </p>

<pre><code>BorderStyle := Forms.bsNone;
</code></pre>

[{'answer_id': 14458, 'author': 'JosephStyons', 'author_id': 672, 'author_profile': 'https://Stackoverflow.com/users/672', 'pm_score': 2, 'selected': False, 'text': '<p>Maximize the form and <a href="http://delphi.about.com/cs/adptips2000/a/bltip0100_5.htm" rel="nofollow noreferrer">hide the title bar</a>.  The maximize line is done from memory, but I\'m pretty sure WindowState is the property you want.</p>\n\n<p>There\'s also <a href="http://www.delphicorner.f9.co.uk/articles/forms5.htm" rel="nofollow noreferrer">this</a> article, but that seems too complicated to me.</p>\n\n<pre><code>procedure TForm1.FormCreate(Sender: TObject) ;\nbegin\n   //maximize the window\n   WindowState := wsMaximized;\n   //hide the title bar\n   SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);\n   ClientHeight := Height;\nend;\n</code></pre>\n\n<p>Edit:  Here\'s a complete example, with "full screen" and "restore" options.  I\'ve broken out the different parts into little procedures for maximum clarity, so this could be greatly compressed into just a few lines.</p>\n\n<pre><code>unit Unit1;\n\ninterface\n\nuses\n  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,\n  Dialogs, StdCtrls;\n\ntype\n  TForm1 = class(TForm)\n    btnGoFullScreen: TButton;\n    btnNotFullScreen: TButton;\n    btnShowTitleBar: TButton;\n    btnHideTitleBar: TButton;\n    btnQuit: TButton;\n    procedure btnGoFullScreenClick(Sender: TObject);\n    procedure btnShowTitleBarClick(Sender: TObject);\n    procedure btnHideTitleBarClick(Sender: TObject);\n    procedure btnNotFullScreenClick(Sender: TObject);\n    procedure btnQuitClick(Sender: TObject);\n  private\n    SavedLeft : integer;\n    SavedTop : integer;\n    SavedWidth : integer;\n    SavedHeight : integer;\n    SavedWindowState : TWindowState;\n    procedure FullScreen;\n    procedure NotFullScreen;\n    procedure SavePosition;\n    procedure HideTitleBar;\n    procedure ShowTitleBar;\n    procedure RestorePosition;\n    procedure MaximizeWindow;\n  public\n    { Public declarations }\n  end;\n\nvar\n  Form1: TForm1;\n\nimplementation\n\n{$R *.dfm}\n\nprocedure TForm1.btnQuitClick(Sender: TObject);\nbegin\n  Application.Terminate;\nend;\n\nprocedure TForm1.btnGoFullScreenClick(Sender: TObject);\nbegin\n  FullScreen;\nend;\n\nprocedure TForm1.btnNotFullScreenClick(Sender: TObject);\nbegin\n  NotFullScreen;\nend;\n\nprocedure TForm1.btnShowTitleBarClick(Sender: TObject);\nbegin\n  ShowTitleBar;\nend;\n\nprocedure TForm1.btnHideTitleBarClick(Sender: TObject);\nbegin\n  HideTitleBar;\nend;\n\nprocedure TForm1.FullScreen;\nbegin\n  SavePosition;\n  HideTitleBar;\n  MaximizeWindow;\nend;\n\nprocedure TForm1.HideTitleBar;\nbegin\n  SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_CAPTION);\n  ClientHeight := Height;\nend;\n\nprocedure TForm1.MaximizeWindow;\nbegin\n  WindowState := wsMaximized;\nend;\n\nprocedure TForm1.NotFullScreen;\nbegin\n  RestorePosition;\n  ShowTitleBar;\nend;\n\nprocedure TForm1.RestorePosition;\nbegin\n  //this proc uses what we saved in "SavePosition"\n  WindowState := SavedWindowState;\n  Top := SavedTop;\n  Left := SavedLeft;\n  Width := SavedWidth;\n  Height := SavedHeight;\nend;\n\nprocedure TForm1.SavePosition;\nbegin\n  SavedLeft := Left;\n  SavedHeight := Height;\n  SavedTop := Top;\n  SavedWidth := Width;\n  SavedWindowState := WindowState;\nend;\n\nprocedure TForm1.ShowTitleBar;\nbegin\n  SetWindowLong(Handle,gwl_Style,GetWindowLong(Handle,gwl_Style) or ws_Caption or ws_border);\n  Height := Height + GetSystemMetrics(SM_CYCAPTION);\n  Refresh;\nend;\n\nend.\n</code></pre>\n'}, {'answer_id': 14472, 'author': 'Roddy', 'author_id': 1737, 'author_profile': 'https://Stackoverflow.com/users/1737', 'pm_score': 6, 'selected': True, 'text': '<p>Well, this has always worked for me. Seems a bit simpler...</p>\n\n<pre><code>procedure TForm52.Button1Click(Sender: TObject);\nbegin\n  BorderStyle := bsNone;\n  WindowState := wsMaximized;\nend;\n</code></pre>\n'}, {'answer_id': 14480, 'author': 'onnodb', 'author_id': 1037, 'author_profile': 'https://Stackoverflow.com/users/1037', 'pm_score': 3, 'selected': False, 'text': '<p>A Google search turned up the following, additional methods:</p>\n\n<p>(though I think I\'d try Roddy\'s method first)</p>\n\n<h2><a href="http://delphi.about.com/cs/adptips2000/a/bltip0600_2.htm" rel="noreferrer">Manually fill the screen</a> (from: About Delphi)</h2>\n\n<pre><code>procedure TSomeForm.FormShow(Sender: TObject) ;\nvar\n   r : TRect;\nbegin\n   Borderstyle := bsNone;\n   SystemParametersInfo\n      (SPI_GETWORKAREA, 0, @r,0) ;\n   SetBounds\n     (r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top) ;\nend;\n</code></pre>\n\n<h2>Variation on a theme by Roddy</h2>\n\n<pre><code>FormStyle := fsStayOnTop;\nBorderStyle := bsNone;\nLeft := 0;\nTop := 0;\nWidth := Screen.Width;\nHeight := Screen.Height;\n</code></pre>\n\n<h2><a href="http://groups.google.nl/group/borland.public.delphi.objectpascal/msg/1cc7e07b0e80150e?hl=en" rel="noreferrer">The WinAPI way</a> (by Peter Below from TeamB)</h2>\n\n<pre><code>private  // in form declaration\n    Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);\n      message WM_GETMINMAXINFO;\n\nProcedure TForm1.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);\n  Begin\n    inherited;\n    With msg.MinMaxInfo^.ptMaxTrackSize Do Begin\n      X := GetDeviceCaps( Canvas.handle, HORZRES ) + (Width - ClientWidth);\n      Y := GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight\n);\n    End;\n  End;\n\nprocedure TForm1.Button2Click(Sender: TObject);\nConst\n  Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);\n  FullScreen: Boolean = False;\nbegin\n  FullScreen := not FullScreen;  \n  If FullScreen Then Begin\n    Rect := BoundsRect;\n    SetBounds(\n      Left - ClientOrigin.X,\n      Top - ClientOrigin.Y,\n      GetDeviceCaps( Canvas.handle, HORZRES ) + (Width - ClientWidth),\n      GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight ));\n  //  Label2.caption := IntToStr(GetDeviceCaps( Canvas.handle, VERTRES ));\n  End\n  Else\n    BoundsRect := Rect;\nend; \n</code></pre>\n'}, {'answer_id': 3157913, 'author': 'Freddie Bell', 'author_id': 381084, 'author_profile': 'https://Stackoverflow.com/users/381084', 'pm_score': 1, 'selected': False, 'text': "<p>How to constrain a sub-form within the Mainform like it was an MDI app., but without the headaches! (Note: The replies on this page helped me get this working, so that's why I posted my solution here)</p>\n\n<pre><code>private\n{ Private declarations }\n  StickyAt: Word;\n  procedure WMWINDOWPOSCHANGING(Var Msg: TWMWINDOWPOSCHANGING); Message M_WINDOWPOSCHANGING;\n  Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;\n</code></pre>\n\n<p>later...</p>\n\n<pre><code>    procedure TForm2.WMWINDOWPOSCHANGING(var Msg: TWMWINDOWPOSCHANGING);\n    var\n      A, B: Integer;\n      iFrameSize: Integer;\n      iCaptionHeight: Integer;\n      iMenuHeight: Integer;\n    begin\n\n      iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);\n      iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);\n      iMenuHeight := GetSystemMetrics(SM_CYMENU);\n\n      // inside the Mainform client area\n      A := Application.MainForm.Left + iFrameSize;\n      B := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight;\n\n      with Msg.WindowPos^ do\n      begin\n\n        if x &lt;= A + StickyAt then\n          x := A;\n\n        if x + cx &gt;= A + Application.MainForm.ClientWidth - StickyAt then\n          x := (A + Application.MainForm.ClientWidth) - cx + 1;\n\n       if y &lt;= B + StickyAt then\n         y := B;\n\n       if y + cy &gt;= B + Application.MainForm.ClientHeight - StickyAt then\n         y := (B + Application.MainForm.ClientHeight) - cy + 1;\n\n      end;\nend;\n</code></pre>\n\n<p>and yet more...</p>\n\n<pre><code>Procedure TForm2.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);\nvar\n  iFrameSize: Integer;\n  iCaptionHeight: Integer;\n  iMenuHeight: Integer;\nBegin\n  inherited;\n  iFrameSize := GetSystemMetrics(SM_CYFIXEDFRAME);\n  iCaptionHeight := GetSystemMetrics(SM_CYCAPTION);\n  iMenuHeight := GetSystemMetrics(SM_CYMENU);\n  With msg.MinMaxInfo^.ptMaxPosition Do\n  begin\n    // position of top when maximised\n    X := Application.MainForm.Left + iFrameSize + 1;\n    Y := Application.MainForm.Top + iFrameSize + iCaptionHeight + iMenuHeight + 1;\n  end;\n  With msg.MinMaxInfo^.ptMaxSize Do\n  Begin\n     // width and height when maximized\n     X := Application.MainForm.ClientWidth;\n     Y := Application.MainForm.ClientHeight;\n  End;\n  With msg.MinMaxInfo^.ptMaxTrackSize Do\n  Begin\n     // maximum size when maximised\n     X := Application.MainForm.ClientWidth;\n     Y := Application.MainForm.ClientHeight;\n  End;\n  // to do: minimum size (maybe)\nEnd;\n</code></pre>\n"}, {'answer_id': 11867212, 'author': 'Taras', 'author_id': 889787, 'author_profile': 'https://Stackoverflow.com/users/889787', 'pm_score': 2, 'selected': False, 'text': '<p>Put to the form <strong><em>onShow</em></strong> event such code:</p>\n\n<pre><code>  WindowState:=wsMaximized;\n</code></pre>\n\n<p>And to the <strong><em>OnCanResize</em></strong> this:</p>\n\n<pre><code>  if (newwidth&lt;width) and (newheight&lt;height) then\n    Resize:=false;\n</code></pre>\n'}, {'answer_id': 17927052, 'author': 'Edijs Kolesnikovičs', 'author_id': 2578854, 'author_profile': 'https://Stackoverflow.com/users/2578854', 'pm_score': 0, 'selected': False, 'text': '<p>You need to make sure Form position is poDefaultPosOnly.</p>\n\n<pre><code>Form1.Position := poDefaultPosOnly;\nForm1.FormStyle := fsStayOnTop;\nForm1.BorderStyle := bsNone;\nForm1.Left := 0;\nForm1.Top := 0;\nForm1.Width := Screen.Width;\nForm1.Height := Screen.Height;\n</code></pre>\n\n<p>Tested and works on Win7 x64.</p>\n'}, {'answer_id': 23679070, 'author': 'Noener', 'author_id': 3218191, 'author_profile': 'https://Stackoverflow.com/users/3218191', 'pm_score': 0, 'selected': False, 'text': '<p>Try:</p>\n\n<pre><code>Align = alClient    \nFormStyle = fsStayOnTop\n</code></pre>\n\n<p>This always align to the primary monitor;</p>\n'}, {'answer_id': 23985225, 'author': 'Jon Lennart Aasenden', 'author_id': 544838, 'author_profile': 'https://Stackoverflow.com/users/544838', 'pm_score': 0, 'selected': False, 'text': '<p>Hm. Looking at the responses I seem to remember dealing with this about 8 years ago when I coded a game. To make debugging easier, I used the device-context of a normal, Delphi form as the source for a fullscreen display.</p>\n\n<p>The point being, that DirectX is capable of running any device context fullscreen - including the one allocated by your form.</p>\n\n<p>So to give an app "true" fullscreen capabilities, track down a DirectX library for Delphi and it will probably contain what you need out of the box.</p>\n'}, {'answer_id': 53226931, 'author': 'Jacek Krawczyk', 'author_id': 1960514, 'author_profile': 'https://Stackoverflow.com/users/1960514', 'pm_score': 1, 'selected': False, 'text': '<p>In my case, the only working solution is:</p>\n\n<pre><code>procedure TFormHelper.FullScreenMode;\nbegin\n  BorderStyle := bsNone;\n  ShowWindowAsync(Handle, SW_MAXIMIZE);\nend;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/14451', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1724/']