Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<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> <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> <pre><code>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; </code></pre> <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> <pre><code>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. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload