<?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[TreeView-Items im Debug-Modus aber nicht im Release-Modus?]]></title><description><![CDATA[<p>Hi,<br />
Habe ein kleines Prob. Mein TreeView ist soweit fertig das Problem ist das im Debug-Modus alles funzt aber Im Release-Modus ich nur ein leeres Fenster angezeigt bekomme also ohne den Items. Ich benutze Visual Studio 6.0 und es ist auf Win 98 und XP so!<br />
hier noch ein Teil des Quellcodes</p>
<pre><code>hwndTreeView = CreateWindowEx(0, WC_TREEVIEW, &quot;Tree View&quot;,
				WS_VISIBLE | WS_CHILD | WS_BORDER | WS_THICKFRAME | TVS_HASLINES
				| TVS_HASBUTTONS | TVS_LINESATROOT, 
				0, 25, 150, 300, hwnd, (HMENU)ID_TREEVIEW, 
				ghInstance, NULL);
			if(hwndTreeView == NULL)
				ShowError();
			if(!InitTreeViewImageLists(hwndTreeView) || !InitTreeViewItems(hwndTreeView))
			{
				MessageBox(NULL, &quot;Fehler beim erstellen des Tree-View's!&quot;, &quot;Nachricht&quot;, MB_OK);
				DestroyWindow(hwndTreeView); 
			}

BOOL InitTreeViewImageLists(HWND hwndTV)
{ 
    HIMAGELIST himl;  // handle to image list 
    HBITMAP hbmp;     // handle to bitmap 

    // Create the image list. 
    if((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, FALSE, NUM_BITMAPS, 0)) == NULL) 
        return FALSE; 

    // Add the open file, closed file, and document bitmaps. 
	hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_OPEN_FILE));
	if(hbmp == NULL)
		return false;
	g_nOpen = ImageList_Add(himl, hbmp, (HBITMAP)NULL);
	DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_CLOSED_FILE));
 	if(hbmp == NULL)
		return false;
    g_nClosed = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT)); 
	if(hbmp == NULL)
		return false;
    g_nDocument = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_C)); 
	if(hbmp == NULL)
		return false;
    g_nCfile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_H)); 
	if(hbmp == NULL)
		return false;
    g_nHfile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_MAKEFILE)); 
	if(hbmp == NULL)
		return false;
    g_nMakefile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

	// Fail if not all of the images were added. 
    if(ImageList_GetImageCount(himl) &lt; 6) 
        return FALSE; 

    // Associate the image list with the tree-view control. 
    TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL); 

    return TRUE; 
} 

BOOL InitTreeViewItems(HWND hwndTV)//, LPSTR lpszFileName) 
{ 
	// Add the item to the tree-view control. 
	AddItemToTree(hwndTV, &quot;Projekt&quot;, 1, 1);
	AddItemToTree(hwndTV, &quot;C-Quellcodedateien&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Header-Dateien&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Makefile&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Dokumente&quot;, 1, 2);

    return TRUE; 
} 

/*	nBitmap == 1 Ordner
	nBitmap == 2 c-Datei
	nBitmap == 3 h-Datei
	nBitmap == 4 MakeFile
	nBitmap == 5 Document
*/
HTREEITEM AddItemToTree(HWND hwndTV, LPSTR lpszItem, int nBitmap, int nLevel)
{ 
	TVITEM tvi; 
	TVINSERTSTRUCT tvins; 
	static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST; 
	static HTREEITEM hPrevRootItem = NULL; 
	static HTREEITEM hPrevLev2Item = NULL; 

	tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; 

	// Set the text of the item. 
	tvi.pszText = lpszItem; 
	tvi.cchTextMax = sizeof(tvi.pszText) / sizeof(tvi.pszText[0]); 

	// Assume the item is not a parent item, so give it a 
	// document image. 
	switch(nBitmap)
	{
	case 1:
		tvi.iImage = g_nClosed; 
		tvi.iSelectedImage = g_nClosed; 
		break;
	case 2:
		tvi.iImage = g_nCfile; 
		tvi.iSelectedImage = g_nCfile; 
		break;
	case 3:
		tvi.iImage = g_nHfile; 
		tvi.iSelectedImage = g_nHfile; 
		break;
	case 4:
		tvi.iImage = g_nMakefile; 
		tvi.iSelectedImage = g_nMakefile; 
		break;
	case 5:
		tvi.iImage = g_nDocument; 
		tvi.iSelectedImage = g_nDocument; 
		break;
	default:
		tvi.iImage = g_nDocument; 
		tvi.iSelectedImage = g_nDocument; 
		break;

	}
	// Save the heading level in the item's application-defined 
	// data area. 
	tvins.item = tvi; 
	tvins.hInsertAfter = hPrev; 

	// Set the parent item based on the specified level. 
	if (nLevel == 1) 
		tvins.hParent = TVI_ROOT;
	else if (nLevel == 2) 
		tvins.hParent = hPrevRootItem; 
	else 
		tvins.hParent = hPrevLev2Item; 

	// Add the item to the tree-view control. 
	hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&amp;tvins); 
	if(hPrev == NULL)
		return false;

	// Save the handle to the item. 
	if(nLevel == 1)
		hPrevRootItem = hPrev;
	else if(nLevel == 2)
		hPrevLev2Item = hPrev;

	return hPrev;
}
</code></pre>
<p>Ich hoffe ihr könnt mir helfen?<br />
MfG schirrmie</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/93441/treeview-items-im-debug-modus-aber-nicht-im-release-modus</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 02:31:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/93441.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Nov 2004 15:03:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TreeView-Items im Debug-Modus aber nicht im Release-Modus? on Mon, 29 Nov 2004 15:03:39 GMT]]></title><description><![CDATA[<p>Hi,<br />
Habe ein kleines Prob. Mein TreeView ist soweit fertig das Problem ist das im Debug-Modus alles funzt aber Im Release-Modus ich nur ein leeres Fenster angezeigt bekomme also ohne den Items. Ich benutze Visual Studio 6.0 und es ist auf Win 98 und XP so!<br />
hier noch ein Teil des Quellcodes</p>
<pre><code>hwndTreeView = CreateWindowEx(0, WC_TREEVIEW, &quot;Tree View&quot;,
				WS_VISIBLE | WS_CHILD | WS_BORDER | WS_THICKFRAME | TVS_HASLINES
				| TVS_HASBUTTONS | TVS_LINESATROOT, 
				0, 25, 150, 300, hwnd, (HMENU)ID_TREEVIEW, 
				ghInstance, NULL);
			if(hwndTreeView == NULL)
				ShowError();
			if(!InitTreeViewImageLists(hwndTreeView) || !InitTreeViewItems(hwndTreeView))
			{
				MessageBox(NULL, &quot;Fehler beim erstellen des Tree-View's!&quot;, &quot;Nachricht&quot;, MB_OK);
				DestroyWindow(hwndTreeView); 
			}

BOOL InitTreeViewImageLists(HWND hwndTV)
{ 
    HIMAGELIST himl;  // handle to image list 
    HBITMAP hbmp;     // handle to bitmap 

    // Create the image list. 
    if((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, FALSE, NUM_BITMAPS, 0)) == NULL) 
        return FALSE; 

    // Add the open file, closed file, and document bitmaps. 
	hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_OPEN_FILE));
	if(hbmp == NULL)
		return false;
	g_nOpen = ImageList_Add(himl, hbmp, (HBITMAP)NULL);
	DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_CLOSED_FILE));
 	if(hbmp == NULL)
		return false;
    g_nClosed = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT)); 
	if(hbmp == NULL)
		return false;
    g_nDocument = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_C)); 
	if(hbmp == NULL)
		return false;
    g_nCfile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_H)); 
	if(hbmp == NULL)
		return false;
    g_nHfile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

    hbmp = LoadBitmap(ghInstance, MAKEINTRESOURCE(IDB_DOCUMENT_MAKEFILE)); 
	if(hbmp == NULL)
		return false;
    g_nMakefile = ImageList_Add(himl, hbmp, (HBITMAP)NULL); 
    DeleteObject(hbmp); 

	// Fail if not all of the images were added. 
    if(ImageList_GetImageCount(himl) &lt; 6) 
        return FALSE; 

    // Associate the image list with the tree-view control. 
    TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL); 

    return TRUE; 
} 

BOOL InitTreeViewItems(HWND hwndTV)//, LPSTR lpszFileName) 
{ 
	// Add the item to the tree-view control. 
	AddItemToTree(hwndTV, &quot;Projekt&quot;, 1, 1);
	AddItemToTree(hwndTV, &quot;C-Quellcodedateien&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Header-Dateien&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Makefile&quot;, 1, 2);
	AddItemToTree(hwndTV, &quot;Dokumente&quot;, 1, 2);

    return TRUE; 
} 

/*	nBitmap == 1 Ordner
	nBitmap == 2 c-Datei
	nBitmap == 3 h-Datei
	nBitmap == 4 MakeFile
	nBitmap == 5 Document
*/
HTREEITEM AddItemToTree(HWND hwndTV, LPSTR lpszItem, int nBitmap, int nLevel)
{ 
	TVITEM tvi; 
	TVINSERTSTRUCT tvins; 
	static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST; 
	static HTREEITEM hPrevRootItem = NULL; 
	static HTREEITEM hPrevLev2Item = NULL; 

	tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; 

	// Set the text of the item. 
	tvi.pszText = lpszItem; 
	tvi.cchTextMax = sizeof(tvi.pszText) / sizeof(tvi.pszText[0]); 

	// Assume the item is not a parent item, so give it a 
	// document image. 
	switch(nBitmap)
	{
	case 1:
		tvi.iImage = g_nClosed; 
		tvi.iSelectedImage = g_nClosed; 
		break;
	case 2:
		tvi.iImage = g_nCfile; 
		tvi.iSelectedImage = g_nCfile; 
		break;
	case 3:
		tvi.iImage = g_nHfile; 
		tvi.iSelectedImage = g_nHfile; 
		break;
	case 4:
		tvi.iImage = g_nMakefile; 
		tvi.iSelectedImage = g_nMakefile; 
		break;
	case 5:
		tvi.iImage = g_nDocument; 
		tvi.iSelectedImage = g_nDocument; 
		break;
	default:
		tvi.iImage = g_nDocument; 
		tvi.iSelectedImage = g_nDocument; 
		break;

	}
	// Save the heading level in the item's application-defined 
	// data area. 
	tvins.item = tvi; 
	tvins.hInsertAfter = hPrev; 

	// Set the parent item based on the specified level. 
	if (nLevel == 1) 
		tvins.hParent = TVI_ROOT;
	else if (nLevel == 2) 
		tvins.hParent = hPrevRootItem; 
	else 
		tvins.hParent = hPrevLev2Item; 

	// Add the item to the tree-view control. 
	hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&amp;tvins); 
	if(hPrev == NULL)
		return false;

	// Save the handle to the item. 
	if(nLevel == 1)
		hPrevRootItem = hPrev;
	else if(nLevel == 2)
		hPrevLev2Item = hPrev;

	return hPrev;
}
</code></pre>
<p>Ich hoffe ihr könnt mir helfen?<br />
MfG schirrmie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/661936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/661936</guid><dc:creator><![CDATA[schirrmie]]></dc:creator><pubDate>Mon, 29 Nov 2004 15:03:39 GMT</pubDate></item></channel></rss>