|
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 />
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 />
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 />
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 />
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
|| 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_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))
{<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
{<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 />
}
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
|| 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_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
{<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 />
}
<br />
}
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
hi,
I want to create a file association programmatically using vc++, for example, I want to associate '.txt' files with myprogram.exe.
are there any api functions to do this?
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Not sure if there are any directly, but the file associations are stored in the registry, you can use registry APIs to set them up.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks,
but when I change these settings from registry will the settings take effect immediately or do I need to restart windows or restart windows explorer??
I need a method that takes effects immediately.
Thanks alot
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
|
haha, very easy.
1.) Right-click on the .txt file,
2.) Choose "Properties",
3.) Choose "Browse",
4.) Then choose your program name, ie. myprogram.exe
Enjoy
|
|
|
|
|
|
36 hours straight and my mind is starting to go blank. What is a quick and easy way to convert a string to a DWORD? The string is an 8 char representation of a hash value, I will use it as a key in the registry.
|
|
|
|
|
wow, I didn't even realise this set of functions existed, and here's me thinking of bit shifting!!
dwKey = strtoul(key,0,16);
|
|
|
|
|
Hello
I am trying to keep a window within a certain bounding rect. So far I am capturing the WM_ENTERSIZEMOVE message within the window procedure and doing this:
boundry is the program defined rect that the user should stay within.
pt is the mouse POINT.
rect is the window RECt.
<br />
test.left = boundry.left + ( pt.x - rect.left );<br />
test.right = boundry.right - ( rect.right - pt.x );<br />
<br />
test.top = boundry.top + ( pt.y - rect.top );<br />
test.bottom = boundry.bottom - ( rect.bottom - pt.y );<br />
<br />
ClipCursor( &test );
There are a few problems that arise, one of them is that depending on where i grab the window, the resulting boundry rect is sometimes off by as much as a few pixels.
Whats the dilly?
|
|
|
|
|
Didn't you ask this question the other day? And didn't I recomend using the WM_GETMINMAXINFO rather than trying to do it manually. And did it work?
|
|
|
|
|
Yah I did, And no I couldn't get it to work properly. It was only working for the resizing of the window, not the moving. This is what i wrote:
<br />
<br />
case WM_GETMINMAXINFO:<br />
<br />
<br />
wndInfo = (MINMAXINFO *)lParam;<br />
<br />
wndInfo->ptMaxPosition.x = boundry.left;<br />
wndInfo->ptMaxPosition.y = boundry.top;<br />
<br />
wndInfo->ptMaxSize.x = boundry.right - boundry.left;<br />
wndInfo->ptMaxSize.y = boundry.bottom - boundry.top;<br />
<br />
wndInfo->ptMaxTrackSize.x = boundry.right;<br />
wndInfo->ptMaxTrackSize.y = boundry.bottom;<br />
<br />
wndInfo->ptMinTrackSize.x = boundry.left;<br />
wndInfo->ptMinTrackSize.y = boundry.top;<br />
<br />
ret = 0;<br />
break;
Was I missing somthing?
|
|
|
|
|
Maybe this[^] will help you.
|
|
|
|
|
Thanks for the article, It seems that only the resizing is being handled though, not the moving.
|
|
|
|
|
Well I ended up going about it this way, now i just need to figure out how to stop the cursor from moving in the case that it goes within the if statements, any ideas?
case WM_SIZING:<br />
case WM_MOVING:<br />
winRect = (RECT *) lParam;<br />
<br />
winWidth = winRect->right - winRect->left;<br />
winHeight = winRect->bottom - winRect->top;<br />
<br />
if ( winRect->left < boundry.left )<br />
{<br />
winRect->left = boundry.left;<br />
if ( Msg == WM_MOVING ) winRect->right = winRect->left + winWidth;<br />
}<br />
<br />
if ( winRect->top < boundry.top )<br />
{<br />
winRect->top = boundry.top;<br />
if ( Msg == WM_MOVING ) winRect->bottom = winRect->top + winHeight;<br />
}<br />
<br />
if ( winRect->bottom > boundry.bottom )<br />
{<br />
winRect->bottom = boundry.bottom;<br />
if ( Msg == WM_MOVING ) winRect->top = winRect->bottom - winHeight;<br />
}<br />
<br />
if ( winRect->right > boundry.right )<br />
{<br />
winRect->right = boundry.right;<br />
if ( Msg == WM_MOVING ) winRect->left = winRect->right - winWidth;<br />
}<br />
<br />
counter++;<br />
sprintf( buffer2, "In WM_SIZING/WM_MOVING this many times: %d", counter );<br />
charCount = SetWindowText( hWnd, buffer2 );<br />
<br />
return true;
Thanks,
Ben.
|
|
|
|
|
you're asking for Managed C++.
ask this in the C++/CLI forum[^] instead.
|
|
|
|
|
Hi toxcct,
Wheres question?
|
|
|
|
|
When i try to make an object from the CGridCtrl class as follows: CGridCtrl grid;
I get this error:
"unresolved external symbol "public: __thiscall CGridCtrl::CGridCtrl(int,int,int,int)" (??0CGridCtrl@@QAE@HHHH@Z) referenced in function "public: void __thiscall CSpreadSheetView::CreateGrid(void)" (?CreateGrid@CSpreadSheetView@@QAEXXZ)"
How could this be solved?
|
|
|
|
|
did you correctly added all the files into Visual C++ ?
|
|
|
|
|
And also make sure that CGridCtrl::CGridCtrl(int,int,int,int) has been "declared".
|
|
|
|
|
it is... the CGridCtrl is a class made by Chris Maunder available somewhere here on Codeproject.
|
|
|
|
|
Is there any way of creating a console program that runs without the user noticing? SOmething like a invisible console? I've seen an article that taught to do this, somewhere in CP, but I can't find it anymore..
|
|
|
|
|
Would ShellExecut() do it?
|
|
|
|
|
The simplest way to do that I've found is to create a normal Windows application (one with a WinMain function), and then don't create a window.
Software Zen: delete this;
|
|
|
|
|