无标题栏窗口的拖动,我写的代码怎么运行结果与我想的不一样,
private int omx;//鼠标原来的x坐标
private int omy;//鼠标原来的y坐标
private int ofx;//窗口原来的x坐标
private int ofy;//窗口原来的y坐标
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.ofx = this.Left;
this.ofy = this.Top;
this.omx = e.X;
this.omy = e.Y;
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Left = this.ofx + (e.X - this.omx);
this.Top = this.ofy + (e.Y - this.omy);
this.ofx = this.Top;
this.ofy = this.Left;
this.omx = e.X;
this.omy = e.Y;
}
}
搞不清楚是逻辑不对还是其它的原因,就是出不来我想要的效果,请各位大虾多多指教……
问题点数:20、回复次数:9Top
1 楼zhushizu(从来就没有救世祖)回复于 2004-09-01 14:07:34 得分 0
是呀,我也是想了好久。。关注中。。。Top
2 楼homesos(熊猫贩子)回复于 2004-09-01 14:11:48 得分 0
我觉得好像是它的鼠标的坐标系统有异于其它的语言的坐标系统,但不确定Top
3 楼homesos(熊猫贩子)回复于 2004-09-01 14:42:04 得分 0
有个地方错了,应该是
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Left = this.ofx + (e.X - this.omx);
this.Top = this.ofy + (e.Y - this.omy);
this.ofx = this.Left;
this.ofy = this.Top;
this.omx = e.X;
this.omy = e.Y;
}
}
Top
4 楼homesos(熊猫贩子)回复于 2004-09-01 14:42:21 得分 0
但还是没什么效果Top
5 楼moonewxp(母牛)回复于 2004-09-01 14:49:16 得分 0
想出什么效果,我觉得还是重写你form的WndProc来实现无标题栏的窗口的移动比较好Top
6 楼homesos(熊猫贩子)回复于 2004-09-01 15:07:12 得分 0
大体说一下过程,有示例更好,我对WndProc一窍不通Top
7 楼homesos(熊猫贩子)回复于 2004-09-01 15:09:14 得分 0
我就想在没有标题栏的情况下,用鼠标拖动窗口Top
8 楼homesos(熊猫贩子)回复于 2004-09-02 13:38:34 得分 0
这个问题,我自己已解决Top
9 楼hapboy19811023(^_^)回复于 2004-11-03 16:09:13 得分 20
所以,你要靠自己才能胜利,好好努力,黎明的曙光等着你
Top




