private static void SetImageListControl ( Control ctrl, SystemImageList sysImageList, bool forStateImages ) {
if ( ctrl.GetType ( ) != typeof ( ListView ) && ( ctrl.GetType ( ) != typeof ( TreeView ) && !ctrl.GetType ( ).IsSubclassOf ( typeof ( TreeView ) ) ) )
throw new ArgumentException ( "Invalid type of control" );
IntPtr wParam = IntPtr.Zero;
if ( ctrl.GetType ( ) == typeof ( ListView ) )
wParam = (IntPtr)LVSIL_NORMAL;
else
wParam = (IntPtr)TVSIL_NORMAL;
if ( sysImageList.ImageListSize == SystemImageListSize.SmallIcons ) {
if ( ctrl.GetType ( ) == typeof ( ListView ) )
wParam = (IntPtr)LVSIL_SMALL;
}
if ( forStateImages ) {
if ( ctrl.GetType ( ) == typeof ( ListView ) )
wParam = (IntPtr)LVSIL_STATE;
else
wParam = (IntPtr)TVSIL_STATE;
}
if ( ctrl.GetType ( ) == typeof ( ListView ) )
SendMessage ( ctrl.Handle, LVM_SETIMAGELIST, wParam, sysImageList.Handle );
else
SendMessage ( ctrl.Handle, TVM_SETIMAGELIST, wParam, sysImageList.Handle );
}
#endregion