<?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[wieder einmal TreeControl]]></title><description><![CDATA[<p>Hallo,</p>
<p>hätte mal wieder ne Frage zu TreeControl.<br />
und zwar will ich irgendwie den String und/oder die Position (aber hauptsächlich<br />
die bezeichnung) des aktuell ausgewählten Elements ermitteln.<br />
Das Ganze beim Doppelklick auf das jeweilige Element.<br />
Der Code für meine &quot;Test-Strukturansicht&quot; sieht folgendermassen aus:</p>
<pre><code class="language-cpp">HTREEITEM htrItem = NULL, htrItem2 = NULL, htrItem3=NULL, htrItem4=NULL, htrItem5=NULL;;

void CDateitestView::OnButton1() 
{

	HICON m_pIconList;

    if (imagelist.GetSafeHandle() == NULL)
    {
        imagelist.Create(16, 16, ILC_COLOR, 5, 5);
        imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)));		
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK2)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK3)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK4)));	
        m_tree.SetImageList(&amp;imagelist, TVSIL_NORMAL);        

		htrItem = m_tree.InsertItem(&quot;Eintrag 1&quot;, 0, 0);
		htrItem2 = m_tree.InsertItem(&quot;Untereintrag 1&quot;, 1, 1, htrItem);
		htrItem3 = m_tree.InsertItem(&quot;Untereintrag 2&quot;, 2, 2, htrItem);
		htrItem4 = m_tree.InsertItem(&quot;Unteruntereintrag&quot;, 3, 3, htrItem2);
		htrItem5 = m_tree.InsertItem(&quot;Unterunteruntereintrag&quot;, 4, 4, htrItem4);
    }
}
</code></pre>
<p>für den Doppelklick-Handler hab ich vom Assistenten folgenden Code erhalten,<br />
in dem ich zu Testzwecken einen neues Item erstellen gelassen hatte:</p>
<pre><code class="language-cpp">void CDateitestView::OnDblclkTree(NMHDR* pNMHDR, LRESULT* pResult) 
{	
	//NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

/*
	CString strPathName = &quot;Neues Element&quot;;
    HTREEITEM hItem=NULL;
	hItem = m_tree.InsertItem(strPathName, 0,0);
*/

	*pResult = 0;
}
</code></pre>
<p>Kennt sich da jemand aus? <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/69874/wieder-einmal-treecontrol</link><generator>RSS for Node</generator><lastBuildDate>Fri, 01 May 2026 19:16:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/69874.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 Apr 2004 13:11:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wieder einmal TreeControl on Thu, 01 Apr 2004 13:12:22 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>hätte mal wieder ne Frage zu TreeControl.<br />
und zwar will ich irgendwie den String und/oder die Position (aber hauptsächlich<br />
die bezeichnung) des aktuell ausgewählten Elements ermitteln.<br />
Das Ganze beim Doppelklick auf das jeweilige Element.<br />
Der Code für meine &quot;Test-Strukturansicht&quot; sieht folgendermassen aus:</p>
<pre><code class="language-cpp">HTREEITEM htrItem = NULL, htrItem2 = NULL, htrItem3=NULL, htrItem4=NULL, htrItem5=NULL;;

void CDateitestView::OnButton1() 
{

	HICON m_pIconList;

    if (imagelist.GetSafeHandle() == NULL)
    {
        imagelist.Create(16, 16, ILC_COLOR, 5, 5);
        imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)));		
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK2)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK3)));	
		imagelist.Add(::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MK4)));	
        m_tree.SetImageList(&amp;imagelist, TVSIL_NORMAL);        

		htrItem = m_tree.InsertItem(&quot;Eintrag 1&quot;, 0, 0);
		htrItem2 = m_tree.InsertItem(&quot;Untereintrag 1&quot;, 1, 1, htrItem);
		htrItem3 = m_tree.InsertItem(&quot;Untereintrag 2&quot;, 2, 2, htrItem);
		htrItem4 = m_tree.InsertItem(&quot;Unteruntereintrag&quot;, 3, 3, htrItem2);
		htrItem5 = m_tree.InsertItem(&quot;Unterunteruntereintrag&quot;, 4, 4, htrItem4);
    }
}
</code></pre>
<p>für den Doppelklick-Handler hab ich vom Assistenten folgenden Code erhalten,<br />
in dem ich zu Testzwecken einen neues Item erstellen gelassen hatte:</p>
<pre><code class="language-cpp">void CDateitestView::OnDblclkTree(NMHDR* pNMHDR, LRESULT* pResult) 
{	
	//NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

/*
	CString strPathName = &quot;Neues Element&quot;;
    HTREEITEM hItem=NULL;
	hItem = m_tree.InsertItem(strPathName, 0,0);
*/

	*pResult = 0;
}
</code></pre>
<p>Kennt sich da jemand aus? <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/493078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/493078</guid><dc:creator><![CDATA[Bummsfallera]]></dc:creator><pubDate>Thu, 01 Apr 2004 13:12:22 GMT</pubDate></item><item><title><![CDATA[Reply to wieder einmal TreeControl on Thu, 01 Apr 2004 13:38:36 GMT]]></title><description><![CDATA[<p>GetItemText, GetSelectedItem</p>
<p>Devil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/493110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/493110</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Thu, 01 Apr 2004 13:38:36 GMT</pubDate></item><item><title><![CDATA[Reply to wieder einmal TreeControl on Thu, 01 Apr 2004 13:42:32 GMT]]></title><description><![CDATA[<p>Cool, DANKE!</p>
<p>Das war wieder einmal zu einfach um selbst draufzukommen.<br />
Hab da echt gestanden wie der Ochs vorm Berg.</p>
<p>VG, Marco!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/493115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/493115</guid><dc:creator><![CDATA[Bummsfallera]]></dc:creator><pubDate>Thu, 01 Apr 2004 13:42:32 GMT</pubDate></item></channel></rss>