<?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[Dynamische array laenge]]></title><description><![CDATA[<p>jemand ne idee wie ich das hier dynamisch bekomm?</p>
<pre><code class="language-cpp">TCHAR str[256] = {'\0'};

LVITEM item;
item.cchTextMax = 256;
item.pszText = str;

::SendMessage(m_Handle, LVM_GETITEMTEXT, Pos, (LPARAM)(LVITEM *)&amp;item);
</code></pre>
<p>bei einer listbox geht:</p>
<pre><code class="language-cpp">int NameLenght = ((int)::SendMessage(m_Handle, LB_GETTEXTLEN, Pos, NULL)+1);
</code></pre>
<p>aber bei einer list control?<br />
soll fuer item und subitem funktionieren, bisher hab ich es wie man sieht auf 256 begrenzt</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/170083/dynamische-array-laenge</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 09:07:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170083.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Jan 2007 14:55:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 14:55:40 GMT]]></title><description><![CDATA[<p>jemand ne idee wie ich das hier dynamisch bekomm?</p>
<pre><code class="language-cpp">TCHAR str[256] = {'\0'};

LVITEM item;
item.cchTextMax = 256;
item.pszText = str;

::SendMessage(m_Handle, LVM_GETITEMTEXT, Pos, (LPARAM)(LVITEM *)&amp;item);
</code></pre>
<p>bei einer listbox geht:</p>
<pre><code class="language-cpp">int NameLenght = ((int)::SendMessage(m_Handle, LB_GETTEXTLEN, Pos, NULL)+1);
</code></pre>
<p>aber bei einer list control?<br />
soll fuer item und subitem funktionieren, bisher hab ich es wie man sieht auf 256 begrenzt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1207999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1207999</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 14:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 15:02:28 GMT]]></title><description><![CDATA[<p>Wo ist denn das Problem ?!</p>
<p>...</p>
<pre><code class="language-cpp">TCHAR* pszDspBuffer = new TCHAR[ANZAHL];

LVITEM item;
item.cchTextMax = ANZAHL;
item.pszText = pszDspBuffer;

::SendMessage(m_Handle, LVM_GETITEMTEXT, Pos, (LPARAM)&amp;item);
</code></pre>
<p>Vergiss aber nicht den angeforderten Speicher wieder freizugeben <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/1208007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208007</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 11 Jan 2007 15:02:28 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 15:06:14 GMT]]></title><description><![CDATA[<p>ich moechte &quot;ANZAHL&quot; aus dem text ermitteln - dh wenn das itemtext nur 6 zeichen lang ist, das ich auch nur 7 reserviere<br />
so gehts bei einer einfachen listbox</p>
<pre><code class="language-cpp">int NameLenght = ((int)::SendMessage(m_Handle, LB_GETTEXTLEN, Pos, NULL)+1);
TCHAR *Name = new TCHAR[NameLenght];
SecureZeroMemory(Name, NameLenght);
::SendMessage(m_Handle, LB_GETTEXT, select, (LPARAM)Name);
delete [] Name;
</code></pre>
<p>und das moechte ich in einer list control auch koennen, fuer das item und das subitem</p>
<p>//change tippfehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208013</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 15:06:14 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 15:15:03 GMT]]></title><description><![CDATA[<p>Kenn ich auch keine Lösung für, aber probier mal aus, item.cchTextMax und item.pszText auf 0 zu setzen. Vielleicht ist nach der LVM_GETITEMTEXT die Länge des Strings in item.cchTextMax drin <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=":/"
      alt="😕"
    /> Wirklich nur vielleicht, wahrscheinlich schlägts fehl, aber nen Versuch ists wert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208022</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Thu, 11 Jan 2007 15:15:03 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 15:39:23 GMT]]></title><description><![CDATA[<p>Hab grad das hier mit <a href="http://google.com/codesearch" rel="nofollow">google.com/codesearch</a> gefunden:</p>
<pre><code class="language-cpp">BOOL GetItemText(int nItem, int nSubItem, BSTR&amp; bstrText) const
	{
		USES_CONVERSION;
		ATLASSERT(::IsWindow(m_hWnd));
		ATLASSERT(bstrText == NULL);
		LVITEM lvi;
		memset(&amp;lvi, 0, sizeof(LVITEM));
		lvi.iSubItem = nSubItem;

		LPTSTR lpstrText = NULL;
		int nRes = 0;
		for(int nLen = 256; ; nLen *= 2)
		{
			ATLTRY(lpstrText = new TCHAR[nLen]);
			if(lpstrText == NULL)
				break;
			lpstrText[0] = NULL;
			lvi.cchTextMax = nLen;
			lvi.pszText = lpstrText;
			nRes  = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&amp;lvi);
			if(nRes &lt; nLen - 1)
				break;
			delete [] lpstrText;
			lpstrText = NULL;
		}

		if(lpstrText != NULL)
		{
			if(nRes != 0)
				bstrText = ::SysAllocString(T2OLE(lpstrText));
			delete [] lpstrText;
		}

		return (bstrText != NULL) ? TRUE : FALSE;
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1208046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208046</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Thu, 11 Jan 2007 15:39:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 15:55:58 GMT]]></title><description><![CDATA[<p>Aber die Funktion allokiert intern Speicher...sowas ist eigentlich unüblich. Dann sollteste vllt. ne Referenz auf n std::string-Objekt übergeben <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/1208065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208065</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 11 Jan 2007 15:55:58 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 16:26:34 GMT]]></title><description><![CDATA[<p>Oh stimmt :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208096</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Thu, 11 Jan 2007 16:26:34 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 17:27:40 GMT]]></title><description><![CDATA[<p>std::wstring waehre natuelrich das beste, da diese funktion das auch returniert, aber leider funktioniert nichts davon:</p>
<p>ich hab hier ein paar versionen probiert, alle compilieren, aber es landet nichts in str, es bleibt immer leer</p>
<pre><code class="language-cpp">std::wstring str = _T(&quot;&quot;);
LVITEM item;
item.iSubItem = Number;
//item.pszText = (LPWSTR)&amp;str; //- leer nach SendMessage
//item.pszText = (LPWSTR)str.c_str(); //- leer nach SendMessage
::SendMessage(m_Handle, LVM_GETITEMTEXT, Pos, (LPARAM)(LVITEM *)&amp;item);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1208142</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208142</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 17:27:40 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 17:50:18 GMT]]></title><description><![CDATA[<p>das funktioniert:</p>
<pre><code class="language-cpp">std::wstring funk(UINT Number, UINT Pos){
    std::wstring str = _T(&quot;&quot;);
    LVITEM item;
    item.iSubItem = Number;
    item.cchTextMax = (int)str.max_size();
    item.pszText = (LPWSTR)str.c_str();
    ::SendMessage(m_Handle, LVM_GETITEMTEXT, Pos, (LPARAM)(LVITEM *)&amp;item);
    return str.c_str();
}
</code></pre>
<p>was ich mich allerdings frage ist, ist es teuer wenn ich pszTextMax die maximale groesse von wstring geb [ist mehr als 1miliarde}</p>
<p>//qt geaendert da es erst nicht ging</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208149</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 17:50:18 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 17:49:57 GMT]]></title><description><![CDATA[<p>Ähm Dein Code ist falsch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> !</p>
<p>Du machst einen const Cast. Da muss man bei C++ Strings sehr aufpassen:</p>
<pre><code class="language-cpp">item.pszText = (LPWSTR)str.c_str();
</code></pre>
<p>Außerdem ist std::wstring auch nicht Zeichensatzunabhänig (da es eben NUR mit UNICODE funktioniert, siehe Definition)... . Da müsste man schon sowas machen:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
// namespace NCppString
// {
   #ifdef UNICODE
     typedef std::wstring CString;
   #else
     typedef std::string  CString;
   #endif // UNICODE
// };
</code></pre>
<p>Ob der Scope notwendig ist, hängt davon ab, ob du MFC nutzt (da wir hier im WinAPI-Subforum sind, hab ichs deshalb auskommentiert <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/1208155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208155</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 11 Jan 2007 17:49:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 17:53:05 GMT]]></title><description><![CDATA[<p>ich hab den code geaendert, nu funktioniert alles,</p>
<p>das mit unicode weiss ich, das ist auch ok so, ich compiliere IMMER und ALLES NUR auf unicode, multibyte hab ich bisher nie auch nur ein kleines prograemmchen geschrieben #gg</p>
<p>auch damals fuer die firma, das programm was die codepages umgespeichert hat, hab ich alles unicode compiliert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208156</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 17:53:05 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 18:59:34 GMT]]></title><description><![CDATA[<p>IMHO können Win95 und Win98 kein Unicode, stört dich das nicht? (Nicht dass du mich falsch verstehst, mich würde es auch nicht stören :D)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208188</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Thu, 11 Jan 2007 18:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 19:49:22 GMT]]></title><description><![CDATA[<p>was interessiert mich 95 oder 98 #gg - es funktioniert alles unter 2k - xp und vista, das reicht mir {o;</p>
<p>wer 95 oder 98 noch benutzt hat 1. selber schuld und 2. braucht meine programme nicht #gg {o;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208239</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 11 Jan 2007 19:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Thu, 11 Jan 2007 23:18:22 GMT]]></title><description><![CDATA[<p>Also ähm ich finde '<em>wer 95 oder 98 noch benutzt hat 1. selber schuld und 2. braucht meine programme nicht #gg {o;</em>' n bissl sinnlos, da ich mir nicht vorstellen kann, dass Deine Programme in China zur Verwendung kommen :p . Da sollte man doch lieber auf geringeren Speicherverbrauch setzen, oder noch besser: auf beides.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208363</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 11 Jan 2007 23:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Fri, 12 Jan 2007 06:29:41 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p>da ich mir nicht vorstellen kann, dass Deine Programme in China zur Verwendung kommen</p>
</blockquote>
<p>meeep - falsch, meine programme werden fast immer in 25 verschiedenen sprachen verwendet, von CHT/CHS bis hin zu ELL und THA {o;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208412</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 12 Jan 2007 06:29:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Fri, 12 Jan 2007 08:07:05 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p>Du machst einen const Cast. Da muss man bei C++ Strings sehr aufpassen:</p>
<pre><code class="language-cpp">item.pszText = (LPWSTR)str.c_str();
</code></pre>
</blockquote>
<p>Direkte typspzifische casts würde grundsätzlich in #ifdef _UNICODE Blöcke einschließen. Ansonsten gehört eben LPTSTR verwendet!<br />
Das ist mit Abstand das sicherste und flexibelste!</p>
<p>Und wenn dieser Code eben nur für Unicode funktioniert, dann gehört in die #else Sektion oder in den Programmkopf #error rein!<br />
Der Programmkopf hat natürlich den Nachteil, dass man ihn nicht sieht, wenn man solche Code-Passagen kopiert! So was mach CPP Programmierer (Copy&amp;Paste Programmer) ja ständig... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208441</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 12 Jan 2007 08:07:05 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamische array laenge on Fri, 12 Jan 2007 09:22:39 GMT]]></title><description><![CDATA[<p>achwat, warum so viel stress machen mit den ganzen ifdef gebla, das sind meine sources und diese werden immer nur unicode compiliert, auch die anderen die bekommen die sources + solution, und jeder proggt nur in unicode, grade weil alles in 25 sprachen uebersetzt wird</p>
<p>multibyte kann und werd ich komplett ignorieren</p>
<p>//dazuedit, tschuldige wenns ein bissl forsch klang, danke fuer die gut gemeinten ratschlaege {= weiss es selbstverstaendlich zu schaetzen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1208456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1208456</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 12 Jan 2007 09:22:39 GMT</pubDate></item></channel></rss>