Author: Kevin Gallagher
How can I show a form so that it covers all available screen space including the
taskbar?
Answer:
Covering the entire screen with a form is relatively easy to accomplish as shown
below.
1 procedure TfrmMainForm.FormCreate(Sender: TObject);
2 begin3 { Position form }4 Top := 0;
5 Left := 0;
6 7 { Go full screen }8 WindowState := wsmaximized;
9 ClientWidth := Screen.Width;
10 ClientHeight := Screen.Height;
11 Refresh;
12 end;
If this is a typical form it will have borders which you might consider removing by
setting BorderStyle property to bsNone as shown below.
13 procedure TfrmMainForm.FormCreate(Sender: TObject);
14 begin15 { Position form }16 Top := 0;
17 Left := 0;
18 19 { Go full screen }20 BorderStyle := bsNone;
21 WindowState := wsmaximized;
22 ClientWidth := Screen.Width;
23 ClientHeight := Screen.Height;
24 Refresh;
25 end;
Sometimes the code shown above will go full screen but still display the Windows
TaskBar, if this happens we can force the form on top using either
SetForeGroundWindow or SetActiveWindow. From my testing it is best to use both if
the problem persist.
26 procedure TfrmMainForm.FormCreate(Sender: TObject);
27 begin28 { Position form }29 Top := 0;
30 Left := 0;
31 32 { Go full screen }33 BorderStyle := bsNone;
34 WindowState := wsmaximized;
35 ClientWidth := Screen.Width;
36 ClientHeight := Screen.Height;
37 Refresh;
38 SetForegroundWindow(Handle);
39 SetActiveWindow(Application.Handle);
40 end;
Other considerations (see attachment for code to address these items) If the form
is already in maximized window state the above code will not work. Controlling the
system menu commands as per above needs to be considered Ghost items in the TaskBar
after terminating your application.
Delphi makes it simple to cover the display screen but what if you need to
duplicate the functionality in another programming language such as Microsoft
Visual Basic? Well in this case you might want to learn the API methods (again see
attachment).