Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent a control from changing Z order?
    primarykey
    data
    text
    <p>I have user control in .Net where I use a hit test in WndProc to allow resizing it in runtime with the mouse.</p> <p>The problem is that after the hit test succedes (mouse press, drag to resize, mouse release) the control jumps upwards in the Z order and ruins it position in the form.</p> <p>I need the hit test since it's a very customized control.</p> <p>Is there a way in WndProc to stop the control from changing it's Z order ?</p> <p>Thanks.</p> <p>The hit test code:</p> <pre><code>protected override void WndProc(ref Message m) { if (!DesignMode &amp;&amp; Sizeable &amp;&amp; (m.Msg == Win32Wrapper.WM_NCHITTEST)) { Point Hit = new Point((int)m.LParam &amp; 0xFFFF, (int)m.LParam &gt;&gt; 16); Hit = this.PointToClient(Hit); int DistToBorder = 5; if (Hit.X &lt; DistToBorder) { if (Hit.Y &lt; DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTTOPLEFT; return; } if (Hit.Y &gt; this.ClientRectangle.Bottom - DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTBOTTOMLEFT; return; } m.Result = (IntPtr)Win32Wrapper.HTLEFT; return; } else if (Hit.X &gt; ClientRectangle.Right - DistToBorder) { if (Hit.Y &lt; DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTTOPRIGHT; return; } else if (Hit.Y &gt; this.ClientRectangle.Bottom - DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTBOTTOMRIGHT; return; } m.Result = (IntPtr)Win32Wrapper.HTRIGHT; return; } else if (Hit.Y &lt; DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTTOP; return; } else if (Hit.Y &gt; this.ClientRectangle.Bottom - DistToBorder) { m.Result = (IntPtr)Win32Wrapper.HTBOTTOM; return; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload