protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)User32.Msgs.WM_DESTROY: this.ReleaseHandle(); break; case (int)User32.Msgs.WM_NCDESTROY: this.ReleaseHandle(); break; case (int)User32.Msgs.WM_NCPAINT: case (int)User32.Msgs.WM_PAINT: break; case (int)User32.Msgs.WM_WINDOWPOSCHANGING: // move the control just a bit User32.WINDOWPOS wp = (User32.WINDOWPOS)(m.GetLParam(typeof(User32.WINDOWPOS))); var sz = GetOffset(); // obtain from parent wp.x += sz.Width; wp.y += sz.Height; System.Runtime.InteropServices.Marshal.StructureToPtr(wp, m.LParam, true); break; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)WM.WM_WINDOWPOSCHANGING: User32.WINDOWPOS wp = (User32.WINDOWPOS)System.Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, typeof(User32.WINDOWPOS)); if (true) // ... if somecondition ... { // modify the location with x,y: //wp.x = 0; wp.y = wp.y - 15; } System.Runtime.InteropServices.Marshal.StructureToPtr(wp, m.LParam, true); break; } base.WndProc(ref m); }