Jul 15, 2011 11:53 AM
(This post was last modified: Dec 9, 2012 06:08 PM by nathan72389.)
Ok..
since we all love the listview control in VS, but if your like me, hate the way it looks (does it not look like it fell out of win 95'?) then this VERY simple control will soon become a quick replacement.
lets start by checking out the differences in the standard listview and the "Areo listview":
[img]http://img691.imageshack.us/img691/926/715201121245pm.png[/img]
^^
on the left is the standard listview, but on the right is our new areo listview. both of them are set to simply display something in detail mode, with some garbage that is being displayed.
so, what has change?
well, if the image dont say it all, then i will tell you, ..
The appearance!
our new one (the one on the right) looks like it fits into windows vista / 7 more, and dont look 10 years old.
lets do another example:
[img]http://img24.imageshack.us/img24/9227/715201121906pm.png[/img]
this time i did it with pictures...(dont that just look better ?)
ok, thats all for the demo, and you might be thinking that this is some custom drawn listview. well, no, its not.
starting with windows vista you can now apply the windows themes (areo) to different controls found around the windows environment.
since i use a listview (alot) this is one control class that i made and have always loaded it up when i need a listview.
dude, shutup and show some code!
ok, ok
lets start.
make a new class and call it something close to what the control is. (AreoListView)
then import "System.Runtime.InteropServices"
make it "inherit" a listview
you will need to declare this api:
now, we will add an event handler for when the handle is created we can go ahead and use our api to make it look "pretty"
so the api call is basically like this..
me.handle (the handle to the control to change)
"explorer" (this is just a marker that windows uses, its not that important)
nothing (this is the pram for the theme(anything other than "nothing, 0, nill" will force it back to the old way and defeat the whole point of the ctrl))
now, one issue that i always hate with listviews, are that they flicker when they are being updated.. lets solve this now..
ah, much better.
ok so close the class and debug your app, close it, then check the toolbox for your new control.
done!
now you can use a listview that fits with windows vista / 7 a little better than that ugly solid blue selections.
just incase anyone is wondering about XP, this will not crash on an xp box, but also, it wont do anything.
anyway, here is my whole class for the control:
so, i hope that everyone enjoyed themselves and can use this in making your programs a little more pleasing to the eye.
since we all love the listview control in VS, but if your like me, hate the way it looks (does it not look like it fell out of win 95'?) then this VERY simple control will soon become a quick replacement.
lets start by checking out the differences in the standard listview and the "Areo listview":
[img]http://img691.imageshack.us/img691/926/715201121245pm.png[/img]
^^
on the left is the standard listview, but on the right is our new areo listview. both of them are set to simply display something in detail mode, with some garbage that is being displayed.
so, what has change?
well, if the image dont say it all, then i will tell you, ..
The appearance!
our new one (the one on the right) looks like it fits into windows vista / 7 more, and dont look 10 years old.
lets do another example:
[img]http://img24.imageshack.us/img24/9227/715201121906pm.png[/img]
this time i did it with pictures...(dont that just look better ?)
ok, thats all for the demo, and you might be thinking that this is some custom drawn listview. well, no, its not.
starting with windows vista you can now apply the windows themes (areo) to different controls found around the windows environment.
since i use a listview (alot) this is one control class that i made and have always loaded it up when i need a listview.
dude, shutup and show some code!
ok, ok
lets start.
make a new class and call it something close to what the control is. (AreoListView)
then import "System.Runtime.InteropServices"
make it "inherit" a listview
you will need to declare this api:
Code
<DllImport("uxtheme", CharSet:=CharSet.Unicode)> _
Public Shared Function SetWindowTheme(ByVal hWnd As IntPtr, _
ByVal textSubAppName As String, _
ByVal textSubIdList As String) As Integer
End Functionnow, we will add an event handler for when the handle is created we can go ahead and use our api to make it look "pretty"
Code
Private Sub AreoListView_HandleCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.HandleCreated
SetWindowTheme(Me.Handle, "explorer", Nothing)
End Subso the api call is basically like this..
me.handle (the handle to the control to change)
"explorer" (this is just a marker that windows uses, its not that important)
nothing (this is the pram for the theme(anything other than "nothing, 0, nill" will force it back to the old way and defeat the whole point of the ctrl))
now, one issue that i always hate with listviews, are that they flicker when they are being updated.. lets solve this now..
Code
Sub New()
Me.DoubleBuffered = True
End Subah, much better.
ok so close the class and debug your app, close it, then check the toolbox for your new control.
done!
now you can use a listview that fits with windows vista / 7 a little better than that ugly solid blue selections.
just incase anyone is wondering about XP, this will not crash on an xp box, but also, it wont do anything.
anyway, here is my whole class for the control:
Code
Imports System.Runtime.InteropServices
Public Class AreoListView
Inherits ListView
<DllImport("uxtheme", CharSet:=CharSet.Unicode)> _
Public Shared Function SetWindowTheme(ByVal hWnd As IntPtr, _
ByVal textSubAppName As String, _
ByVal textSubIdList As String) As Integer
End Function
Sub New()
Me.DoubleBuffered = True
End Sub
Private Sub AreoListView_HandleCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.HandleCreated
SetWindowTheme(Me.Handle, "explorer", Nothing)
End Sub
End Classso, i hope that everyone enjoyed themselves and can use this in making your programs a little more pleasing to the eye.


