16

In Windows 7's Windows Explorer list view (what allegedly is not list view at all) in the Details view, you can start selection marquee in the first (Name) column. You just need to start outside the actual name.

Windows 7's Windows Explorer Selection Marquee

The same is true for default-style list view control in Details view.

But if you set the list view control to the Explorer style (using the SetWindowTheme), what should mimic the Windows Explorer, this does not work anymore. You can start selection in the second and later columns only.

SetWindowTheme(listView1.Handle, "explorer", null);

Is there any way to make list view mimic the Explorer selection style?

I suppose there's no settings to enable such behavior and this would have to be coded. Like handling the mouse down and triggering selection. But I have no idea how to do that.

Thanks.

Ntb, I'm using C++Builder, but this should be purely Win32 issue. I've tested this with WinForms too (hence the C# sample above).

0

2 Answers 2

11
+100

Actually there is a way to mimic Explorer selection behavior. It requires a lot of additional declarative work, but it is possible.

You need to get undocumented IListView interface via undocumented LVM_QUERYINTERFACE message (note that interface declaration and GUIDs are different for Windows Vista and Windows 7+). Details about constants and declarations can be found here:

After acquiring the interface all you need is simply a call to SetSelectionFlags(1, 1) method. Voila you are done.

5
  • Thanks! Where did you found the values for SetSelectionFlags? Commented Sep 8, 2015 at 6:33
  • I've successfully tested this on Windows 7, 8.1 and 10. Does not work on Vista (yes, I've used the Vista-specific GUID/interface); I can retrieve the Vista-specific interface, but the SetSelectionFlags does not have any effect. I've experienced no side-effect of sending LVM_QUERYINTERFACE message to the list view on Windows XP. Commented Sep 8, 2015 at 7:04
  • Good luck with this on future versions of Windows Commented Sep 8, 2015 at 8:03
  • @David, of course any undocumented feature can be dropped at any time, but in this particular case it will not break working code. Still ListView is most complicated and puzzled comctrl control, and it seems that MS afraid to touch it when it works (there are bugs that exists for decades now and nobody even tried to fix them), so this solutions will for many years for sure.
    – arbiter
    Commented Sep 8, 2015 at 22:14
  • @Martin, I didn't remember exactly how I found it. Probably I was found it on some forum (less likely) or figured it by myself (more likely, because I've spent many days and even weeks experimenting with IListView interface and ListView control in general).
    – arbiter
    Commented Sep 8, 2015 at 22:18
11
+50

Is there any way to make list view it mimic the Explorer selection style?

No, SysListView32 in explorer theme does not behave that way. The control used by the modern Explorer is actually DirectUIHwnd. And you are not able to use one of them.

The only way to get the behaviour of DirectUIHwnd is to code it yourself. I expect that's possible to do but I'd also expect it to be very difficult to achieve.

6
  • Thanks. I was pretty sure I cannot set anything to make it behave like I want. I expect this has to be coded. I just do not know how. Edited the question to make it explicit. Commented Apr 1, 2013 at 20:11
  • 4
    Well, I answered the original question. Clearly it's possible to make such a control. Explorer is proof of that. Whether it's tractable for you to graft it on to SysListView32 is a different matter. I'm sceptical. Commented Apr 1, 2013 at 20:13
  • Bounty goes to you, as I, unfortunately, did not get any better answer :) Thanks. Commented Apr 16, 2013 at 8:07
  • Thanks. I'd say that part of your problem is that you didn't actually ask for a different answer. I picked out the question that you asked in a quote in my answer. And you asked "is there any way?" That's really a yes/no type of a question. What you want to do, I think, is ask a follow up question that says, "how do I do this?" Commented Apr 16, 2013 at 8:09
  • I understand that my original question was not specific enough. But I do not see how to improve it further after my edit. I would have to post the same question again, what does not look like a good idea :) Commented Apr 17, 2013 at 6:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.