首先,你应当设置其它几个窗体的从属关系,然后当其中一个窗体移动时,其它几个窗体添加以下代码: this.Location = new Point(MousePosition.X, MousePosition.Y); 读取主窗体的位移,这样就可以了.
这里有做好的控件,楼主可以看一下 http://www.codeproject.com/KB/cs/stickywindows.aspx原理; The idea behind the implementation is to filter the NC (NonClient) messages from the Form's message queue and do the own Moving/Resizing of the form by overriding the WndProc of the NativeWindow.When a WM_NCLBUTTONDOWN is received for the Form, the StickyWindow checks the required operation (Move/Resize) and starts the algorithm for the requested operation.While mouse is moved, the algorithm computes the new Form's position/size and then tries to compute the distance to the closest Form or screen border. If the shortest distance is smaller than the StickGap, the form will be moved/resized to touch the margins of the form/screen, thus sticking taking place.While resize takes place, the form will take care not to shrink below Form.MinimumSize or SystemInformation.MinWindowTrackSize or to grow above Form.MaximumSize or SystemInformation.MaxWindowTrackSize.
带代码中同时显示出来
关了Form1不写关闭Form2的代码他们就不关连再比 Form1是播放列表 点击播放列表时 触发事件把歌曲传到Form2中就是这个道理啊
form2.hide在按钮事件下和运行初始状态下设置
当鼠标拖动form1时form2响应很慢,有时甚至没有反应
就是所form1拖动,form2还在原处啊
能不能说具体点
不过自己没有弄过
组件调用不知道怎么弄
首先,你应当设置其它几个窗体的从属关系,然后当其中一个窗体移动时,其它几个窗体添加以下代码:
this.Location = new Point(MousePosition.X, MousePosition.Y);
读取主窗体的位移,这样就可以了.
http://www.codeproject.com/KB/cs/stickywindows.aspx原理;
The idea behind the implementation is to filter the NC (NonClient) messages from the Form's message queue and do the own Moving/Resizing of the form by overriding the WndProc of the NativeWindow.When a WM_NCLBUTTONDOWN is received for the Form, the StickyWindow checks the required operation (Move/Resize) and starts the algorithm for the requested operation.While mouse is moved, the algorithm computes the new Form's position/size and then tries to compute the distance to the closest Form or screen border. If the shortest distance is smaller than the StickGap, the form will be moved/resized to touch the margins of the form/screen, thus sticking taking place.While resize takes place, the form will take care not to shrink below Form.MinimumSize or SystemInformation.MinWindowTrackSize or to grow above Form.MaximumSize or SystemInformation.MaxWindowTrackSize.
http://www.codeproject.com/KB/cs/stickywindows.aspx
有源码的