public static void SetGroupHeaderColor(IntPtr aHandle, Color aColor) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { LVGROUPMETRICS groupMetrics = new LVGROUPMETRICS(); groupMetrics.cbSize = Marshal.SizeOf(typeof(LVGROUPMETRICS)); // set the mask to LVGMF_TEXTCOLOR to enable the new header color to take effect groupMetrics.mask = LVGMF_TEXTCOLOR; groupMetrics.crHeader = Color.FromArgb(0, aColor.R, aColor.G, aColor.B).ToArgb(); SendMessage(aHandle, LVM_SETGROUPMETRICS, 0, ref groupMetrics); } }
public static void SetGroupHeaderColor(IntPtr handle, int icolor) { var groupMetrics = new LVGROUPMETRICS(); Int32 ptrRetVal; IntPtr wparam = new IntPtr(); IntPtr lparam = new IntPtr(); groupMetrics.cbSize = Marshal.SizeOf(groupMetrics); groupMetrics.mask = ListViewAPI.LVGMF_TEXTCOLOR; groupMetrics.crHeader = icolor; lparam = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(groupMetrics)); System.Runtime.InteropServices.Marshal.StructureToPtr(groupMetrics, lparam, false); ptrRetVal = SendMessage(handle, LVM_SETGROUPMETRICS, wparam, lparam); System.Runtime.InteropServices.Marshal.FreeCoTaskMem(lparam); }
private unsafe void updateMetricsButton_Click(object sender, EventArgs e) { ListViewGroup group = listView1.Groups[0]; int id = (int)typeof(ListViewGroup).GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(group); //listView1.MultiSelect = true; var metrics = new LVGROUPMETRICS { cbSize = (uint)sizeof(LVGROUPMETRICS), mask = LVGMF.BORDERSIZE | LVGMF.BORDERCOLOR }; metrics.Right = 50; metrics.Left = 50; metrics.Top = 50; metrics.Bottom = 50; metrics.crRight = (uint)COLORREF.ColorToCOLORREF(Color.Red); metrics.crLeft = (uint)COLORREF.ColorToCOLORREF(Color.Red); metrics.crTop = (uint)COLORREF.ColorToCOLORREF(Color.Red); metrics.crBottom = (uint)COLORREF.ColorToCOLORREF(Color.Red); IntPtr r = User32.SendMessageW(listView1.Handle, (User32.WindowMessage)LVM.SETGROUPMETRICS, (IntPtr)id, ref metrics); }
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, ref LVGROUPMETRICS lParam);
public static int SetGroupMetrics(ObjectListView olv, int groupId, LVGROUPMETRICS metrics) { return((int)NativeMethods.SendMessage(olv.Handle, LVM_SETGROUPMETRICS, groupId, ref metrics)); }
public static int SetGroupMetrics(ObjectListView olv, int groupId, LVGROUPMETRICS metrics) { return (int)NativeMethods.SendMessage(olv.Handle, LVM_SETGROUPMETRICS, groupId, ref metrics); }
public static int SetGroupMetrics(ObjectListView olv, int groupId, LVGROUPMETRICS metrics) { return((int)SendMessage(olv.Handle, 0x109b, groupId, ref metrics)); }
public static IntPtr SetGroupMetrics(ObjectListView olv, LVGROUPMETRICS metrics) { return(NativeMethods.SendMessage(olv.Handle, LVM_SETGROUPMETRICS, 0, ref metrics)); }