自己画个窗体就可以实现了 我这里的用一个Label和一个Button实现的,把Label的背景图片设为你生成的图片,和标题栏的蓝色一样,这样在Label中你就可以设置字体样式了,然后在右边的Button中实现关闭的效果 实现Label的MouseDown、MouseUp和MouseMove方法 private void MouseDown(object sender, MouseEventArgs e) { // when the mouse is down we must activate // a flag to say that the left button is down // and then store the current position // of the mouse and the form and we will // use these posotions to calculate the offset // that must be added to the loaction if(e.Button==MouseButtons.Left) { mouseDown = true; MouseCurrrnetPos = Control.MousePosition; formPos = this.Location; } }private void MouseUp(object sender, MouseEventArgs e) { if(e.Button==MouseButtons.Left) mouseDown=false; }private void MouseMove(object sender, MouseEventArgs e) { if(mouseDown==true) { // get the position of the mouse in the screen MouseNewPos=Control.MousePosition; formNewPos.X=MouseNewPos.X-MouseCurrrnetPos.X+formPos.X; formNewPos.Y=MouseNewPos.Y-MouseCurrrnetPos.Y+formPos.Y; Location=formNewPos; formPos=formNewPos; MouseCurrrnetPos=MouseNewPos; }
比较麻烦,说白了我也不会写,所以一般只用Windows自带的就可以了
我这里的用一个Label和一个Button实现的,把Label的背景图片设为你生成的图片,和标题栏的蓝色一样,这样在Label中你就可以设置字体样式了,然后在右边的Button中实现关闭的效果
实现Label的MouseDown、MouseUp和MouseMove方法
private void MouseDown(object sender, MouseEventArgs e)
{
// when the mouse is down we must activate
// a flag to say that the left button is down
// and then store the current position
// of the mouse and the form and we will
// use these posotions to calculate the offset
// that must be added to the loaction
if(e.Button==MouseButtons.Left)
{
mouseDown = true;
MouseCurrrnetPos = Control.MousePosition;
formPos = this.Location;
}
}private void MouseUp(object sender, MouseEventArgs e)
{
if(e.Button==MouseButtons.Left)
mouseDown=false;
}private void MouseMove(object sender, MouseEventArgs e)
{
if(mouseDown==true)
{
// get the position of the mouse in the screen
MouseNewPos=Control.MousePosition; formNewPos.X=MouseNewPos.X-MouseCurrrnetPos.X+formPos.X;
formNewPos.Y=MouseNewPos.Y-MouseCurrrnetPos.Y+formPos.Y; Location=formNewPos;
formPos=formNewPos;
MouseCurrrnetPos=MouseNewPos;
}
}