Solved

Application in Full-Screen mode

Posted on 2006-07-13
11
173 Views
Last Modified: 2010-04-05
Hi there, I have searched and searched on this site
how to make a application full-screen, but i didn't
found a good solution!

So I have made a beginning:

procedure TMainForm.ToolButton7Click(Sender: TObject);
begin
 with MainForm do
   WindowState := wsMaximized;
   FormStyle := fsStayOnTop;
   Left := 0;
   Top := 0;
   Height := Screen.Height;
   Width := Screen.Width;
   BorderStyle := bsNone;
   StatusBar1.Visible := false
end;
(*-----------------------------------------------*)
procedure TMainForm.ToolButton8Click(Sender: TObject);
begin
   with MainForm do
   FormStyle := fsNormal;
   BorderStyle := bsSizeable;
   StatusBar1.Visible := true
end;
(*-----------------------------------------------*)

I have several question about the procedures above:
1. How can I hide/show the statusbar?
2. When I press the ToolButton8 to get the screen in normal-state
    The rezise-button in the right-top corner doesn't work!

Who can help me out?

Greetings,

Peter
0
Comment
Question by:peterkiers
  • 6
  • 4
11 Comments
 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
You need to remember the coordinates yourself to switch back. You will need something like this:

FSavedCoords : array[0..3] of Integer;

And then this should do it:

procedure TMainForm.ToolButton7Click(Sender: TObject);
begin
 with MainForm do
   FormStyle := fsStayOnTop;
   FSavedCoords[0] := Left;
   FSavedCoords[1] := Top;
   FSavedCoords[2] := Height;
   FSavedCoords[3] := Width;
   SetBounds(0, 0, Screen.Width, Screen.Height);
   BorderStyle := bsNone;
   StatusBar1.Visible := false;
end;

procedure TMainForm.ToolButton8Click(Sender: TObject);
begin
  with Form1 do
    FormStyle := fsNormal;
    SetBounds(FSavedCoords[0], FSavedCoords[1], FSavedCoords[2], FSavedCoords[3]);
    BorderStyle := bsSizeable;
    StatusBar1.Visible := true;
end;

Also the StatusBar should now react correctly on the .Visible property.

Regards !
Tueblo
0
 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
Well, I have swapped the Height and Width values from FSavedCoords in ToolButton8Click(), but am sure you get the point. :)
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
I am sorry, I don't get the point, what do I do wrong?

procedure TMainForm.ToolButton7Click(Sender: TObject);
begin
 with MainForm do
   WindowState := wsMaximized;
   FormStyle := fsStayOnTop;
   FSavedCoords[0] := Left;
   FSavedCoords[1] := Top;
   FSavedCoords[2] := Height;
   FSavedCoords[3] := Width;
   SetBounds(0, 0, Screen.Width, Screen.Height );
   Left := 0;
   Top := 0;
   Height := Screen.Height;
   Width := Screen.Width;
   BorderStyle := bsNone;
   StatusBar1.Visible := false

end;
(*-----------------------------------------------*)
procedure TMainForm.ToolButton8Click(Sender: TObject);
begin
   with MainForm do
   FormStyle := fsNormal;
   SetBounds(FSavedCoords[0], FSavedCoords[1], FSavedCoords[2], FSavedCoords[3]);
   BorderStyle := bsSizeable;
   StatusBar1.Visible := true
(*-----------------------------------------------*)

PK
0
 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
Replace your function exactly with these, I mark the differences:

procedure TMainForm.ToolButton7Click(Sender: TObject);
begin
 with MainForm do
   // You don't need to change the WindowState
   // WindowState := wsMaximized;
   FormStyle := fsStayOnTop;
   FSavedCoords[0] := Left;
   FSavedCoords[1] := Top;
   FSavedCoords[2] := Width; // changed, now Width instead of Height
   FSavedCoords[3] := Height; // changed, now Height instead of Width
   SetBounds(0, 0, Screen.Width, Screen.Height);
   // SetBounds() will do the same as the four lines below
   // Left := 0;
   //Top := 0;
   // Height := Screen.Height;
   // Width := Screen.Width;
   BorderStyle := bsNone;
   StatusBar1.Visible := false;
end;

That should work...does it?
procedure TMainForm.ToolButton8Click(Sender: TObject);
begin
  with MainForm do
    FormStyle := fsNormal;
    SetBounds(FSavedCoords[0], FSavedCoords[1], FSavedCoords[2], FSavedCoords[3]);
    BorderStyle := bsSizeable;
    StatusBar1.Visible := true;
end;
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Your solution did help other problems I had, but the MainMenu-bar
still there.

P.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
MainMenuBar? You did not mention that before. What does it and where is the problem?
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
AAAHHH, that was dumb of me, I ment the MainMenuBar not the statusbar.

p.
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
The procedure works fine to make my application full-screen
except for the MainMenubar, I want to hide the mainmenubar also.
But I don't know how.
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
Comment Utility
To remove:

MainForm.Menu:=nil;

To restore

MainForm.Menu:={name of MainMenu component}

--

Regards,
Russell
0
 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
procedure TMainForm.HideTitle;
var actStyle : Integer;
begin
  actStyle := GetWindowLong(Handle, GWL_STYLE);
  SetWindowLong(Handle, GWL_STYLE, (actStyle and (not WS_CAPTION)));
  SetWindowPos(Handle, 0, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_FRAMECHANGED);  
end;

You will now have the problem that you can not move the window anymore. This will allow moving by clicking anywhere on the window:

Put the following function in the private section of TMainForm:

procedure WMNCHitTest(var msg: TWMNCHitTest); message WM_NCHitTest;

And this is the implementation:

procedure TMainForm.WMNCHitTest (var msg: TWMNCHitTest);
begin
  inherited;
  if ( msg.Result = htClient ) then
    msg.Result := htCaption;
end;

0
 
LVL 1

Expert Comment

by:Tueblo
Comment Utility
Cool
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now