TreeView-Items im Debug-Modus aber nicht im Release-Modus?



  • Hi,
    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!
    hier noch ein Teil des Quellcodes

    hwndTreeView = CreateWindowEx(0, WC_TREEVIEW, "Tree View",
    				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, "Fehler beim erstellen des Tree-View's!", "Nachricht", 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) < 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, "Projekt", 1, 1);
    	AddItemToTree(hwndTV, "C-Quellcodedateien", 1, 2);
    	AddItemToTree(hwndTV, "Header-Dateien", 1, 2);
    	AddItemToTree(hwndTV, "Makefile", 1, 2);
    	AddItemToTree(hwndTV, "Dokumente", 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)&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;
    }
    

    Ich hoffe ihr könnt mir helfen?
    MfG schirrmie


Anmelden zum Antworten