How can I set the TCustomForm.clientheight to 768?

How can I set the TCustomForm.clientheight to 768?

I have and application that I want to cover the full screen, with no border. This means that I set the Borderstyle := bsNone;
BorderIcons := [];

Since I work in 1024*768 resolution I set:
ClientWidth := 1028;

But then when I set ClientHeight to 768 it jumps back to 753 leaving Height at 780. I have tried this with both WindowState = wsNormal and WindowState = wsMaximized. This leaves an application that almost, but not quite, covers the screen. Why is this happening? Is there a way around it?

Who is Participating?
kretzschmarConnect With a Mentor Commented:
hi bra,

will you give me the points then accept,
otherwise reject.

hi bra,

it seems the problem is only in designmode, because in designmode is always the windowstitle present and there will be a formula like maxclientheight := screenheight-windowstitleheight.

but you can set it at runtime

procedure TForm1.FormCreate(Sender: TObject);
  form1.Top := 0;
  form1.left := 0;
  form1.clientwidth := 1024;
  form1.clientheight :=768;

You should also try different border styles. The sizing behaves different with different border styles...

Regards... Madshi.
At design time, why not say:
BorderStyle = bsNone
BorderWidth = 0
WindowState = wsMaximized

Run the program, it covers the full screen and client height is 768 (at least it is on my machine)

With a menu bar, client height is less, but the window still covers the entire screen.

Note that setting the clientheight to 768 is maybe not the best idea. If someone runs your app on a higher resolution, it'll only cover the top left area of the screen. On a lower resolution, a status bar (if you have one) would not be visible. If you really want to set the clientheight, then use Screen.Height instead of 768.

bra033098Author Commented:

Tried it, it works, thanks. Bit inconsistent?


Thanks for the tip on using Screen.Height instead. The application I am writing will always
be on the same type of machine and it is therefore not a worry, but do we ever know what the
future holds? (Ask Bill Gates about 640k)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.