protected bool HandleLayout(ref Message m) { if (this.ListView.HeaderStyle == ColumnHeaderStyle.None) { return(true); } BrightIdeasSoftware.NativeMethods.HDLAYOUT lParam = (BrightIdeasSoftware.NativeMethods.HDLAYOUT)m.GetLParam(typeof(BrightIdeasSoftware.NativeMethods.HDLAYOUT)); BrightIdeasSoftware.NativeMethods.RECT structure = (BrightIdeasSoftware.NativeMethods.RECT)Marshal.PtrToStructure(lParam.prc, typeof(BrightIdeasSoftware.NativeMethods.RECT)); BrightIdeasSoftware.NativeMethods.WINDOWPOS windowpos = (BrightIdeasSoftware.NativeMethods.WINDOWPOS)Marshal.PtrToStructure(lParam.pwpos, typeof(BrightIdeasSoftware.NativeMethods.WINDOWPOS)); using (Graphics graphics = this.ListView.CreateGraphics()) { graphics.TextRenderingHint = ObjectListView.TextRendereringHint; int num = this.CalculateHeight(graphics); windowpos.hwnd = this.Handle; windowpos.hwndInsertAfter = IntPtr.Zero; windowpos.flags = 0x20; windowpos.x = structure.left; windowpos.y = structure.top; windowpos.cx = structure.right - structure.left; windowpos.cy = num; structure.top = num; Marshal.StructureToPtr(structure, lParam.prc, false); Marshal.StructureToPtr(windowpos, lParam.pwpos, false); } this.ListView.BeginInvoke(delegate { this.Invalidate(); this.ListView.Invalidate(); }); return(false); }
public Rectangle GetItemRect(int itemIndex) { BrightIdeasSoftware.NativeMethods.RECT r = new BrightIdeasSoftware.NativeMethods.RECT(); BrightIdeasSoftware.NativeMethods.SendMessageRECT(this.Handle, 0x1207, itemIndex, ref r); return(Rectangle.FromLTRB(r.left, r.top, r.right, r.bottom)); }