2014-07-08 12:58:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2015-04-06 18:33:34 +00:00
|
|
|
|
namespace xServer.Core.Extensions
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-01-13 18:43:55 +00:00
|
|
|
|
public static class ListViewExtensions
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
|
|
|
|
|
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
|
|
|
|
|
private static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, int pszSubIdList);
|
|
|
|
|
|
|
|
|
|
private const uint WM_CHANGEUISTATE = 0x127;
|
|
|
|
|
private const uint SET_COLUMN_WIDTH = 4126;
|
|
|
|
|
private const int AUTOSIZE_USEHEADER = -2;
|
|
|
|
|
|
2015-04-06 18:33:34 +00:00
|
|
|
|
public static void RemoveDots(ListView targetListView)
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-04-06 18:33:34 +00:00
|
|
|
|
SendMessage(targetListView.Handle, WM_CHANGEUISTATE, 65537, 0);
|
2014-07-08 12:58:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 18:33:34 +00:00
|
|
|
|
public static void ChangeTheme(ListView targetListView)
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-04-06 18:33:34 +00:00
|
|
|
|
SetWindowTheme(targetListView.Handle, "Explorer", 0);
|
2014-07-08 12:58:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 18:33:34 +00:00
|
|
|
|
public static void AutosizeColumns(ListView targetListView)
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-04-06 18:33:34 +00:00
|
|
|
|
for (int lngColumn = 0; lngColumn <= (targetListView.Columns.Count - 1); lngColumn++)
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-04-06 18:33:34 +00:00
|
|
|
|
SendMessage(targetListView.Handle, SET_COLUMN_WIDTH, lngColumn, AUTOSIZE_USEHEADER);
|
2014-07-08 12:58:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|