1
我有一个没有边框和标题栏的自定义窗体。我使用面板(宽度= 1px)来模拟边框。所有的工作都很好,除了左边界和上边界。当我尝试减小窗体的大小(通过拖动它到右侧),它工作正常,但当窗体的大小== this.MinimumSize。它开始移动到右侧。我只想改变尺寸,但不要移动... 这里是我的左边的代码。我如何修改它只更改大小?通过边框自定义窗体大小调整
private void borderW_MouseDown(object sender, MouseEventArgs e)
{
Active = true;
}
private void borderW_MouseMove(object sender, MouseEventArgs e)
{
if (Active)
{
if (e.X < 0)
{
this.Location = new Point(this.Left + e.X, this.Top);
this.Size = new Size(this.Width - e.X, this.Height);
}
else
{
this.Size = new Size(this.Width - e.X, this.Height);
this.Location = new Point(this.Left + e.X, this.Top);
}
}
}
private void borderW_MouseUp(object sender, MouseEventArgs e)
{
Active = false;
}
不,FormStartPostion如何影响表单位置,何时更改位置(this.Location = new Point(this.Left + eX,this.Top);) – Udjen
你说得对,开始位置只在表单加载时才有影响。这个答案:http://bytes.com/topic/c-sharp/answers/279387-how-do-i-prevent-form-moving指向一个解决方案。如果你的form.left是eqal form.left +表单.width,你可以踢这个winproc来防止移动窗口。 –
我该如何使用这个?我在哪里必须粘贴它? – Udjen