problem with listview and images

This is a discussion on problem with listview and images within the Windows Programming forums, part of the Platform Specific Boards category; Hi, i am trying to use a image in a listview item but the image seems to not show up, ...

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    problem with listview and images

    Hi,
    i am trying to use a image in a listview item but the image seems to not show up,
    im using msvc++6 and in the resource view it shows the correct icon, so that seems to be loading, here is how i am doing it

    Code:
    
    	memset(&lvCol,0,sizeof(lvCol));
    
    	lvCol.mask =			LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
    	lvCol.cx =				0x90;
    	lvCol.pszText =			"UserName";
    
    
    
    	hwndNameList = CreateWindowEx(WS_EX_STATICEDGE | WS_EX_CLIENTEDGE, WC_LISTVIEW , "" ,
    					WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ICON ,
    					660 , 5 ,
    					120 , 480 ,
    					hwnd,
    					(HMENU) ID_LISTVIEW,
    					(HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE),
    					NULL);
    
    
    
    	hSmallIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), 
        	GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1); 
    	hUserIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICONUSER));
    
    	ImageList_AddIcon(hSmallIcons, hUserIcon);
    	ListView_SetImageList(hwndNameList, hSmallIcons, LVSIL_SMALL); 
    
    	lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE; 
    	lvItem.iItem=0;                     
    	lvItem.pszText="test";               
    	lvItem.cchTextMax=512;   
    	lvItem.iImage=0;                    
        	SendMessage(hwndNameList,LVM_INSERTITEM,0,(LPARAM)&lvItem);
    if any one can see from this as to why its not working i would much appreciate it, thanks
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try...

    removing either the LVS_ICON or LVS_REPORT styles as I believe they are mutually exclusive. Report is multiple columns with a small icon list in the left column.

    If using report ensure you first add the columns with ListView_InsertColumn() or SendMessage()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    thanks for the reply nova, i should have stated that it has 1 column and the look i want it to have is a small icon next to the user name like...

    @username1
    @username2

    @ representing the icon, thanks
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Try sending the list view a LVM_SETIMAGELIST message.

  5. #5
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    still no luck
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    >>i want it to have is a small icon next to the user name like...

    try

    LVS_SMALLICON | WS_CHILD | WS_VISIBLE | LVS_SHOWSELALWAYS
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    still no luck, it has the indent but there is no icon?
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ListView Version 6.0 and ImageLists
    By blundstrom in forum Windows Programming
    Replies: 0
    Last Post: 07-26-2002, 09:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21