說明: 解決自定義不規則窗體後,不能拖動問題。
先看效果圖:
代碼如下:<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PC9wPgo8cHJlIGNsYXNzPQ=="brush:java;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace BT
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Point mouse_offset;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
mouse_offset = new Point(-e.X, -e.Y);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
Point mousepos = Control.MousePosition;
mousepos.Offset(mouse_offset.X, mouse_offset.Y);
Location = mousepos;
}
}
}
}