Click here to Skip to main content
15,921,716 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Description of different shortings Pin
frankis782-Oct-06 11:00
frankis782-Oct-06 11:00 
GeneralRe: Description of different shortings Pin
Christian Graus2-Oct-06 11:17
protectorChristian Graus2-Oct-06 11:17 
GeneralRe: Description of different shortings Pin
frankis782-Oct-06 11:24
frankis782-Oct-06 11:24 
GeneralRe: Description of different shortings Pin
Christian Graus2-Oct-06 11:26
protectorChristian Graus2-Oct-06 11:26 
GeneralRe: Description of different shortings Pin
frankis782-Oct-06 11:41
frankis782-Oct-06 11:41 
GeneralRe: Description of different shortings Pin
Christian Graus2-Oct-06 11:47
protectorChristian Graus2-Oct-06 11:47 
AnswerRe: Description of different shortings Pin
Hamid_RT1-Oct-06 21:06
Hamid_RT1-Oct-06 21:06 
QuestionLVN_GETDISPINFO and LVIF_DI_SETITEM Pin
Mohammad A Gdeisat1-Oct-06 10:59
Mohammad A Gdeisat1-Oct-06 10:59 
Hi,

I use a CListView as a virtual list in which I display a list of files and file information like size and type.

in the LVN_GETDISPINFO handler I add LVIF_DI_SETITEM to the item mask so that the control will not ask for the data twice for the same item, but it doesnt work at all! the control always asks for data whenever the displayed contents are changed.

I mask the LVIF_DI_SETITEM as follows:

pItem->mask|=LVIF_DI_SETITEM;

and my whole msg handler is as follows if u would like to have a look:

void CFileListView::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;<br />
	// TODO: Add your control notification handler code here<br />
	CProdigyExplorerView *pView=(CProdigyExplorerView*)GetParent();<br />
	LV_ITEM* pItem= &(pDispInfo)->item;<br />
	pItem->mask|=LVIF_DI_SETITEM  ;<br />
	int itemid = pItem->iItem;<br />
	*pResult = 0;<br />
	///file info<br />
	CFileFolderInfo *pFI;<br />
	if(itemid > CFileFolderManager::m_Folders.GetUpperBound())<br />
		pFI = (CFileFolderInfo *)CFileFolderManager::m_Files[itemid-CFileFolderManager::m_Folders.GetUpperBound()-1];<br />
	else<br />
		pFI=(CFileFolderInfo *)CFileFolderManager::m_Folders[itemid];<br />
	//////<br />
	if (pItem->mask & LVIF_TEXT)<br />
    {<br />
		if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Filename"))<br />
		{<br />
			wcsncpy(pItem->pszText,pFI->m_Attributes.cFileName,pItem->cchTextMax);<br />
		}<br />
		else if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Size"))<br />
		{<br />
			CString strSize = CFileFolderManager::FormatFileSize(pFI->m_Attributes.nFileSizeHigh,pFI->m_Attributes.nFileSizeLow,0);<br />
			wcsncpy(pItem->pszText, (LPCTSTR)strSize,pItem->cchTextMax);<br />
		}<br />
		else if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Type"))<br />
		{<br />
<br />
		}<br />
		else if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Created"))<br />
		{<br />
			CString strTime = CFileFolderManager::FormatFileTime(pFI->m_Attributes.ftCreationTime,FALSE);<br />
			wcsncpy(pItem->pszText,(LPCTSTR)strTime,pItem->cchTextMax);<br />
		}<br />
		else if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Modified"))<br />
		{<br />
			CString strTime = CFileFolderManager::FormatFileTime(pFI->m_Attributes.ftLastWriteTime,FALSE);<br />
			wcsncpy(pItem->pszText,(LPCTSTR)strTime,pItem->cchTextMax);<br />
		}<br />
		else if(pView->m_lstFiles.GetHeaderText(pItem->iSubItem)==_T("Accessed"))<br />
		{<br />
			CString strTime = CFileFolderManager::FormatFileTime(pFI->m_Attributes.ftLastAccessTime,FALSE);<br />
			wcsncpy(pItem->pszText,(LPCTSTR)strTime,pItem->cchTextMax);<br />
		}<br />
	}<br />
<br />
	//////////////////////////////////////////<br />
	//////////ICONS////////////////////////<br />
	if( pItem->mask & LVIF_IMAGE) <br />
    {<br />
	<br />
		if(pView->m_iLVStyle != LVS_ICON)<br />
		{<br />
			if(pFI->m_iSmallIconIndex!=-1)<br />
			{<br />
				pItem->iImage=pFI->m_iSmallIconIndex;<br />
				return;<br />
			}<br />
			int iIconIndex;<br />
			CString strExtension=CFileFolderManager::GetFileExtension((CString)pItem->pszText);<br />
			if((iIconIndex=pView->GetTypeIconSmall(strExtension))==-1	//no icon in the list<br />
				|| strExtension==_T("exe") ||strExtension==_T("lnk")|| pFI->m_Attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br />
			{<br />
				SHFILEINFO fi;<br />
				SHGetFileInfo(pView->m_strCurrentPath + pItem->pszText,pFI->m_Attributes.dwFileAttributes,&fi,sizeof(fi),SHGFI_USEFILEATTRIBUTES |SHGFI_ICON| /*SHGFI_TYPENAME|*/SHGFI_SMALLICON);<br />
				<br />
				pItem->iImage=pView->m_ilLVIconsSmall.Add(fi.hIcon);<br />
				<br />
				pView->m_hIcons.Add(fi.hIcon);<br />
				pFI->m_iSmallIconIndex = pItem->iImage;<br />
				if(!(pFI->m_Attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))//store extension if not a folder<br />
				{<br />
					IconType IT;<br />
					IT.m_Extension=strExtension;<br />
					IT.m_IconIndex=pItem->iImage;<br />
					pView->m_IconTypeSmall.Add(IT);<br />
				}<br />
				<br />
			}<br />
<br />
			else	//This file type already has an icon index in m_IconType<br />
			{<br />
				pItem->iImage=iIconIndex;<br />
				pFI->m_iSmallIconIndex = iIconIndex;<br />
			<br />
			}<br />
			CString str;<br />
			str.Format(_T("%d"),pView->m_ilLVIconsSmall.GetImageCount());<br />
			GetParent()->GetParent()->SetWindowText(str);<br />
		<br />
		}//end of small icon handler<br />
		if(pView->m_iLVStyle == LVS_ICON)<br />
		{<br />
			if(pFI->m_iLargeIconIndex!=-1)<br />
			{<br />
				pItem->iImage=pFI->m_iLargeIconIndex;<br />
				return;<br />
			}<br />
			<br />
			int iIconIndex;<br />
			CString strExtension=CFileFolderManager::GetFileExtension((CString)pItem->pszText);<br />
			if((iIconIndex=pView->GetTypeIconLarge(strExtension))==-1	//no icon in the list<br />
				|| strExtension==_T("exe") ||strExtension==_T("lnk")|| pFI->m_Attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br />
			{<br />
				IconType IT;<br />
				IT.m_Extension=strExtension;<br />
				SHFILEINFO fi;<br />
				<br />
				SHGetFileInfo(pView->m_strCurrentPath + pItem->pszText,pFI->m_Attributes.dwFileAttributes,&fi,sizeof(fi),SHGFI_USEFILEATTRIBUTES |SHGFI_ICON| /*SHGFI_TYPENAME|*/SHGFI_LARGEICON);<br />
				<br />
				IT.m_IconIndex=pItem->iImage=pView->m_ilLVIconsLarge.Add(fi.hIcon);<br />
				pView->m_IconTypeLarge.Add(IT);<br />
				pView->m_hIcons.Add(fi.hIcon);<br />
				pFI->m_iLargeIconIndex= IT.m_IconIndex;<br />
				<br />
			}<br />
<br />
			else	//This file type already has an icon index in m_IconType<br />
			{<br />
				pItem->iImage=iIconIndex;<br />
				pFI->m_iLargeIconIndex= iIconIndex;<br />
			<br />
			}<br />
			CString str;<br />
			str.Format(_T("%d"),pView->m_ilLVIconsLarge.GetImageCount());<br />
			GetParent()->GetParent()->SetWindowText(str);<br />
		<br />
		}//end of small icon handler<br />
		<br />
	}


And ever has it been that love knows not its own depth until the hour of separation

QuestionCreating a file association with VC++ Pin
Mohammad A Gdeisat1-Oct-06 10:51
Mohammad A Gdeisat1-Oct-06 10:51 
AnswerRe: Creating a file association with VC++ Pin
Christian Graus1-Oct-06 15:19
protectorChristian Graus1-Oct-06 15:19 
GeneralRe: Creating a file association with VC++ Pin
Mohammad A Gdeisat2-Oct-06 7:44
Mohammad A Gdeisat2-Oct-06 7:44 
GeneralRe: Creating a file association with VC++ Pin
Mark Salsbery4-Oct-06 15:07
Mark Salsbery4-Oct-06 15:07 
AnswerRe: Creating a file association with VC++ Pin
Link20061-Oct-06 16:51
Link20061-Oct-06 16:51 
AnswerRe: Creating a file association with VC++ Pin
Hamid_RT2-Oct-06 9:40
Hamid_RT2-Oct-06 9:40 
Questionstring convertions Pin
Waldermort1-Oct-06 8:02
Waldermort1-Oct-06 8:02 
AnswerRe: string convertions Pin
Waldermort1-Oct-06 8:45
Waldermort1-Oct-06 8:45 
QuestionWin32 Window Boundry Pin
beeejay1-Oct-06 6:44
beeejay1-Oct-06 6:44 
AnswerRe: Win32 Window Boundry Pin
Waldermort1-Oct-06 8:06
Waldermort1-Oct-06 8:06 
GeneralRe: Win32 Window Boundry Pin
beeejay1-Oct-06 8:11
beeejay1-Oct-06 8:11 
GeneralRe: Win32 Window Boundry Pin
Waldermort1-Oct-06 8:21
Waldermort1-Oct-06 8:21 
GeneralRe: Win32 Window Boundry Pin
beeejay1-Oct-06 9:38
beeejay1-Oct-06 9:38 
GeneralRe: Win32 Window Boundry Pin
beeejay1-Oct-06 11:34
beeejay1-Oct-06 11:34 
AnswerRe: New To C++ Need Help With Button Code On Form Apps Pin
toxcct1-Oct-06 7:03
toxcct1-Oct-06 7:03 
GeneralRe: New To C++ Need Help With Button Code On Form Apps Pin
Hamid_RT1-Oct-06 7:26
Hamid_RT1-Oct-06 7:26 
Questionunresolved external symbol Pin
marwa_fci1-Oct-06 5:14
marwa_fci1-Oct-06 5:14 

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.