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;
13 14 if this is a typical form it will have borders which you might consider removing by
15 setting BorderStyle propertyto bsNone as shown below.
16 17 procedure TfrmMainForm.FormCreate(Sender: TObject);
18 begin19 { Position form }20 Top := 0;
21 Left := 0;
22 23 { Go full screen }24 BorderStyle := bsNone;
25 WindowState := wsmaximized;
26 ClientWidth := Screen.Width;
27 ClientHeight := Screen.Height;
28 Refresh;
29 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.
30 procedure TfrmMainForm.FormCreate(Sender: TObject);
31 begin32 { Position form }33 Top := 0;
34 Left := 0;
35 36 { Go full screen }37 BorderStyle := bsNone;
38 WindowState := wsmaximized;
39 ClientWidth := Screen.Width;
40 ClientHeight := Screen.Height;
41 Refresh;
42 SetForegroundWindow(Handle);
43 SetActiveWindow(Application.Handle);
44 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).
Component Download: