<?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[Textausgabe im Textfeld]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe ein Textfeld erstellt, in welchem ich einen Text ausgebe. Das klappt auch wunderbar. Der Text ist</p>
<pre><code>CHAR lpszTrouble[] = &quot;When in the Course of human Events &quot; 
                         &quot;it becomes necessary for one People &quot; 
                         &quot;to dissolve the Political Bands which &quot; 
                         &quot;have connected them with another, and &quot; 
                         &quot;to assume among the Powers of the &quot; 
                         &quot;Earth, the separate and equal Station &quot; 
                         &quot;to which the Laws of Nature and of &quot; 
                         &quot;Nature's God entitle them, a decent &quot; 
                         &quot;Respect to the Opinions of Mankind &quot; 
                         &quot;requires that they should declare the &quot; 
                         &quot;causes which impel them to the &quot; 
                         &quot;Separation. &quot;;
</code></pre>
<p>(einfach ein dumb Text von der MSDN Seite). Ich gebe ihn problemlos mit Zeilenumbrüchen mit folgendem Code aus:</p>
<pre><code>SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)lpszTrouble);
</code></pre>
<p>Wie kann ich nun jedoch eine Datei einlesen, die auch Text mit Zeilenumbrüchen ausgibt? In meiner Datei sind einfach 3 Zeilen sinnloser Text, und er wird einfach in einer Zeile ausgegeben. Die Zeilenumbrüche werden durch einen quadratischen Block ersetzt. \n am Ende der Zeilen wird auch nur als Block dargestellt.</p>
<p>Mfg,<br />
iuiz</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/71277/textausgabe-im-textfeld</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 15:54:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/71277.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Apr 2004 16:16:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 16:16:59 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe ein Textfeld erstellt, in welchem ich einen Text ausgebe. Das klappt auch wunderbar. Der Text ist</p>
<pre><code>CHAR lpszTrouble[] = &quot;When in the Course of human Events &quot; 
                         &quot;it becomes necessary for one People &quot; 
                         &quot;to dissolve the Political Bands which &quot; 
                         &quot;have connected them with another, and &quot; 
                         &quot;to assume among the Powers of the &quot; 
                         &quot;Earth, the separate and equal Station &quot; 
                         &quot;to which the Laws of Nature and of &quot; 
                         &quot;Nature's God entitle them, a decent &quot; 
                         &quot;Respect to the Opinions of Mankind &quot; 
                         &quot;requires that they should declare the &quot; 
                         &quot;causes which impel them to the &quot; 
                         &quot;Separation. &quot;;
</code></pre>
<p>(einfach ein dumb Text von der MSDN Seite). Ich gebe ihn problemlos mit Zeilenumbrüchen mit folgendem Code aus:</p>
<pre><code>SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)lpszTrouble);
</code></pre>
<p>Wie kann ich nun jedoch eine Datei einlesen, die auch Text mit Zeilenumbrüchen ausgibt? In meiner Datei sind einfach 3 Zeilen sinnloser Text, und er wird einfach in einer Zeile ausgegeben. Die Zeilenumbrüche werden durch einen quadratischen Block ersetzt. \n am Ende der Zeilen wird auch nur als Block dargestellt.</p>
<p>Mfg,<br />
iuiz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/502808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/502808</guid><dc:creator><![CDATA[iuiz]]></dc:creator><pubDate>Fri, 16 Apr 2004 16:16:59 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 16:23:25 GMT]]></title><description><![CDATA[<p>Hast Du Deinem &quot;Textfeld&quot; die Eigenschaft Multiline verpasst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/502810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/502810</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Fri, 16 Apr 2004 16:23:25 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 16:31:28 GMT]]></title><description><![CDATA[<p>Jo</p>
<pre><code>hEdit = CreateWindowEx(	WS_EX_CLIENTEDGE,
									&quot;EDIT&quot;,      // predefined class 
                                    NULL,        // no window title 
                                    WS_CHILD | WS_VISIBLE | WS_VSCROLL | 
                                    ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL, 
                                    650, 60, 300, 300,
                                    hWnd,        // parent window 
                                    NULL,   // edit control ID 
                                    ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                    NULL);       // pointer not needed
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/502814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/502814</guid><dc:creator><![CDATA[iuiz]]></dc:creator><pubDate>Fri, 16 Apr 2004 16:31:28 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 16:40:58 GMT]]></title><description><![CDATA[<p>Hier ist der Code, mit dem ich jetzt die Datei einlese. Das Create Window hab ich momentan auch wieder ein wenig anders:</p>
<pre><code>#include &lt;string&gt;

//[...]

	using namespace std;
	   ifstream in(&quot;data.txt&quot;);

	string ch;
	while(!in.eof())
	{
		ch+=in.get();
         }

	hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
							&quot;edit&quot;,
							ch.c_str(),    // &lt;- das ist der Inhalt der Editfelds
							WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |
							ES_AUTOVSCROLL,
//[...]
</code></pre>
<p>Sorry für den Doppelpost.... <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>
]]></description><link>https://www.c-plusplus.net/forum/post/502818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/502818</guid><dc:creator><![CDATA[iuiz]]></dc:creator><pubDate>Fri, 16 Apr 2004 16:40:58 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 19:07:30 GMT]]></title><description><![CDATA[<p>Wahrscheinlich hast du in der Textdatei nur \n - du brauchst aber \r\n <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/502885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/502885</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Fri, 16 Apr 2004 19:07:30 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Fri, 16 Apr 2004 23:42:31 GMT]]></title><description><![CDATA[<p>Danke für den Tip. Ich loope jetzt einfach durch die Datei und setze wenn ich \n finde \r ein und ins nächste Feld \n.<br />
Das Problem dass ich dabei zuerst hatte, war dass ich gedacht habe, dass \r\n ein Feld im Arry belegt.</p>
<pre><code class="language-cpp">char data[300];
	char ch;

	FILE *fp;
	fp = fopen(&quot;data.txt&quot;, &quot;r&quot;);

	int position=0;
	while((ch = fgetc(fp)) != EOF)
	{
		if('\n'==ch)
		{
			data[position]='\r';
			data[(position+1)]='\n';
			position++;
		}
		else
			data[position]=ch;

		position++;
	}

	hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
							&quot;edit&quot;,
							data,    // &lt;- das ist der Inhalt der Editfelds
							WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | 
							ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
							0, 490,
							640, 200,
							hWnd,
							NULL,
							((LPCREATESTRUCT) lParam) -&gt; hInstance,
							NULL);
</code></pre>
<p>Jetzt noch eine kleinigkeit: Wie kann ich char data[300]; so initialisieren, dass nicht mehr als die benötigten Felder im Speicher reserviert werden? Die Datei hat z.B. 251 Zeichen. Es sind 3 Zeilenumbrüche drinn, also kommen nochmal 3 Zeichen mehr dazu (aus '\n' wird '\n' '\r').</p>
<p>Ich habe folgenden Code versucht:</p>
<pre><code class="language-cpp">using namespace std;
	   ifstream in(&quot;data.txt&quot;);

	int posi=0;
	string ch2;
	while(!in.eof())
	{
		ch2+=in.get();
		posi=posi+1;
	};
	const int size=ch2.length();

	char data[size];
</code></pre>
<p>Jedoch bekomme ich den Fehler<br />
&quot;error C2057: Konstanter Ausdruck erwartet&quot; (in der Zeile, die hier die letzte ist) size ist doch const int......</p>
]]></description><link>https://www.c-plusplus.net/forum/post/503001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/503001</guid><dc:creator><![CDATA[iuiz]]></dc:creator><pubDate>Fri, 16 Apr 2004 23:42:31 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Sat, 17 Apr 2004 01:33:03 GMT]]></title><description><![CDATA[<p>Du könntest malloc(),LocalLock(), (new und delete) oder sonstwas benutzen...</p>
<pre><code class="language-cpp">char *data;

data=(char*)malloc( size ); // size Bytes Speicher holen

// Irgendwas mit data machen

free(data); // Speicher wieder freigeben.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/503022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/503022</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 17 Apr 2004 01:33:03 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Sat, 17 Apr 2004 06:52:33 GMT]]></title><description><![CDATA[<p>Ansonsten wenn alles nicht hilft dann erstelle Dein Textfeld vorher (z.B. WM_INITDIALOG oder WM_CREATE), lese danach die Datei aus und benutze dann SetDlgItemText(), um dem Textfeld den Text zu verpassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/503040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/503040</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Sat, 17 Apr 2004 06:52:33 GMT</pubDate></item><item><title><![CDATA[Reply to Textausgabe im Textfeld on Sat, 17 Apr 2004 12:09:25 GMT]]></title><description><![CDATA[<p>Hat geklappt.</p>
<p>Danke für die Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/503181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/503181</guid><dc:creator><![CDATA[iuiz]]></dc:creator><pubDate>Sat, 17 Apr 2004 12:09:25 GMT</pubDate></item></channel></rss>