View previous topic :: View next topic |
Author |
Message |
netdecompiler
Joined: 28 Mar 2006 Posts: 1
|
Posted: Tue Mar 28, 2006 2:52 pm Post subject: Why VirtualTree use Icon instead of Bitmap? |
|
|
I am thinking to change standart TreeView to VirtualTree.
But TreeView uses bitmaps and ImageList. Why VirtualTree uses icons?
One can convert bitmap to icon:
Icon _myIcon = Icon.FromHandle(_bitmap.GetHicon());
and this work. But new icon is not transparent.
In the TreeView I can write:
imageList1.TransparentColor = System.Drawing.Color.White;
and get transparent image. _________________ Kozlov Ruslan |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 28, 2006 10:14 pm Post subject: |
|
|
The reason we use Icons is that icons handle transparency properly. Setting transparency for bitmaps is a hack to workaround the fact that bitmaps don't actually have true transparency support. The only reason that the standard TreeView uses bitmaps and ImageLists is that this is what it use the standard Windows Tree control which requires this approach.
ImageLists are ugly to use because they force you to work in two places and deal with indexes. Any good control written from the ground up and managed .NET code should avoid using ImageLists.
It is very easy to convert your bitmaps to icons using the Visual Studio resource editor. Simply create an icon the same size (and number of colors) as your bitmap then copy and paste the content of the bitmap into the icon. Then use the icon editor to set the transparent area.
It is possible to convert bitmaps to icons programmatically (converting a specific color to transparent) but the above method would be preferable in terms of performance. _________________ Infralution Support |
|
Back to top |
|
|
|