<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wie Größe des Buttons anhand des Textes bestimmen?]]></title><description><![CDATA[<p>Hi!<br />
Ich will nicht immer wieder width und heigth des Buttons explizit als Argument übergeben, sondern diese dynamisch berechnen als Funktion der Länge des Textes. So was:</p>
<pre><code class="language-cpp">int cxChar = LOWORD(GetDialogBaseUnits()) + 4; // ??? ohne +4 werden die Buttons zu eng!!!
int cyChar = HIWORD(GetDialogBaseUnits()) + 2; //???
hWnd_ = CreateWindow (&quot;button&quot;, 
					caption,
					style,
					x, y,
					_tcslen(caption) * cxChar, 7 * cyChar / 4,
					parent, (HMENU)id,
					hInst_, 0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/187019/wie-größe-des-buttons-anhand-des-textes-bestimmen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 11:00:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187019.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Jul 2007 17:31:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie Größe des Buttons anhand des Textes bestimmen? on Sat, 14 Jul 2007 17:31:26 GMT]]></title><description><![CDATA[<p>Hi!<br />
Ich will nicht immer wieder width und heigth des Buttons explizit als Argument übergeben, sondern diese dynamisch berechnen als Funktion der Länge des Textes. So was:</p>
<pre><code class="language-cpp">int cxChar = LOWORD(GetDialogBaseUnits()) + 4; // ??? ohne +4 werden die Buttons zu eng!!!
int cyChar = HIWORD(GetDialogBaseUnits()) + 2; //???
hWnd_ = CreateWindow (&quot;button&quot;, 
					caption,
					style,
					x, y,
					_tcslen(caption) * cxChar, 7 * cyChar / 4,
					parent, (HMENU)id,
					hInst_, 0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1325449</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325449</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Sat, 14 Jul 2007 17:31:26 GMT</pubDate></item><item><title><![CDATA[Reply to Wie Größe des Buttons anhand des Textes bestimmen? on Sat, 14 Jul 2007 18:03:52 GMT]]></title><description><![CDATA[<p>GetTextExtentPoint32() könnte dir helfen:<br />
<a href="http://msdn2.microsoft.com/en-us/library/ms534223.aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms534223.aspx</a><br />
Da die Funktion aber natürlich wissen muss mit welchem Font sie es zu tun hat musst du ihr ein HDC übergeben ... wie man das hier am klügsten anstellt weiß ich nicht.<br />
Ein GetDC() auf das Handle des Buttons könnte funktionieren, denke ich aber nicht. Vielleicht könntest du dir auch ein DC erstellen (CreateDC), dann dir einen Font erstellen (Standardschriftart: MS Sans Serif, größe 8), diesen Font mit SelectObject() auf den DC legen und diesen DC übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325468</guid><dc:creator><![CDATA[Black Shadow]]></dc:creator><pubDate>Sat, 14 Jul 2007 18:03:52 GMT</pubDate></item><item><title><![CDATA[Reply to Wie Größe des Buttons anhand des Textes bestimmen? on Sat, 14 Jul 2007 21:57:44 GMT]]></title><description><![CDATA[<p>Ab WindowsXP gibts auch Button_GetIdealSize()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325563</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 14 Jul 2007 21:57:44 GMT</pubDate></item></channel></rss>