11 Vote

Lazarus/Delphi: Width and ClientWidth - Difference

Info by Delphian | Last update on 2023-01-18 | Created on 2015-07-19

Not long ago, we had a question in which someone has asked what the difference between Height and ClientHeight is in regard to Forms of Delphi and Lazarus. For the sake of completeness, now I would also like to explain the difference between Width and ClientWidth.

What are Width and ClientWidth?

Width and ClientWidth are properties defining the width of a form which is the width of the window. The property can be used in Lazarus as well as in Delphi.

  • ClientWidth is referring to the width of the form or the window inclusive of the width of the lateral edges
  • Width on the other hand is referring to the inner width of the window without taking the width of the lateral borders into account

The width of the border is determined by several factors: For example, it depends on the operating system, the current theme and even within the same operating system, there may be differences between each version. For instance, not all Windows versions are having the same border size for their applications.

When should I use which property?

Depending on your purpose of application, it is recommended to set the window size via Width or ClientWidth.

If we want to adjust the window exactly to the content therein using the exact pixel size, it is better to set the width via ClientWidth. Finally, in this case we do not know the resulting size of the window when an arbitrary border is added.

In case that the window itself should have a specific size, for example to ensure that it takes a specific size on the screen, we should set the width by using the Width property. In this case, ClientWidth will automatically have a little bit smaller value.


About the Author

AvatarThe author has not added a profile short description yet.
Show Profile


Related Topics

The Secure Password

Info | 0 Comments

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.


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