Click here to Skip to main content
15,905,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: LoadLibraryW("C:\abc.dll") fails Pin
Code-o-mat14-Mar-12 0:42
Code-o-mat14-Mar-12 0:42 
AnswerRe: LoadLibraryW("C:\abc.dll") fails Pin
Jochen Arndt14-Mar-12 0:56
professionalJochen Arndt14-Mar-12 0:56 
AnswerRe: LoadLibraryW("C:\abc.dll") fails Pin
Richard MacCutchan14-Mar-12 1:18
mveRichard MacCutchan14-Mar-12 1:18 
AnswerRe: LoadLibraryW("C:\abc.dll") fails Pin
CPallini14-Mar-12 23:06
mveCPallini14-Mar-12 23:06 
QuestionCMFCMaskedEdit class Pin
David Crow13-Mar-12 10:00
David Crow13-Mar-12 10:00 
AnswerRe: CMFCMaskedEdit class Pin
«_Superman_»13-Mar-12 17:08
professional«_Superman_»13-Mar-12 17:08 
AnswerRe: CMFCMaskedEdit class Pin
Randor 13-Mar-12 17:43
professional Randor 13-Mar-12 17:43 
Questionc++ win32 Listview, File List, show folder and app icon using SHGetFileInfo Pin
jkirkerx13-Mar-12 7:59
professionaljkirkerx13-Mar-12 7:59 
I made a Windows Listview control that show the contents of a folder, so the user can select the file to open.

My Listview has 4 columns, the first is filename, which can be a folder or app. In front of the name, for cosmetics, I want to show the icon. So if it's a folder, the folder icon, and the name of the folder appears.

Question:

Am I even on the right track here, using SHGetFileInfo to get the folder icon from Shell32.dll, and how to load the result in an ImageList, so I can program the 1st column with the icon in the image list. I could actually use a little help here on writing the code.

////////////////////////////////////////////////////////////////////////////////////////
// Generate the Folder Icons and Image List

hr = SHGetFileInfo( L"Shell32.dll", 0, &siFolderIcon_Small, sizeof( siFolderIcon_Small ), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
hr = SHGetFileInfo( L"Shell32.dll", 0, &siFolderIcon_Large, sizeof( siFolderIcon_Large ), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES);
	
HIMAGELIST hil_Folders;
HBITMAP    hbm_Folders;

hil_Folders = ImageList_Create( 16, 16, ILC_COLOR, 2, 0 );
hbm_Folders = ( HBITMAP )LoadImage( ( HINSTANCE )lParam, siFolderIcon_Small.szDisplayName , IMAGE_BITMAP, 0, 0, 0 );


ImageList_Add( hil_Folders, hbm_Folders, NULL );



// End of Generate the Folder Icons and Image List
////////////////////////////////////////////////////////////////////////////////////////

I'm not sure here, if the first code block should load the icon and text in one shot, or as the example shows, load the text, and then go back and load the icon in separate calls. Maybe load the icon in the first call, and then load the text in the second.

// Process the result in this loop cycle
memset( &lv_ProjectOpen_Item_Record, dwIndex, sizeof( lv_ProjectOpen_Item_Record ) ); 

// Column 1 - Filename			
lv_ProjectOpen_Item_Record.iItem = dwIndex;
lv_ProjectOpen_Item_Record.iSubItem = 0;				
lv_ProjectOpen_Item_Record.mask = LVIF_TEXT;
lv_ProjectOpen_Item_Record.cchTextMax = 254;
lv_ProjectOpen_Item_Record.pszText = szFileName;
ListView_InsertItem( lv_ProjectOpen_FileSelect, &lv_ProjectOpen_Item_Record );

// Column 1 - Insert Image
lv_ProjectOpen_Item_Record.mask = LVIF_IMAGE;
lv_ProjectOpen_Item_Record.iImage = 0;
ListView_SetItem( lv_ProjectOpen_FileSelect, &lv_ProjectOpen_Item_Record);			
				
// Column 2 - Date Modified
lv_ProjectOpen_Item_Record.iItem = dwIndex;
lv_ProjectOpen_Item_Record.iSubItem = 1;
lv_ProjectOpen_Item_Record.mask = LVIF_TEXT;
lv_ProjectOpen_Item_Record.cchTextMax = 24;
lv_ProjectOpen_Item_Record.pszText = szDateModified;
ListView_SetItem( lv_ProjectOpen_FileSelect, (const LV_ITEM *)&lv_ProjectOpen_Item_Record);

QuestionRe: c++ win32 Listview, File List, show folder and app icon using SHGetFileInfo Pin
enhzflep13-Mar-12 13:35
enhzflep13-Mar-12 13:35 
AnswerRe: c++ win32 Listview, File List, show folder and app icon using SHGetFileInfo Pin
jkirkerx13-Mar-12 16:14
professionaljkirkerx13-Mar-12 16:14 
GeneralRe: c++ win32 Listview, File List, show folder and app icon using SHGetFileInfo Pin
enhzflep13-Mar-12 16:58
enhzflep13-Mar-12 16:58 
JokeRe: c++ win32 Listview, File List, show folder and app icon using SHGetFileInfo Pin
jkirkerx13-Mar-12 17:45
professionaljkirkerx13-Mar-12 17:45 
AnswerWell that took a couple of hours to figure out Pin
jkirkerx14-Mar-12 12:07
professionaljkirkerx14-Mar-12 12:07 
Questionhow to read flash drive type reader? Pin
Le@rner12-Mar-12 23:46
Le@rner12-Mar-12 23:46 
AnswerRe: how to read flash drive type reader? Pin
Richard MacCutchan13-Mar-12 0:47
mveRichard MacCutchan13-Mar-12 0:47 
QuestionRe: how to read flash drive type reader? Pin
David Crow13-Mar-12 3:48
David Crow13-Mar-12 3:48 
Questiondocumentation c++ gui Pin
yahya7712-Mar-12 7:46
yahya7712-Mar-12 7:46 
AnswerRe: documentation c++ gui Pin
Maximilien12-Mar-12 7:59
Maximilien12-Mar-12 7:59 
GeneralRe: documentation c++ gui Pin
yahya7712-Mar-12 8:25
yahya7712-Mar-12 8:25 
AnswerRe: documentation c++ gui Pin
Richard MacCutchan12-Mar-12 8:00
mveRichard MacCutchan12-Mar-12 8:00 
AnswerRe: documentation c++ gui Pin
CPallini12-Mar-12 22:58
mveCPallini12-Mar-12 22:58 
Questiontoolbar not being loaded for dialog dll---extension dll Pin
appollosputnik12-Mar-12 4:09
appollosputnik12-Mar-12 4:09 
QuestionRe: toolbar not being loaded for dialog dll---extension dll Pin
Richard MacCutchan12-Mar-12 8:03
mveRichard MacCutchan12-Mar-12 8:03 
AnswerRe: toolbar not being loaded for dialog dll---extension dll Pin
appollosputnik12-Mar-12 21:24
appollosputnik12-Mar-12 21:24 
GeneralRe: toolbar not being loaded for dialog dll---extension dll Pin
Richard MacCutchan12-Mar-12 23:25
mveRichard MacCutchan12-Mar-12 23:25 

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.