<?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[DrawText. Problem mit LPCWSTR]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte eine GUI unter Windows Mobile realisieren. Soweit ist alles klar.<br />
nur habe ich beim Aufruf von drawText() das Problem mit dem Casten von char [] nach LPCWSTR</p>
<p>Folgendes funktioniert:</p>
<pre><code class="language-cpp">DrawText(hdc, L&quot;test&quot;, sizeof(&quot;text&quot;), &amp;rect, DT_WORDBREAK | DT_CENTER);
</code></pre>
<p>das hier aber nicht:</p>
<pre><code class="language-cpp">const char str[] = &quot;test&quot;;
DrawText(hdc, str, sizeof(str), &amp;rect, DT_WORDBREAK | DT_CENTER);
</code></pre>
<p>Mir ist schon klar, dass da irgendwas fehlt, aber was und wo genau? Ich möchte ja nicht jedes mal einen Text erst im Funktionsaufruf direkt übergeben. Außerdem kann man nicht durch irgendeine Einstellung sich dieses UniCode Problem beheben? Mich wundert, dass es in keinem Tutorial erwähnt wird?</p>
<p>Vielen Dank im Vorraus<br />
Grüße<br />
jens</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182486/drawtext-problem-mit-lpcwstr</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 01:11:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182486.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 May 2007 12:27:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DrawText. Problem mit LPCWSTR on Fri, 25 May 2007 12:27:35 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich möchte eine GUI unter Windows Mobile realisieren. Soweit ist alles klar.<br />
nur habe ich beim Aufruf von drawText() das Problem mit dem Casten von char [] nach LPCWSTR</p>
<p>Folgendes funktioniert:</p>
<pre><code class="language-cpp">DrawText(hdc, L&quot;test&quot;, sizeof(&quot;text&quot;), &amp;rect, DT_WORDBREAK | DT_CENTER);
</code></pre>
<p>das hier aber nicht:</p>
<pre><code class="language-cpp">const char str[] = &quot;test&quot;;
DrawText(hdc, str, sizeof(str), &amp;rect, DT_WORDBREAK | DT_CENTER);
</code></pre>
<p>Mir ist schon klar, dass da irgendwas fehlt, aber was und wo genau? Ich möchte ja nicht jedes mal einen Text erst im Funktionsaufruf direkt übergeben. Außerdem kann man nicht durch irgendeine Einstellung sich dieses UniCode Problem beheben? Mich wundert, dass es in keinem Tutorial erwähnt wird?</p>
<p>Vielen Dank im Vorraus<br />
Grüße<br />
jens</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292200</guid><dc:creator><![CDATA[jensr]]></dc:creator><pubDate>Fri, 25 May 2007 12:27:35 GMT</pubDate></item><item><title><![CDATA[Reply to DrawText. Problem mit LPCWSTR on Fri, 25 May 2007 12:31:23 GMT]]></title><description><![CDATA[<p>Daß das erste funktioniert, ist vermutlich nur Glück - ersetz mal das &quot;Test&quot; durch ein &quot;Hallo Welt!&quot; und schau dir das Ergebnis an.</p>
<p>Ansonsten LPCWSTR ist ein wchar_t-Zeiger (und wchar_t ist etwas größer als char). Also mußt du auch mit wchar's arbeiten:</p>
<pre><code class="language-cpp">const wchar_t str[] = L&quot;test&quot;;
DrawText(hdc, str, sizeof(str), &amp;rect, DT_WORDBREAK | DT_CENTER);

//oder unabhängig von den Compiler-Einstellungen:
const TCHAR str[]=_T(&quot;test&quot;);
DrawText(hdc, str, sizeof(str), &amp;rect, DT_WORDBREAK | DT_CENTER);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1292203</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292203</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 25 May 2007 12:31:23 GMT</pubDate></item><item><title><![CDATA[Reply to DrawText. Problem mit LPCWSTR on Fri, 25 May 2007 14:54:33 GMT]]></title><description><![CDATA[<p>Vielen Dank, jetzt geht es!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292284</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292284</guid><dc:creator><![CDATA[jensr]]></dc:creator><pubDate>Fri, 25 May 2007 14:54:33 GMT</pubDate></item></channel></rss>