resizing a panel in a form with the mouse

  • Thread starter Thread starter Julian
  • Start date Start date
J

Julian

Hi,

I am following up on an older thread about resizing a panel in a form
with the mouse.

http://groups.google.de/group/micro...ntrol+resizable&rnum=1&hl=de#bb247a9b14219d94

I tried this code to manipulate the right border of the panel but I
have a problem:

public class SizablePanel : Panel
{
private const int WM_NCHITTEST = 0x0084;
private const int HTRIGHT = 11;

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
{
Point pos = new Point((int)m.LParam);
pos = this.PointToClient(pos);
if (pos.X > this.Width - 5)
m.Result = new IntPtr(HTRIGHT);
}
}
}

I cannot make the panel narrower than about 120 pixel.
Does anyone have a solution to that?

Also I would like to drag the panel horizontally.
 
Julian,

I copy/paste your exact code in a test application and I have no problem
resizing the panel. Are you sure that there is not some constraints on the
size of the panel that you may enforce. Check the MinimumSize property of
the panel. The code that I have posted does not apply any size limitations.
 
Back
Top