Add your own alternative version
Stats
97.5K views 1K downloads 29 bookmarked
Posted
21 Jun 2001
Licenced
|
Comments and Discussions
|
|
solved one of my headache.
|
|
|
|
|
how do i get the desired in vc .net
|
|
|
|
|
Title: "SHGetFileInfo" with "SHGFI_SYSICONINDEX" flag doesn't work if called many times ?#%@!
I need to access & store the system image list for many times in my application. So i have called a "SHGetFileInfo" function and attached that handle to a CImageList object. I got the expected results till fourth time I called "SHGetFileInfo" function. But after that, "SHGetFileInfo" returned a system image list handle which had no icons in it !!!
*** What could be the reason?
*** Is there any alternative?
mike
|
|
|
|
|
I found that when I "Attach" m_ImgList, I get ASSERT error.
Therefore, I change the original one:
////////////////////////////////////////////////////////////////////////////
// get a handl e to the system small icon list
HIMAGELIST hSystemSmallImageList;
SHFILEINFO ssfi;
hSystemSmallImageList = ( HIMAGELIST )SHGetFileInfo( ( LPCTSTR )_T( "c:\\" ),
0,
&ssfi,
sizeof( SHFILEINFO ),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
m_ImgList.Attach( hSystemSmallImageList );
m_List.SetImageList( &m_ImgList, LVSIL_SMALL );
////////////////////////////////////////////////////////////////////////////
to this:
////////////////////////////////////////////////////////////////////////////
// get a handle to the system small icon list
HIMAGELIST hSystemSmallImageList;
SHFILEINFO ssfi;
hSystemSmallImageList = ( HIMAGELIST )SHGetFileInfo( ( LPCTSTR )_T( "c:\\" ), 0,
&ssfi,
sizeof( SHFILEINFO ),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
m_list.SetImageList( ( CImageList * )CImageList::FromHandle( SystemSmallImageList ), LVSIL_SMALL );
////////////////////////////////////////////////////////////////////////////
Good luck.
|
|
|
|
|
One of the few examples I've seen for figuring file size in KB, MB, and GB. Thanks for the code snipet.
MT
http://www.teddev.com
|
|
|
|
|
Hello Blaze.
This routine work good in W2000, but in W98, when your demo project finishes, the icons of the desktop, the explorer and all the views disappear.
¿Do you know where is the problem?
Thanks in advance.
Tomás.
|
|
|
|
|
(1) Don't forget to call Detach() after ImageList is done.
m_ImgList.Attach(hSystemSmallImageList);<br />
m_List.SetImageList(&m_ImgList,LVSIL_SMALL);<br />
m_ImgList.Detach ();
(2) Add "LVS_SHAREIMAGELISTS" style to list control
|
|
|
|
|
Hi Ridgeley.
This code works well in W2000 but not in W98.
BOOL CMyPropertyPage::PrepareListControl()
{
static TCHAR *szColumnLabel[] = { _T("Name"), _T("Modified"), _T("Create"), _T("Size"), _T("Type"), _T("Folder") };
static UINT iColumnFmt[] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_RIGHT, LVCFMT_LEFT, LVCFMT_LEFT };
static UINT iColumnWidth[] = { 140, 110, 110, 80, 100,240 };
for(int i = 0; i < 6; i++) {
if (m_lcList.InsertColumn(i,szColumnLabel[i],iColumnFmt[i],iColumnWidth[i]) != i) {
ASSERT(FALSE);
return FALSE;
}
}
DWORD dwExStyle = LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_SHAREIMAGELISTS;
m_lcList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));
HIMAGELIST hSystemSmallImageList;
SHFILEINFO ssfi;
hSystemSmallImageList =
(HIMAGELIST)SHGetFileInfo(
(LPCTSTR)_T("c:\\"),
0,
&ssfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
m_ImgList.Attach(hSystemSmallImageList);
m_lcList.SetImageList(&m_ImgList,LVSIL_SMALL);
m_ImgList.Detach();
return TRUE;
}
Do you know where the problem is?.
Thanks in advance.
Tomás
|
|
|
|
|
Tomas wrote:
DWORD dwExStyle = LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_SHAREIMAGELISTS;
m_lcList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));
"LVS_SHAREIMAGELISTS" is NOT the extended style of list control.
So you should put it independently and use ModifyStyle ().
DWORD dwExStyle = LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP;<br />
m_lcList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));<br />
m_lcList.ModifyStyle (0, LVS_SHAREIMAGELISTS, 0);
Hope that helps 
|
|
|
|
|
Thank you, now works perfect.
Tomás
|
|
|
|
|
Hi,
Is it possbile to select multiple files with different extensions, I do not want all the files to be selected, but only files with certain extension.
For e.g. I would like to search recursively in a parent directory for "*.txt, *.bmp, *.doc, *.xls" files in one shot.
Thanks in advance for your time.
Cheers
Alpesh Makwana 
|
|
|
|
|
I had to replace the GetLength64 with GetLength, and it worked fine.
Good work.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Good!
But do you know how to create a dialog like explorer properties. Is there any common or ATL based dialog?
|
|
|
|
|
|
|
|
what are you talking about ??
BLaZe
ICQ # 71682311
email : mpblaze@iquebec.com
|
|
|
|
|
If you want to make a project which Update every time you click on a button POP you Dlg Properties Box -> Style -> Check the "Clip Children"
BLaZe
ICQ # 71682311
email : mpblaze@iquebec.com
|
|
|
|
|
|
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|