<?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[Probleme mit CMap: Assertion bei Zugriff]]></title><description><![CDATA[<p>Moin!</p>
<p>Ich stehe gerade mit einer CMap auf Kriegsfuß.<br />
Ich will als Schlüssel einen UINT (Control ID) haben und mit dem dann auf einen CString (Tooltip) zugreifen.</p>
<p>Leider habe ich noch nie mit CMap gearbeitet und komme daher nicht weiter.<br />
So weit bin ich:</p>
<pre><code class="language-cpp">// Im Header
CMap&lt;UINT, UINT, CString, CString&gt;		m_mapTooltips;
</code></pre>
<pre><code class="language-cpp">// Im Konstruktor
	m_mapTooltips.InitHashTable(257); // Mehr Dialogelemente gehen nicht

// Später dann füllen
void CBasisView::AddTooltip(UINT f_nCtrlID, CString f_strText)
{
	m_pToolTip-&gt;AddTool(GetDlgItem(f_nCtrlID), f_strText);
	m_mapTooltips.SetAt(f_nCtrlID, f_strText);
}
</code></pre>
<p>Und wenn ich nun mit</p>
<pre><code class="language-cpp">CString CBasisView::GetTipText()
{
	CString strReturn;
	if (m_mapTooltips.Lookup(m_nCtrlID, strReturn))
	{
		return strReturn;
	}

	return _T(&quot;&quot;);
}
</code></pre>
<p>zugreifen will, lande ich da:</p>
<pre><code class="language-cpp">// check to make sure the VTable pointer is valid
	ASSERT(sizeof(CObject) == sizeof(void*));
	if (!AfxIsValidAddress(*(void**)pOb, sizeof(void*), FALSE))
	{
		TRACE0(&quot;ASSERT_VALID fails with illegal vtable pointer.\n&quot;);
		if (AfxAssertFailedLine(lpszFileName, nLine))
			AfxDebugBreak();
		return;     // quick escape
	}
</code></pre>
<p>Was hab ich vergessen/falsch gemacht? <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=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/163579/probleme-mit-cmap-assertion-bei-zugriff</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 11:50:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163579.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 31 Oct 2006 07:54:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 07:55:02 GMT]]></title><description><![CDATA[<p>Moin!</p>
<p>Ich stehe gerade mit einer CMap auf Kriegsfuß.<br />
Ich will als Schlüssel einen UINT (Control ID) haben und mit dem dann auf einen CString (Tooltip) zugreifen.</p>
<p>Leider habe ich noch nie mit CMap gearbeitet und komme daher nicht weiter.<br />
So weit bin ich:</p>
<pre><code class="language-cpp">// Im Header
CMap&lt;UINT, UINT, CString, CString&gt;		m_mapTooltips;
</code></pre>
<pre><code class="language-cpp">// Im Konstruktor
	m_mapTooltips.InitHashTable(257); // Mehr Dialogelemente gehen nicht

// Später dann füllen
void CBasisView::AddTooltip(UINT f_nCtrlID, CString f_strText)
{
	m_pToolTip-&gt;AddTool(GetDlgItem(f_nCtrlID), f_strText);
	m_mapTooltips.SetAt(f_nCtrlID, f_strText);
}
</code></pre>
<p>Und wenn ich nun mit</p>
<pre><code class="language-cpp">CString CBasisView::GetTipText()
{
	CString strReturn;
	if (m_mapTooltips.Lookup(m_nCtrlID, strReturn))
	{
		return strReturn;
	}

	return _T(&quot;&quot;);
}
</code></pre>
<p>zugreifen will, lande ich da:</p>
<pre><code class="language-cpp">// check to make sure the VTable pointer is valid
	ASSERT(sizeof(CObject) == sizeof(void*));
	if (!AfxIsValidAddress(*(void**)pOb, sizeof(void*), FALSE))
	{
		TRACE0(&quot;ASSERT_VALID fails with illegal vtable pointer.\n&quot;);
		if (AfxAssertFailedLine(lpszFileName, nLine))
			AfxDebugBreak();
		return;     // quick escape
	}
</code></pre>
<p>Was hab ich vergessen/falsch gemacht? <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=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165082</guid><dc:creator><![CDATA[estartu]]></dc:creator><pubDate>Tue, 31 Oct 2006 07:55:02 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 09:09:40 GMT]]></title><description><![CDATA[<p>Versuchs mal mit</p>
<pre><code class="language-cpp">CMap&lt;UINT, UINT, CString, CString&amp;&gt; m_mapTooltips;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1165121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165121</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:09:40 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 09:41:29 GMT]]></title><description><![CDATA[<p>Das scheint mir nicht an der Map zu liegen. Der Assert sagt klar, dass es sich um kein gültiges Objekt handelt!<br />
Was zeigt denn der Callstack?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165143</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:41:29 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 09:42:34 GMT]]></title><description><![CDATA[<p>Nein, das war es leider auch nicht. <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="😞"
    /><br />
Also es ist genau diese Funktion in CMap:</p>
<pre><code class="language-cpp">template&lt;class KEY, class ARG_KEY, class VALUE, class ARG_VALUE&gt;
BOOL CMap&lt;KEY, ARG_KEY, VALUE, ARG_VALUE&gt;::Lookup(ARG_KEY key, VALUE&amp; rValue) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc-&gt;value;
	return TRUE;
}
</code></pre>
<p>In Zeile 7 steht der grüne Pfeil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165144</guid><dc:creator><![CDATA[estartu]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:42:34 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 09:49:01 GMT]]></title><description><![CDATA[<p>Martin Richter schrieb:</p>
<blockquote>
<p>Was zeigt denn der Callstack?</p>
</blockquote>
<pre><code>AfxAssertValidObject(const CObject * 0x018c606c {CObject}, const char * 0x101bd784 _szAfxTempl, int 1342) line 96
CMap&lt;unsigned int,unsigned int,CString,CString &amp;&gt;::Lookup(unsigned int 3722304989, CString &amp; {&quot;&quot;}) line 1345
CBasisView::GetTipText() line 363 + 28 bytes
</code></pre>
<p>Das sind die obersten Zeilen. Je der Code davon ist hier schon gepostet.<br />
Kann ich noch irgendwelche Werte nachucken? Ich weiß grade echt nicht, was ich suchen soll.</p>
<p>Wenn der Schlüsselwert nicht existiert, dann müsste ich doch einfach nur FALSE bekommen. <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=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165150</guid><dc:creator><![CDATA[estartu]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:49:01 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 11:57:24 GMT]]></title><description><![CDATA[<p>Ist denn der this Zeiger von CBasisView wirklich nicht NULL. Kommt mir eher vor als ob CBasisView nicht angelegt wurde.<br />
Wie besorgst Du Dir denn den Zeiger?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165262</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 31 Oct 2006 11:57:24 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit CMap: Assertion bei Zugriff on Tue, 31 Oct 2006 12:34:30 GMT]]></title><description><![CDATA[<p>Martin Richter schrieb:</p>
<blockquote>
<p>Ist denn der this Zeiger von CBasisView wirklich nicht NULL. Kommt mir eher vor als ob CBasisView nicht angelegt wurde.<br />
Wie besorgst Du Dir denn den Zeiger?</p>
</blockquote>
<p>Ja, das war es. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
Ich hab das immer noch falsch aufgerufen, weil ich eigentlich nen String mitschicken wollte und dann wegen Castproblemen umgestellt hatte. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Immerhin gibt es jetzt keinen ASSERT mehr - aber den falschen Text.<br />
Mal gucken, was das nun wieder ist.</p>
<p>Vielen Dank erstmal an euch beide. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1165291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165291</guid><dc:creator><![CDATA[estartu]]></dc:creator><pubDate>Tue, 31 Oct 2006 12:34:30 GMT</pubDate></item></channel></rss>