<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Lazarus Pascal - Determine titlebar height crossplatform quick and easy - Delphi, Lazarus, Free Pascal				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-determine-titlebar-height-crossplatform-quick-and-easy/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Sat, 13 Jun 2026 21:58:36 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Lazarus Pascal - Determine titlebar height crossplatform quick and easy</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-determine-titlebar-height-crossplatform-quick-and-easy/#post-5076</link>
                        <pubDate>Sat, 23 Sep 2023 16:45:53 +0000</pubDate>
                        <description><![CDATA[Seems hard to determine the height of the titlebar/caption of a form.I&#039;ve seen some calls that are Windows specific only, and some tricks that maximize the form to determine the size (flicke...]]></description>
                        <content:encoded><![CDATA[<p>Seems hard to determine the height of the titlebar/caption of a form.<br />I've seen some calls that are Windows specific only, and some tricks that maximize the form to determine the size (flicker), or system calls that simply do not work on all platforms.</p>
452
<p>So after tinkering with that issue for a bit, I figured; why not use the "translation" of a pixel on a form to its location on the screen and determine how much it's off? (a.k.a. the titlebar height)</p>
<p>Tested this under Windows (11), macOS (Monterey and Sonoma), GTK2 and QT5 ... and it just works ...</p>
<pre contenteditable="false">function DetermineTitlebarHeight(aForm:Tform):integer;
var
  global_pos : TPoint;
begin
  global_pos := aForm.ClientToScreen(Point (1,1));
  Result     := global_pos.Y - aForm.Top;
end;</pre>
<p>I've tested this at <strong>onFormPaint</strong> and <strong>onFormChangeBounds</strong>, and even when changing themes (Linux) it adapts.</p>
<p>For testing I've added a little project that has 2 units, where the 2nd unit stays aligned to the bottom of the first unit.</p>
453]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-determine-titlebar-height-crossplatform-quick-and-easy/#post-5076</guid>
                    </item>
							        </channel>
        </rss>
		