Vista ListView Focus/Selection style
-
Tuesday, September 27, 2005 12:07 PMHow 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
All Replies
-
Thursday, September 29, 2005 6:42 PM
You can use the SetWindowTheme() function, like so:
SetWindowTheme (hwndListView, L"explorer", NULL); -
Friday, September 30, 2005 10:59 AMThank you!
Are there some drawbacks? Is this documented some where? Which other app names are available? -
Friday, September 30, 2005 5:12 PMYou'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. -
Tuesday, October 04, 2005 12:57 PMYou 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 -
Friday, March 17, 2006 4:40 PM
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
-
Tuesday, June 06, 2006 10:18 PM
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
-
Wednesday, June 07, 2006 8:26 AMI'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?
-
Monday, June 12, 2006 9:43 PM
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.
-
Tuesday, September 19, 2006 3:35 PMHow can I use this with Visual Studio and C#? I don't know what that L in front of "explorer" means.
-
Thursday, September 28, 2006 5:37 PM
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.
-
Sunday, October 08, 2006 9:49 PM
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.
-
Wednesday, October 18, 2006 12:41 PMI 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); -
Tuesday, April 17, 2007 9:59 PM
Hi Tammy,
Was the final list of names ever documented?
Thanks,
Matt -
Saturday, September 27, 2008 6:17 PMIs there way to change dividing lines color in listview when explorer style is used?
-
Sunday, March 08, 2009 12:00 AM
Sergey Kucherov said:If your referring to the vertical grid lines in details mode, you can't change the colour that I know of though setting a background image will get rid of them.Is there way to change dividing lines color in listview when explorer style is used?
/// <summary> /// Hack to disable gridlines using a dummy image as background. /// </summary> private void NoGridBgImgHack() { this.BackgroundImage = new Bitmap(10, 10); using (Graphics oGfx = Graphics.FromImage(this.BackgroundImage)) { oGfx.Clear(this.BackColor); } } -
Wednesday, June 17, 2009 9:22 PM
Actually using background image does not help:
HINSTANCE hInst = LoadLibrary("uxtheme"); if (hInst) { __SetWindowTheme = (pSetWindowTheme*)GetProcAddress(hInst, "SetWindowTheme"); if (__SetWindowTheme) __SetWindowTheme(lvWnd, L"EXPLORER", NULL); } HBITMAP hBmp = LoadImage(hInstance, "BGR", IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT); if (hBmp) { LVBKIMAGE lvi = {LVBKIF_SOURCE_HBITMAP | LVBKIF_STYLE_TILE}; lvi.hbm = hBmp; lvi.xOffsetPercent = 100; lvi.yOffsetPercent = 100; SendMessage(lvWnd, LVM_SETBKIMAGE, 0, (LPARAM)&lvi); }Background image is not displayed when explorer theme is applied. Any suggestions?


