Thread: ListView ImageList problem (MFC)

  1. #1
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788

    ListView ImageList problem (MFC)

    I have a problem with initializing an image list for a listview. I'm using MFC with doc/view. The problem is that when I try and retrieve the image list, with the SHGFI_SMALLICON flag enabled, I get a debugging error.

    If i just use SHGFI_ICON, then it works fine, but then i don't get the small icons.

    Here's my code:
    Code:
    SHFILEINFO ssfi;    
    	
    m_ilSmall.Attach((HIMAGELIST)SHGetFileInfo( 
    	"c:\\",
    	0, 
    	&ssfi, 
    	sizeof(SHFILEINFO), 
    	SHGFI_SYSICONINDEX | SHGFI_ICON));
    
    DestroyIcon(ssfi.hIcon);
    If I used SHGFI_SMALLICON instead, then i get an error message.

    I attached a zip file of two pics of the error message and the working prog, but with large icons.

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Well, thanks for all the replies , but i found the problem.

    The treeview's imagelist was being initialized first, which i attached to the system's imagelist, so when i tried to attach the listview imagelist to the same thing, I got a debugging error.

    I solved the problem by making the listview's imagelist point to the treeviews imagelist.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. MFC Dialog Problem
    By prongs_386 in forum Windows Programming
    Replies: 1
    Last Post: 05-10-2007, 12:25 AM
  3. Problem with MFC Wizard
    By okinrus in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2004, 04:09 PM
  4. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  5. MFC ListView and EditBox Data
    By mangoz in forum Windows Programming
    Replies: 0
    Last Post: 04-21-2002, 10:51 PM