Click here to Skip to main content
15,906,574 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionNeed XML Alternative for Persisting Object Data Pin
Peter Weyzen17-May-08 16:28
Peter Weyzen17-May-08 16:28 
QuestionChanging The Title & Icon Of Dialog Box At Run Time Pin
Joseph Marzbani17-May-08 8:05
Joseph Marzbani17-May-08 8:05 
AnswerRe: Changing The Title & Icon Of Dialog Box At Run Time Pin
Nelek17-May-08 8:26
protectorNelek17-May-08 8:26 
AnswerRe: Changing The Title & Icon Of Dialog Box At Run Time Pin
CPallini17-May-08 8:41
mveCPallini17-May-08 8:41 
GeneralRe: Changing The Title & Icon Of Dialog Box At Run Time Pin
Nelek18-May-08 0:42
protectorNelek18-May-08 0:42 
AnswerRe: Changing The Title & Icon Of Dialog Box At Run Time Pin
Peter Weyzen17-May-08 17:17
Peter Weyzen17-May-08 17:17 
AnswerRe: Changing The Title & Icon Of Dialog Box At Run Time Pin
Hamid_RT17-May-08 19:13
Hamid_RT17-May-08 19:13 
QuestionOnly one Icon in my treeview! Pin
CrocodileBuck17-May-08 8:00
CrocodileBuck17-May-08 8:00 
Hi Wink | ;) ,

i coded a working treeview(SDI/Windows Explorer Style), but hardly without icons, there is shown only one icon in my treeview.
Pic Wink | ;) :
http://filehosting.at/images/download.php?file=b14ad20aa1a01412004995061e3202bb

I want to show the original explorer icons in my treeview so i tried it with
SHGetFileInfo()

...but it won't work Confused | :confused:

Here is some sample code (i don't want to post too much):

1. This function detects the drives and labels :
void CLeftView::CreateRoots()
{
    CString	strMessage;
    int		nPos = 65;
    CString strDrive;
	TCHAR	szLabel[128];
	DWORD	dwVolumeSerialNumber;
	DWORD	dwMaxNameLength;
	DWORD	dwFileSystemFlags;
	TCHAR	szFileSysName[128];
	
	UINT	uDriveType;
	CString cstrWirDir;
	TCHAR	infoBuf[INFO_BUFFER_SIZE];
	DWORD	dwDriveList = GetLogicalDrives ();			// Anzahl der Laufwerke ermitteln


//----------------------------------------------------------------------------------------------------------------

	GetWindowsDirectory(infoBuf, INFO_BUFFER_SIZE);
	cstrWirDir = infoBuf;
	cstrWirDir = cstrWirDir.GetAt(0);
	cstrWirDir = cstrWirDir + ":";

//----------------------------------------------------------------------------------------------------------------


    while (dwDriveList) 
 	{
        if (dwDriveList & 1) 
 		{
			strDrive = "?:\\";
            strDrive.SetAt (0,nPos);
			uDriveType = GetDriveType(strDrive);
			
			GetVolumeInformation (strDrive, szLabel,
						          sizeof( szLabel ) - 1,
								  &dwVolumeSerialNumber,
								  &dwMaxNameLength,
								  &dwFileSystemFlags,
								  szFileSysName,
								  sizeof( szFileSysName ) - 1);	
			
			switch(uDriveType)
			{

				// ToDo: Wenn kein Name für Diskettenlaufwerk(und andere), dann vorgefertigtes Label
				case 2: // Diskettenlaufwerk
					strDrive = strDrive.Left(2);
					InsertFileItem("3½-Diskette (" + strDrive +")");
					break;
				case 3: // Festplatte
					strDrive = strDrive.Left(2);
					// AfxMessageBox(strDrive, MB_OK);
					InsertFileItem((CString)szLabel + " (" + strDrive +")");
					break;
				case 5: // CD-Rom
					strDrive = strDrive.Left(2);
					InsertFileItem((CString)szLabel + " (" + strDrive +")"); 					
					break;
				default:
					break;
			}
        }
        dwDriveList >>= 1;
        nPos++;
    }
}



2. This function should build the tree with all the icons :
void CLeftView::InsertFileItem(const CString sFile)
{
 	CTreeCtrl &trCtrl = this->GetTreeCtrl();
	trCtrl.SetImageList(&m_SysImageList.GetImageList(), TVSIL_NORMAL); 
 		
    SHFILEINFO sfi;
    SHGetFileInfo(sFile, 0, &sfi, sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

	//Gibt den IconIndex des Files/Datei zurück
	int nIconIndex;
	nIconIndex = sfi.iIcon;

	//Hängt das aktuelle Item an
	CString sTemp = sFile;
	TV_INSERTSTRUCT tvis;
	ZeroMemory(&tvis, sizeof(TV_INSERTSTRUCT));
	tvis.hParent			= TVI_ROOT;
	tvis.hInsertAfter		= TVI_LAST;
	tvis.item.mask			= TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
	tvis.item.pszText = sTemp.GetBuffer(sTemp.GetLength());
	tvis.item.iImage = nIconIndex;  
	trCtrl.InsertItem(&tvis);
	sTemp.ReleaseBuffer();


I don't know if it is enough code or not to detect my mistake so i uploaded a very small project (only the treeview with my code) here :
[url]http://www.filehosting.at/files/download.php?file=1cadb172342f4f83577c45e72addfc42[/url]


Thank you very much for your help
best regards
Cocodile Buck Smile | :)
AnswerRe: Only one Icon in my treeview! Pin
Nathan Holt at EMOM17-May-08 8:45
Nathan Holt at EMOM17-May-08 8:45 
GeneralRe: Only one Icon in my treeview! Pin
CrocodileBuck17-May-08 11:00
CrocodileBuck17-May-08 11:00 
AnswerRe: Only one Icon in my treeview! Pin
Iain Clarke, Warrior Programmer17-May-08 13:36
Iain Clarke, Warrior Programmer17-May-08 13:36 
GeneralRe: Only one Icon in my treeview! Pin
CrocodileBuck17-May-08 22:08
CrocodileBuck17-May-08 22:08 
GeneralRe: Only one Icon in my treeview! Pin
CrocodileBuck18-May-08 7:44
CrocodileBuck18-May-08 7:44 
GeneralRe: Only one Icon in my treeview! Pin
Iain Clarke, Warrior Programmer19-May-08 5:45
Iain Clarke, Warrior Programmer19-May-08 5:45 
QuestionHow do I use this api call for C++ Pin
luisgrimaldo17-May-08 6:15
luisgrimaldo17-May-08 6:15 
AnswerRe: How do I use this api call for C++ Pin
Hamid_RT17-May-08 6:40
Hamid_RT17-May-08 6:40 
GeneralRe: How do I use this api call for C++ Pin
luisgrimaldo17-May-08 7:14
luisgrimaldo17-May-08 7:14 
GeneralRe: How do I use this api call for C++ Pin
Hamid_RT17-May-08 7:25
Hamid_RT17-May-08 7:25 
GeneralRe: How do I use this api call for C++ Pin
luisgrimaldo17-May-08 8:06
luisgrimaldo17-May-08 8:06 
GeneralRe: How do I use this api call for C++ Pin
bob1697217-May-08 9:39
bob1697217-May-08 9:39 
GeneralRe: How do I use this api call for C++ Pin
Hamid_RT17-May-08 19:11
Hamid_RT17-May-08 19:11 
AnswerRe: How do I use this api call for C++ Pin
Hamid_RT17-May-08 6:51
Hamid_RT17-May-08 6:51 
GeneralRe: How do I use this api call for C++ Pin
ThatsAlok6-Jul-09 21:01
ThatsAlok6-Jul-09 21:01 
GeneralRe: How do I use this api call for C++ Pin
Hamid_RT7-Jul-09 1:06
Hamid_RT7-Jul-09 1:06 
Questionnot allowing the edit option for an combobox Pin
sunny_vc17-May-08 0:13
sunny_vc17-May-08 0:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.