00 Votes

Lazarus/Delphi: Difference between Height and ClientHeight of a Form

Question by Guest | 2015-07-14 at 21:27

I have found two different properties of the TForm in Delphi and Lazarus which are both influencing the height of the Form or Window: Height and ClientHeight.

But what is the difference between those heights? Do both specifications have exactly the same effect? Because, I have seen that the values are differing a little bit. And which property should I use to change the height of my program application window?

ReplyPositiveNegative
Avatar
1Best Answer1 Vote

Both properties are referring to the height of the window. The difference is how this height is calculated:

  • Height is the total height of the window inclusively the border, the menu (TMainMenu) and the title bar (program connection, system icons).
  • ClientHeight on the contrary is the inner height of the window without borders or menu. That is the entire height of the inner space of the window in which you can place your controls.

According to that, the value of "Height" will be a little bit greater than the value from "Clientheight".

Because the frame, the border and the title bar have another appearance and size on different operating systems or Windows versions, I recommend to set the width with ClientHeight whenever you would like to make the window fit to for example some controls created dynamically. Even the font type used and the selected user theme make the window border size vary, so that it is hard to rely on specific values. But sure there are other applications in which setting the Height property fits the needs more.

Whenever you want to set a window to its minimum possible height, accordingly, you have to set ClientHeight to 0 which is making only the title bar shown.

Apart from Height and ClientHeight, there are also the properties Width and ClientWidth which can correspondingly be used to determine the window width.
2015-07-17 at 18:50

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.