您需要另一个 Form 进行一些自定义(可能移除顶部的控制框,例如关闭、最大化和最小化)。您可以在按钮MouseHover 事件中打开此表单。
比如:
private void MyButton_MouseHover(object sender, EventArgs e)
{
//Assume that you made this form in designer
var cutomForm = new CustomForm();
//Set the opening location somewhere on the right side of main form, you can change it ofc
cutomForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
//Probably topmost is needed
cutromForm.TopMust = true;
customForm.Show();
}
关于动画,你可以在google上搜索winformws的动画。或者到处看看,比如:WinForms animation
关于您的其他问题
如果您希望新打开的表单随着您的移动而移动,那么您需要进行一些更改。首先,您需要将新表单作为代码中的一个字段(然后按钮悬停也应该更改):
private CustomForm _customForm;
private void MyButton_MouseHover(object sender, EventArgs e)
{
//Check if customForm was perviously opened or not
if(_customForm != null)
return;
//Assume that you made this form in designer
_customForm= new CustomForm();
//Set the opening location somewhere on the right side of main form, you can change it ofc
_customForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
//Probably topmost is needed
_customForm.TopMust = true;
//Delegate to make form null on close
_customForm.FormClosed += delegate { _customForm = null;};
_customForm.Show();
}
为了让两个表单一起移动,您需要在主表单的 Move 事件中处理它,例如:
private void Form1_Move(object sender, EventArgs e)
{
if(_customForm != null)
{
//Not sure if this gonna work as you want but you got the idea I guess
_customForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
}
}