<?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[-&amp;gt;Caption &#x2F; -&amp;gt;Text ect. = Error]]></title><description><![CDATA[<p>Hi,<br />
also zuerst muss ich sagen, dass ich neu hier im Forum bin ^^.<br />
Ich hab mir schon son bissl Cpp angeeignet und verstehe den Grund eigentlich ganz gut.<br />
Ich will nicht lang drum rum reden:</p>
<p>Ich möchte dass er mir via Buttonklick den Text via MessageBox ausgibt, der in einem edit-Window steht. Soweit ist alles klar. Habe dann gleich losgegooglet wie man den Text eines WNDs rausbekommt und bin auf folgede Varianten gestoßen:</p>
<p>Label1-&gt;Text,<br />
Label1-&gt;Caption,<br />
GetWindowText(...),<br />
EM_ ... ,<br />
WS_GETTEXT</p>
<p>Leider funktioniert nichts von allem.<br />
Ich bekomm fast immer einen Ausgabewert von 0.</p>
<p>Hier ein bisschen Text von meinem Programm:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

...
...

case WM_CREATE:
  textbox1 = CreateWindow(&quot;edit&quot;, &quot;&quot;,
     WS_CHILD | WS_VISIBLE,
     10, 10, 40, 16,
     hwnd, (HMENU)1, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL);

...
...

case WM_COMMAND:
  if(LOWORD(wParam) == 3) {
     char str[50];
     sprintf(str, &quot;%i&quot;, ...);
     MessageBox(hwnd, str, &quot;MsgBoxTitle&quot;, MB_OK);
  }

...
...
return 0;
</code></pre>
<p>Ich hoffe man kann mir helfen <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>Gruß,<br />
paSe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/171239/gt-caption-gt-text-ect-error</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 04:41:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/171239.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Jan 2007 18:38:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to -&amp;gt;Caption &#x2F; -&amp;gt;Text ect. = Error on Tue, 23 Jan 2007 18:38:53 GMT]]></title><description><![CDATA[<p>Hi,<br />
also zuerst muss ich sagen, dass ich neu hier im Forum bin ^^.<br />
Ich hab mir schon son bissl Cpp angeeignet und verstehe den Grund eigentlich ganz gut.<br />
Ich will nicht lang drum rum reden:</p>
<p>Ich möchte dass er mir via Buttonklick den Text via MessageBox ausgibt, der in einem edit-Window steht. Soweit ist alles klar. Habe dann gleich losgegooglet wie man den Text eines WNDs rausbekommt und bin auf folgede Varianten gestoßen:</p>
<p>Label1-&gt;Text,<br />
Label1-&gt;Caption,<br />
GetWindowText(...),<br />
EM_ ... ,<br />
WS_GETTEXT</p>
<p>Leider funktioniert nichts von allem.<br />
Ich bekomm fast immer einen Ausgabewert von 0.</p>
<p>Hier ein bisschen Text von meinem Programm:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

...
...

case WM_CREATE:
  textbox1 = CreateWindow(&quot;edit&quot;, &quot;&quot;,
     WS_CHILD | WS_VISIBLE,
     10, 10, 40, 16,
     hwnd, (HMENU)1, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL);

...
...

case WM_COMMAND:
  if(LOWORD(wParam) == 3) {
     char str[50];
     sprintf(str, &quot;%i&quot;, ...);
     MessageBox(hwnd, str, &quot;MsgBoxTitle&quot;, MB_OK);
  }

...
...
return 0;
</code></pre>
<p>Ich hoffe man kann mir helfen <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>Gruß,<br />
paSe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1215467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1215467</guid><dc:creator><![CDATA[unlimieD.paSe]]></dc:creator><pubDate>Tue, 23 Jan 2007 18:38:53 GMT</pubDate></item><item><title><![CDATA[Reply to -&amp;gt;Caption &#x2F; -&amp;gt;Text ect. = Error on Tue, 23 Jan 2007 22:17:45 GMT]]></title><description><![CDATA[<p>Ähm also Dein Code ist auch falsch <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>
<blockquote>
<pre><code class="language-cpp">// ...
     sprintf(str, &quot;%i&quot;, ...);
// ...
</code></pre>
</blockquote>
<p>Damit bekommst Du nicht den Text aus dem Fenster.</p>
<p>Mit <em>GetWindowText</em> geht es so (der Einfachheit mal ohne dynamische Speicherallokierung):</p>
<pre><code class="language-cpp">TCHAR szCaption[1024];
GetWindowText(textbox1, szCaption, sizeof(szCaption) / sizeof(szCaption[0]));
MessageBox(hwnd, szCaption, TEXT(&quot;MsgBoxTitle&quot;), MB_OK);
</code></pre>
<p>Das Makro <em>TEXT(&quot;...&quot;)</em> sorgt dafür, dass Du sowohl mit UNICODE als auch mit ANSI arbeiten kannst (genau wie <em>TCHAR</em>).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1215625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1215625</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 23 Jan 2007 22:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to -&amp;gt;Caption &#x2F; -&amp;gt;Text ect. = Error on Wed, 24 Jan 2007 16:30:48 GMT]]></title><description><![CDATA[<p>Danke du hast mir sehr geholfen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216167</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216167</guid><dc:creator><![CDATA[unlimieD.paSe]]></dc:creator><pubDate>Wed, 24 Jan 2007 16:30:48 GMT</pubDate></item></channel></rss>