Vista ListView Focus/Selection style

How can I say that the ListView control should use the focus/selction style like in explorer? My items have just the blue background, not the much cooler explorer 3d stuff.

btw: I'm using the application manifest.

Steffen

[227 byte] By [TheSZ] at [2007-12-24]
# 1

You can use the SetWindowTheme() function, like so:
SetWindowTheme (hwndListView, L"explorer", NULL);

TammyCulter-MSFT at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 2
Thank you!

Are there some drawbacks? Is this documented some where? Which other app names are available?

TheSZ at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 3
You're welcome!

Drawbacks: You can't custom draw, and you'll want to test your app again with the new style to check for new bugs. This isn't documented yet, and the final decision has not yet been made on which app names will be available. Hopefully by Beta 2 things will be more settled.

TammyCulter-MSFT at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 4
You mean with Beta2 "Platform SDK Beta 2"? I'm using Vista 5219 which says it is Beta 2.

Why are these styles not always used?

Steffen

TheSZ at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 5

Yes and yes. These calls should work on that build and be documented in that drop of the API. We don't set the style by default for backward compatibility. Many applications looked broken, so we changed to an opt-in model.

jeff

JeffPettiross-MS at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 6

Hi I tried your solution on a ListViewCtrl and it made the list window draw the dividing lines for the column in the background upon resize of the column.

(for example)

I change the size of the column to be 3 times as wide (during runtime). The themed window does not redraw the background of the listcontrol. If I dont theme the listcontrol then the textbox for editing an item creates a rectangle background behind the textbox, the color of the text highlight, when the editable text is changed.

Is there a way to force the now themed listview to refresh the background area of the listcontrol that is showing?

If this is still confusing... I'm resizing the column in the window. The dividers in vista are shown from top to bottom, unlike XP where the divider is only shown on resize. When I stretch the column to a larger size, to the left, the ui draws the diving line below the already existing item's rows and does not refresh. Once the column is resized the ui still doesn't refresh the background. If i use the lower scroll bar to view the extended listview then the background is repainted upon scrolling back.

Please let me know if there is a way to get the listview to refresh during the resize or refresh it imediately after the resize completes?

Thanks,

Daniel

cynistersix at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 7
I've tried adding this theme and it works - including custom drawing which an earlier post suggests won't work. However, I can't find any documentation other than this thread. Can someone direct me to it please? Also, do any other control types support a change of theme in this way?
Than at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 8

Is your listviewctrl setup to be viewed with the LVS_REPORT flag on? because I guarantee that the issue I am seeing is accross the board when theming in my fashion. It is highly possible that we do not understand what eachother is doing.

Hope you never run into the bug I found.

cynistersix at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 9
How can I use this with Visual Studio and C#? I don't know what that L in front of "explorer" means.
floppes at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 10

Can we please get an update from the Microsoft team on SetWindowTheme(hwnd, L"explorer", NULL) ?

i.e. what window types does it support, what does it do for each window type, and what are the limitations of each.

Ted. at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 11

Check out AeroStyle.xml in the SDK, classes that support SetWindowTheme("Explorer") will be mentioned there. Currently there's listview and treeview.

As mentioned there, it currently affects the item selection visuals. Since it's opt-in, if you decide to use it you should test your application thoroughly with it, since it affects things like custom draw, etc.

You should also make sure your control is double-buffered (LVS_EX_DOUBLEBUFFER , TVS_EX_DOUBLEBUFFER) if you decide to use this style.

lm-MSFT at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 12
I got it working in C# with Vista RC-2, here's my code:

[DllImport("uxtheme", CharSet = CharSet.Unicode)]
public extern static Int32 SetWindowTheme(IntPtr hWnd, String textSubAppName, String textSubIdList);

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

floppes at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 13

Hi Tammy,

Was the final list of names ever documented?

Thanks,
Matt

st31n at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...

Software Development for Windows Vista

Site Classified