The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: fearless on March 05, 2009, 12:30:03 PM

Title: Listview missing icon on selecting row
Post by: fearless on March 05, 2009, 12:30:03 PM
Hi,

Ive recently come across a small problem with a listview control. I create a report style and add a number of items and subitems and icons from an imagelist. All rows display fine, but when i select a row, the icon associated with the row is blanked out/disappears, when i move off from that and select another row the previous icon row is displayed fine and the new row icon that is currently selected disappears.

This problem seems to only occur when adding a manifest for new xp style. Ive searched here and other asm forums in case i have missed something with regard to listviews, manifest adding or posts indicating similar problems for other users. So far im stumped, so just wondering if anyone has come across the problem?

I have a few other projects that re-use my own listview lib of procs, and i have re-used the same icons as resources, to see if there is a prob with the actual .ico files i was previously using. But i cant see any differences except the manifest thing which does work in all my other projects - weird.

I think i will go back to create a simple project with just my listview library code, and a simple listview to test this bad boy out, but if anyone has come across this issue or can suggest what might be the cause, then that would be great.

Cheers.
Title: Re: Listview missing icon on selecting row
Post by: fearless on March 05, 2009, 03:03:19 PM
Ive attached a simple listview project that shows the problem. Only seems to occur when ive added in the xp style manifest

(http://i265.photobucket.com/albums/ii214/nwofearless/lvtest3.jpg)
(http://i265.photobucket.com/albums/ii214/nwofearless/lvtest1.jpg)
(http://i265.photobucket.com/albums/ii214/nwofearless/lvtest2.jpg)

[attachment deleted by admin]
Title: Re: Listview missing icon on selecting row
Post by: akane on March 05, 2009, 04:02:48 PM
Hi, you need to add LVIF_IMAGE flag to .mask before adding items, and ofcourse set .iImage to the image index.
Title: Re: Listview missing icon on selecting row
Post by: sinsi on March 05, 2009, 04:11:59 PM
No problems here - windows7 beta.
(http://i51.photobucket.com/albums/f395/sinsithedog/lvtest.jpg)
Title: Re: Listview missing icon on selecting row
Post by: fearless on March 05, 2009, 07:32:25 PM
I still seem to have the same problem. I went back to insert code in the WM_INITDIALOG section:

; Mask
mov LVItem.imask, LVIF_TEXT or LVIF_STATE or LVIF_IMAGE or LVIF_PARAM

; Item
push 1
pop LVItem.iItem

; Subitem
mov LVItem.iSubItem,0

; Statemask
mov LVItem.stateMask, LVIS_FOCUSED

; pszText
Invoke szCopy, CTEXT("Test Item1"), Addr LVItemText
mov eax, Offset LVItemText
mov LVItem.pszText, eax

; cchTextMax
mov LVItem.cchTextMax, MAX_PATH

; image
mov eax, 0
mov LVItem.iImage, eax

; lParam
push 1
pop LVItem.lParam

; Do it
invoke SendMessage, hListview, LVM_INSERTITEM, 0, Addr LVItem



; Mask
mov LVItem.imask, LVIF_TEXT or LVIF_STATE or LVIF_IMAGE or LVIF_PARAM

; Item
push 2
pop LVItem.iItem

; Subitem
mov LVItem.iSubItem,0

; Statemask
mov LVItem.stateMask, LVIS_FOCUSED

; pszText
Invoke szCopy, CTEXT("Test Item2"), Addr LVItemText
mov eax, Offset LVItemText
mov LVItem.pszText, eax

; cchTextMax
mov LVItem.cchTextMax, MAX_PATH

; image
mov eax, 1
mov LVItem.iImage, eax

; lParam
push 2
pop LVItem.lParam

; Do it
invoke SendMessage, hListview, LVM_INSERTITEM, 0, Addr LVItem


I get both icons loaded, but row selection still causes the row icon to disappear
Title: Re: Listview missing icon on selecting row
Post by: jj2007 on March 05, 2009, 11:50:42 PM
Same problem here.. Have you noticed that the icon reappears before the About box displays?
Title: Re: Listview missing icon on selecting row
Post by: fearless on March 06, 2009, 12:04:14 AM
Yes i noticed that as well, seems to be a strange problem. If i ditch the xp manifest, all is well again. I just cant figure out what is different with my other projects that work with the listview and xp manifest. Ive tried importing code from my other projects, using the same icons, resources, same properties in dlgs, and resource files, and played around with the code. Actually i just recompiled another project and the same issue is now showing up there as well - and it worked before. Only thing that might have changed since last look/use/compile of older projects (well before nov last year) is xp sp3 and/or the recent .net 3.5 update along with all other recent updates, maybe an update to the components has caused this, i might try and bring the project into work to try on a machine that is less likely to have all ms updates installed to see if it is just my machine or others as well to rule out that possiblity.
Title: Re: Listview missing icon on selecting row
Post by: PBrennick on March 06, 2009, 12:07:35 AM
fearless,
I rebuilt your code on my machine which does not have .NET installed and I have the same problem. I DO have SP3 installed so your problem is probably there.

Paul
Title: Re: Listview missing icon on selecting row
Post by: jj2007 on March 06, 2009, 12:27:05 AM
Quote from: fearless on March 06, 2009, 12:04:14 AM
If i ditch the xp manifest, all is well again. I just cant figure out what is different...

Assemble the two versions, and ask Olly what is different.

Quote
xp sp3
I have the problem with SP2.
Title: Re: Listview missing icon on selecting row
Post by: fearless on March 06, 2009, 12:35:38 AM
Ive been searching MS site and seen a few posts relating to EnableVisualStyles and images dissappearing and/or not showing up when using listviews. Im going to uninstall .net 3.5 sp1 and go back and see if that is the culprit. Most of the posts are related to .net but i have a feeling it is related.
Title: Re: Listview missing icon on selecting row
Post by: jj2007 on March 06, 2009, 12:57:46 AM
If you uninstall .net, and it works afterwards, you will never find out who the culprit was. Compare the two versions with a disassembler or OllyDbg, and you will find out which of the invokes is different...