【问题标题】:WinForm - draw resizing frame using a single-pixel borderWinForm - 使用单像素边框绘制调整大小的框架
【发布时间】:2008-09-18 15:52:01
【问题描述】:

在具有调整大小框架的 Windows 窗体中,框架边框以凸起的 3-D 外观绘制。我希望它以我选择的颜色绘制一个平坦的单像素边框。

这是否可能无需所有者绘制整个表单?

【问题讨论】:

    标签: c# winforms resize border


    【解决方案1】:

    你可以试试这样的:

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多