views:

917

answers:

1

In a Windows Form with a Resizing Frame, the frame border draws with a raised 3-D look. I'd like it to draw with a flat single pixel border in a color of my choosing.

Is this possible without having to owner draw the whole form?

+2  A: 

You could try something like this:

Point lastPoint = Point.Empty;
Panel leftResizer = new Panel();
leftResizer.Cursor = System.Windows.Forms.Cursors.SizeWE;
leftResizer.Dock = System.Windows.Forms.DockStyle.Left;
leftResizer.Size = new System.Drawing.Size(1, 100);
leftResizer.MouseDown += delegate(object sender, MouseEventArgs e) { 
  lastPoint = leftResizer.PointToScreen(e.Location); 
  leftResizer.Capture = true;
}
leftResizer.MouseMove += delegate(object sender, MouseEventArgs e) {
  if (lastPoint != Point.Empty) {
    Point newPoint = leftResizer.PointToScreen(e.Location);
    Location = new Point(Location.X + (newPoint.X - lastPoint.X), Location.Y);
    Width = Math.Max(MinimumSize.Width, Width - (newPoint.X - lastPoint.X));
    lastPoint = newPoint;
  }
}
leftResizer.MouseUp += delegate (object sender, MouseEventArgs e) { 
  lastPoint = Point.Empty;
  leftResizer.Capture = false;
}

form.BorderStyle = BorderStyle.None;
form.Add(leftResizer);
Hallgrim