<?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[GetWindowText funktioniert nicht! Was mache ich falsch?]]></title><description><![CDATA[<p>Hi!</p>
<p>Folgender Code:</p>
<pre><code class="language-cpp">LPTSTR Text=&quot;&quot;;
HWND hSum;
hSum= GetDlgItem(hWnd, IDC_SUM); //Funktioniert einwandfrei!
SetWindowText(hSum,&quot;Test&quot;); // Funktioniert ebenfalls -&gt; Handle ist also korrekt.
GetWindowText(hSum,Text,4); // Schreibt nichts in den LPTSTR und gibt als Anzahl der ausgelesenen Zeichen NULL zurück!
</code></pre>
<p>Ich möchte den Inhalt eines Textfeldes &quot;IDC_SUM&quot; auslesen und in den LPTSTR &quot;Text&quot; schreiben. Dazu rufe ich GetWindowText(hSum,Text,4); auf. *Die Textbox enthält WENIGER als die angegebenen 4 Zeichen!*. Obwohl eigentlich alles passen müsste, gibt die Funktion NULL zurück, was der Anzahl der ausgelesenen Zeichen entspricht.</p>
<p>Erkennt jemand den Fehler?</p>
<p>Gruß, veryxRV</p>
<p>PS: Hoffe es war diesmal ausführlich genug erklärt, was ich meine <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/topic/162804/getwindowtext-funktioniert-nicht-was-mache-ich-falsch</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 18:54:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162804.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 Oct 2006 13:37:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:37:02 GMT]]></title><description><![CDATA[<p>Hi!</p>
<p>Folgender Code:</p>
<pre><code class="language-cpp">LPTSTR Text=&quot;&quot;;
HWND hSum;
hSum= GetDlgItem(hWnd, IDC_SUM); //Funktioniert einwandfrei!
SetWindowText(hSum,&quot;Test&quot;); // Funktioniert ebenfalls -&gt; Handle ist also korrekt.
GetWindowText(hSum,Text,4); // Schreibt nichts in den LPTSTR und gibt als Anzahl der ausgelesenen Zeichen NULL zurück!
</code></pre>
<p>Ich möchte den Inhalt eines Textfeldes &quot;IDC_SUM&quot; auslesen und in den LPTSTR &quot;Text&quot; schreiben. Dazu rufe ich GetWindowText(hSum,Text,4); auf. *Die Textbox enthält WENIGER als die angegebenen 4 Zeichen!*. Obwohl eigentlich alles passen müsste, gibt die Funktion NULL zurück, was der Anzahl der ausgelesenen Zeichen entspricht.</p>
<p>Erkennt jemand den Fehler?</p>
<p>Gruß, veryxRV</p>
<p>PS: Hoffe es war diesmal ausführlich genug erklärt, was ich meine <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/1159577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159577</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:38:53 GMT]]></title><description><![CDATA[<p>hol dir erstmal ein bisschen speicher</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159578</guid><dc:creator><![CDATA[pffffff]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:38:53 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:39:50 GMT]]></title><description><![CDATA[<p>Dein Zeiger zeigt auf das Stringliteral &quot;&quot;, auf das du nicht schreibend zugreifen darfst, und das - selbst wenn du es dürftest - zu klein für 4 Zeichen ist.</p>
<p>Du musst den Zeiger schon auf einen hinreichend großen und beschreibbaren Puffer verweisen lassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159579</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:39:50 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:44:48 GMT]]></title><description><![CDATA[<p>Habe ich auch schon probiert, kommt aufs gleiche raus...m <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>EDIT: -&gt; Also das mit mehreren Zeichen. Wie mache ich es denn beschreibbar?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159581</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:44:48 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:46:29 GMT]]></title><description><![CDATA[<p>hast du etwa sofort mit winapi angefangen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> looooool</p>
<p>du brauchst GetWindowTextLength und malloc/new</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159590</guid><dc:creator><![CDATA[wejoi]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:46:29 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:47:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">TCHAR text[100];
GetWindowText(hSum, text, 100);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1159591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159591</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:47:27 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 13:55:31 GMT]]></title><description><![CDATA[<p>Naja besser so:</p>
<pre><code class="language-cpp">UINT uiStrLen = SendMessage(hWhd, WM_GETTEXTLENGTH, 0, 0L) + 1;
PTCHAR pszBuffer = new TCHAR[uiStrLen];
SendMessage(hWnd, WM_GETTEXT, uiStrLen, reinterpret_cast&lt;LPARAM&gt;(pszBuffer));
MessageBox(NULL, pszBuffer, NULL, 0);
// ...
delete [] pszBuffer;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1159601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159601</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 23 Oct 2006 13:55:31 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 16:31:45 GMT]]></title><description><![CDATA[<p>wejoi schrieb:</p>
<blockquote>
<p>hast du etwa sofort mit winapi angefangen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> looooool</p>
<p>du brauchst GetWindowTextLength und malloc/new</p>
</blockquote>
<p>Mit der Frage währe ich vorsichtig. Ich kann nebenbei noch C#, C, Pascal, Basic, JavaScr, und nen bissl PHP.. Kann sein, dass ich noch was vergessen hab ^^. Beantwortet das deine Frage? :p</p>
<p>Ich habe einfach nur Probleme mit dem leicht abgeänderten Prinzip in C++! Hab die Logik da teilweise noch nicht drauf..</p>
<p>Danke jedenfalls <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>@Die anderen^^: Danke, ich probiers mal!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159754</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Mon, 23 Oct 2006 16:31:45 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 18:08:35 GMT]]></title><description><![CDATA[<p>veryxRV schrieb:</p>
<blockquote>
<p>Ich kann nebenbei noch C#, C, Pascal, Basic, JavaScr, und nen bissl PHP..</p>
<p>Ich habe einfach nur Probleme mit dem leicht abgeänderten Prinzip in C++! Hab die Logik da teilweise noch nicht drauf..</p>
</blockquote>
<p>Ist dir klar, dass dein Code C ist (was du ja nebenbei angeblich &quot;kannst&quot;)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159839</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159839</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 23 Oct 2006 18:08:35 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Mon, 23 Oct 2006 18:16:06 GMT]]></title><description><![CDATA[<p>Ja das ist mir klar, ich weiß auch nicht mehr genau wie die Sprache hieß. Aber ich mein es war etwas mit C. C# ist schließlich auch nicht *unbedingt* das gleiche wie C oder eben C++. Vielleicht C-Script? Ich weiß es nich. Klingt komisch - is aber so! <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="😉"
    /> Es war ein spezieller Compiler und es gab auch eine Anleitung dazu, aber ich habe nie wirklich gelesen, was ich da wirklich für ne Sprache gelernt hab ^^ Jedenfalls konnte/kann ich damit umgehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159843</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Mon, 23 Oct 2006 18:16:06 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Tue, 24 Oct 2006 07:26:09 GMT]]></title><description><![CDATA[<p>veryxRV schrieb:</p>
<blockquote>
<p>Ich habe einfach nur Probleme mit dem leicht abgeänderten Prinzip in C++! Hab die Logik da teilweise noch nicht drauf..</p>
</blockquote>
<p>Warum? Alles, was C kann, kann C++ auch. Da ist das Prinzip das Gleiche. Dir stehen sämtliche C-Befehle zur Verfügung. Bei C++ kommt nur die OOP-Kapselung dazu (und ein paar neue Befehle), aber Du kannst auch mit einem C++-Compiler reine C-Programme schreiben (nur bei Befehlen Casts muß man das richtige Casting beachten, z. B. bei malloc).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1160043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1160043</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Tue, 24 Oct 2006 07:26:09 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText funktioniert nicht! Was mache ich falsch? on Tue, 24 Oct 2006 11:35:27 GMT]]></title><description><![CDATA[<p>Ja!!! Hab doch schon gesagt, dass ich mich in der Sprache vertan habe! S.h. letzten Post!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1160245</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1160245</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Tue, 24 Oct 2006 11:35:27 GMT</pubDate></item></channel></rss>