ListView Icon Selection
-
Hello, I have a ListView that is set in Details mode for the view. It has no headers though that's likely irrevalent. I have a SmallImageList set and I set an icon for a ListViewItem. When an Item is selected, it also highlights the icon on the left. How would I stop it from highlighting it? I know that I could catch the WM_PAINT but then would I have to repaint the whole control? Is there something that I'm missing? Thanks, Jonathan
-
Hello, I have a ListView that is set in Details mode for the view. It has no headers though that's likely irrevalent. I have a SmallImageList set and I set an icon for a ListViewItem. When an Item is selected, it also highlights the icon on the left. How would I stop it from highlighting it? I know that I could catch the WM_PAINT but then would I have to repaint the whole control? Is there something that I'm missing? Thanks, Jonathan
Ok. This was a bad question. The standard ListView does not highlight the icon. I am trying to modify the TreeListView that was posted on CodeProject and it does highlight the icon using a ListView. I will have to investigate more.
-
Ok. This was a bad question. The standard ListView does not highlight the icon. I am trying to modify the TreeListView that was posted on CodeProject and it does highlight the icon using a ListView. I will have to investigate more.
It appears that I butchered my question. I still have the original question. When I went back and look at my other example, the icon I was looking at just didn't show the highlight as bad. Therefore, does anyone know the answer to my question? Thanks, Jonathan
-
It appears that I butchered my question. I still have the original question. When I went back and look at my other example, the icon I was looking at just didn't show the highlight as bad. Therefore, does anyone know the answer to my question? Thanks, Jonathan
Highliting the icon is handled automatically by listviews, and there is no style bit or anything to override that behaviour. I also wish only the text were highlited, but to do so would mean custom drawing, as you mentioned. I have done it, but that code is somewhere in the archives of a company I once worked for. If you still desire to do so, the drawing of the foreground and background colors is fairly easy, but handling the drawing of the focus rectangle is a bit of a pain (at least when multi-select is enabled). Be careful when drawing selection ranges, as you need to remember which item is the "pivotal" selection (I forget the official term, it's been a while). Othewise, you won't be able to extend or reverse selection changes properly, when the user keeps CTRL or SHIFT down.
-
Highliting the icon is handled automatically by listviews, and there is no style bit or anything to override that behaviour. I also wish only the text were highlited, but to do so would mean custom drawing, as you mentioned. I have done it, but that code is somewhere in the archives of a company I once worked for. If you still desire to do so, the drawing of the foreground and background colors is fairly easy, but handling the drawing of the focus rectangle is a bit of a pain (at least when multi-select is enabled). Be careful when drawing selection ranges, as you need to remember which item is the "pivotal" selection (I forget the official term, it's been a while). Othewise, you won't be able to extend or reverse selection changes properly, when the user keeps CTRL or SHIFT down.
Thank you for your response. I have been looking at some of Carols Perez's great work here on CodeProject where he does a lot of customdraw listviews and treeviews. It gets pretty complicated as you have to receive all of the correct messages and such. It looks like I'm going to just let it go for now and I may change it a little later. Custom control Drawing does not appear to be one of my strong points. :) Jonathan