How to get the size of a Winforms Form titlebar height?

后端 未结 5 489
独厮守ぢ
独厮守ぢ 2021-02-01 01:59

So if it\'s toolwindow or a minimizable form, I want to be able to get its height programmatically.

Is this possible? If so how?

5条回答
  •  有刺的猬
    2021-02-01 02:46

    To fix S. Norman's answer that simply has his minuend and subtrahend switched, the following is the simplest answer:

    int HeightOfTheTitleBar_ofThis = this.Height - this.ClientRectangle.Height;

    BTW, the standard hard coded title bar is 25dpi which is the minimum height and can be changed to a maximum of 50dpi.

    OK OK,... yes, it is technically incorrect As stated by Cody Grey but it works and should get the same answer as the accepted answer. No need to create a rectangle.

提交回复
热议问题