建立窗体的名称修改为:Form_HoverTree
文后附有源码下载。主要代码:Point _HoverTreePosition; public Form_HoverTree() { InitializeComponent(); _HoverTreePosition = new Point(); } ////// 记录鼠标起始位置 hovertree.com /// private void Form_HoverTree_MouseDown(object sender, MouseEventArgs e) { _HoverTreePosition.X = e.X; _HoverTreePosition.Y = e.Y; } ////// 按住左键,鼠标移动窗体跟着移动 - 何问起 /// private void Form_HoverTree_MouseMove(object sender, MouseEventArgs e) { if(e.Button== MouseButtons.Left) { Point h_myPosittion = MousePosition; h_myPosittion.Offset(-_HoverTreePosition.X, -_HoverTreePosition.Y); Location = h_myPosittion; } }
效果图:
可以看出,这个窗体为自定义形状的窗体,没有标题栏。具体参考:
源码下载:
转自:
推荐: