<?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[GetTextExtentPoint32]]></title><description><![CDATA[<p>Wie kann ich berechnen wie lang ein String ist ? Mein Fenster soll so lang sein wie der längste String, der darin dargestellt werden soll. Ich hab versucht das mit GetTextExtentPoint32 zu machen aber es klappt nicht richtig oder ich weiss nicht wie ich umrechnen muss <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code>LOGFONT lf;
	HDC hDC;
	HFONT hFont, hFontOld;
	SIZE Size;

	memset( &amp;lf, 0, sizeof(lf) );

	lf.lfCharSet	= ANSI_CHARSET;
	lf.lfWeight		= FW_REGULAR;

	hDC = GetDC(NULL);
	lf.lfHeight		= -MulDiv( 8, GetDeviceCaps(hDC, LOGPIXELSY), 72 );
	lstrcpy( lf.lfFaceName, &quot;Times New Roman&quot; );

	if( (hFont = CreateFontIndirect(&amp;lf)) == NULL )
		return 0;

	hFontOld = (HFONT) SelectObject( hDC, hFont );
	GetTextExtentPoint32( hDC, lpszText, strlen(lpszText), &amp;Size );
	SelectObject( hDC, hFontOld );
	DeleteObject( hFont );
	ReleaseDC(NULL, hDC);
</code></pre>
<p>Muss ich den Wert von <a href="http://Size.cx" rel="nofollow">Size.cx</a> dann noch irgendwie umrechnen, denn wenn ich den so an CreateWindow als Width übergebe, stimmt das nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/117448/gettextextentpoint32</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 14:38:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/117448.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Aug 2005 18:17:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetTextExtentPoint32 on Sun, 07 Aug 2005 18:17:20 GMT]]></title><description><![CDATA[<p>Wie kann ich berechnen wie lang ein String ist ? Mein Fenster soll so lang sein wie der längste String, der darin dargestellt werden soll. Ich hab versucht das mit GetTextExtentPoint32 zu machen aber es klappt nicht richtig oder ich weiss nicht wie ich umrechnen muss <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code>LOGFONT lf;
	HDC hDC;
	HFONT hFont, hFontOld;
	SIZE Size;

	memset( &amp;lf, 0, sizeof(lf) );

	lf.lfCharSet	= ANSI_CHARSET;
	lf.lfWeight		= FW_REGULAR;

	hDC = GetDC(NULL);
	lf.lfHeight		= -MulDiv( 8, GetDeviceCaps(hDC, LOGPIXELSY), 72 );
	lstrcpy( lf.lfFaceName, &quot;Times New Roman&quot; );

	if( (hFont = CreateFontIndirect(&amp;lf)) == NULL )
		return 0;

	hFontOld = (HFONT) SelectObject( hDC, hFont );
	GetTextExtentPoint32( hDC, lpszText, strlen(lpszText), &amp;Size );
	SelectObject( hDC, hFontOld );
	DeleteObject( hFont );
	ReleaseDC(NULL, hDC);
</code></pre>
<p>Muss ich den Wert von <a href="http://Size.cx" rel="nofollow">Size.cx</a> dann noch irgendwie umrechnen, denn wenn ich den so an CreateWindow als Width übergebe, stimmt das nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/847588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/847588</guid><dc:creator><![CDATA[Christan_]]></dc:creator><pubDate>Sun, 07 Aug 2005 18:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to GetTextExtentPoint32 on Sun, 07 Aug 2005 20:04:01 GMT]]></title><description><![CDATA[<p>Wieviel weicht der Wert denn ab ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/847625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/847625</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sun, 07 Aug 2005 20:04:01 GMT</pubDate></item><item><title><![CDATA[Reply to GetTextExtentPoint32 on Sun, 07 Aug 2005 22:55:52 GMT]]></title><description><![CDATA[<p>hallo,<br />
es klappt doch, hatte mich vorhin nur verguckt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/847693</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/847693</guid><dc:creator><![CDATA[Christan_]]></dc:creator><pubDate>Sun, 07 Aug 2005 22:55:52 GMT</pubDate></item></channel></rss>