7

This is the code I'm using:

BorderStyle := bsNone;
WindowState := wsMaximized;

My problem is that the application won't cover the taskbar, but go behind it.

It works fine when switching to fullscreen at runtime, but it doesn't work when starting the app at system startup.

UPDATE

It turns out that those two lines work very well. They are in the FormShow event handler. If I break point until the end of FormShow, the application seems to be in fullscreen; I can see the application trough the taskbar. But after FormShow the application's Top property gets changed somehow. I don't change it in code - the value is -20, so the application is not maximized anymore.

Is there a way to track where or when it is changed?

Thanks in advance!

UPDATE

This post is flagged. Please do not post any answers! Thank you.

Peacelyk
  • 1,126
  • 4
  • 24
  • 48
  • 1
    Where do you use this code? In what event handler? – jpfollenius Feb 09 '11 at 07:09
  • This is what "work area" means, the area on the primary monitor left out from desktop application toolbars (taskbar is one). – Sertac Akyuz Feb 09 '11 at 09:24
  • You've modified the question so that it not only rendered existing answers and comments irrelevant but also does not ask the same thing that the question's title asks. -1. You'd better resolve the original question somehow and asked a new one.. – Sertac Akyuz Feb 09 '11 at 18:40
  • sorry. i flagged the post. i hope it gets deleted! My bad, i should have been more careful before i post. – Peacelyk Feb 10 '11 at 06:10
  • "This question is unlikely to help any future visitors; it is only relevant to a small geographic area, ..." - Really ??? Why was this closed? It helped me, even though it only works on computers powered up in Kyrgyzstan, but that's ok. I vote to re-open the question – Reversed Engineer Jun 02 '16 at 07:58

2 Answers2

4

Change the param style, according to this MSDN blog: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx

procedure TForm1.CreateParams(var Params: TCreateParams); 
begin
  inherited; 
  Params.Style := WS_POPUP or WS_VISIBLE; //will overlay taskbar
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Self.WindowState := wsMaximized; //fullscreen
end;

====================================

Full code to switch from Windowed to fullscreen mode and back (tested on Win7 64bit, Aero)
(Edit: works in Windows XP (vmware) too)

var
  _OrgWindowedStyle: DWORD;

procedure TForm6.btnWindowedClick(Sender: TObject);
begin
  Self.WindowState := wsNormal;
  //set original style
  SetWindowLong( Application.Handle, GWL_STYLE,
                 _OrgWindowedStyle);
  //re-create window, to use changed style
  RecreateWnd;
end; 

procedure TForm6.btnFullScreenClick(Sender: TObject);
begin
  _OrgWindowedStyle := 0;  //clear: re-applies fullscreen mode in CreateParams
  Self.WindowState  := wsMaximized;
  //re-create window, to use changed style
  RecreateWnd;
end;

procedure TForm6.CreateParams(var Params: TCreateParams);
begin
  inherited;

  //first time? default fullscreen
  if _OrgWindowedStyle = 0 then
  begin
    _OrgWindowedStyle := Params.Style;
    Params.Style := //WS_POPUP or               //not needed?
                    WS_VISIBLE
                    or WS_BORDER or WS_CAPTION  //comment this line to remove border + titlebar
  end;
end;

procedure TForm6.FormCreate(Sender: TObject);
begin
  Self.WindowState := wsMaximized;     //default fullscreen
end;
André
  • 8,920
  • 1
  • 24
  • 24
1

try:

Form.Left := 0; // set the x
Form.Top := 0; // set the y
Form.Width := Screen.Width; // width of the form
Form.Height := Screen.Height; // height of the form
// and
Form.FormStyle := fsStayOnTop; // taskbar is always on top as well, setting the Style property to always on top will allow the form to cover the taskbar

if you would like to hide the caption then set the borderstyle to bsnone

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
  • Does not work (on Win7) if you press the Windows key: taskbar or the round Windows menu button (bottomleft) gets on top – André Feb 09 '11 at 08:53
  • 2
    @André - AFAIU the question does not involve preventing task bar activation after the form is shown. – Sertac Akyuz Feb 09 '11 at 09:31
  • @Sertac: correct, but I think he does not want to see the taskbar at all, so it would be a problem again if taksbar stays on top after the "Windows" key (same problem back). See my own answer for complete solution (by changing style) – André Feb 09 '11 at 10:15