Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow selection in Explorer-style list view to start in the first column

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).

like image 351
Martin Prikryl Avatar asked Apr 01 '13 20:04

Martin Prikryl


2 Answers

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.

like image 132
David Heffernan Avatar answered Nov 15 '22 18:11

David Heffernan


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:

  • IListView at Geoff Chappell - Software Analyst or
  • Undocumented List View Features at Code Project.

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

like image 38
arbiter Avatar answered Nov 15 '22 19:11

arbiter