| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2019 人关注过本帖
标题:关于调用API函数SendMessage的问题
只看楼主 加入收藏
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
 问题点数:0 回复次数:14 
关于调用API函数SendMessage的问题
谁能帮我一下, [DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hWnd,int wMsg,int wParam,int lParam);
public const int w = 0x0112;
public const int move = 0xf010;
public const int caption = 0x0002;

SendMessage(this .Handle ,w,move +caption ,0);
谁能帮我解释一下这个函数的参数,我是查了好多地方,也没查到这个资料,所以才来麻烦大家的。首次发贴,在这里学了不少东西,谢谢大家。
搜索更多相关主题的帖子: API SendMessage 函数 
2006-12-03 19:53
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
得分:0 

就是想要实现无标题窗体的拖动。怎么做?


layman on C#
2006-12-03 19:57
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
以下是引用yigedaizi在2006-12-3 19:57:07的发言:

就是想要实现无标题窗体的拖动。怎么做?

private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
mouseDown = true;
}
}

private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseDown = false;
}

private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
if(mouseDown)
{
this.Location = new Point(MousePosition.X,MousePosition.Y);
}
}
}


前几天都有人发过.

飘过~~
2006-12-03 20:13
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
得分:0 
谢谢,但是能不能帮我解释一下这个
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hWnd,int wMsg,int wParam,int lParam);
public const int w = 0x0112;
public const int move = 0xf010;
public const int caption = 0x0002;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this .Handle ,w,move +caption ,0);
}

layman on C#
2006-12-03 20:22
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
得分:0 
谢谢,不过用你的方法生成成功,但是无法实现窗体的拖动……

layman on C#
2006-12-03 20:32
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
以下是引用yigedaizi在2006-12-3 20:32:17的发言:
谢谢,不过用你的方法生成成功,但是无法实现窗体的拖动……

看看你的怎么引用的?


飘过~~
2006-12-03 20:50
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
得分:0 

就是完全按你的意思,而你这种方法只能在窗体中按下鼠标,然后左上角拖到鼠标单击出,而我想要的是单击窗体后,窗体和鼠标一起移动。
你能不能帮我看看我贴的那段代码?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool mD;

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mD= true;
}

}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
mD = false;

}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (mD)
{
this.Location = new Point(MousePosition.X, MousePosition.Y);
}
}

}


layman on C#
2006-12-03 21:18
yigedaizi
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-24
收藏
得分:0 

我表达能力不是很好,反正两种拖动的效果感觉上不一样


layman on C#
2006-12-03 21:23
leona
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-11-20
收藏
得分:0 

public partial class KyanForm : Form
{
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(int hWnd, int Msg, int wParam, int lParam);
[DllImport("User32.dll", EntryPoint = "ReleaseCapture")]
private static extern int ReleaseCapture();

public KyanForm()
{
InitializeComponent();
}

private void KyanForm_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle.ToInt32(), 0x0112, 0xF012, 0);

}

[此贴子已经被作者于2006-12-3 23:11:00编辑过]

2006-12-03 23:06
leona
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-11-20
收藏
得分:0 

我才看明白你的帖子
namespace _21
{
public partial class Form1 : Form
{
//这里

bool mD=false;



public Form1()
{
InitializeComponent();
}

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (mD == false)
{
mD = true;
}
else
{
mD = false;
}


}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{

if (mD)
{
this.Location = new Point(MousePosition.X - 30, MousePosition.Y - 30);//这个-30是你鼠标在窗口中的位置自己调!!不能-0,或是+.
System.Windows.Forms.Cursor.Clip = new Rectangle(this.Location, this.Size);
}
else
{
System.Windows.Forms.Cursor.Clip = new Rectangle(0,0,1024,768);
}


}


}
}

[此贴子已经被作者于2006-12-4 0:05:52编辑过]

2006-12-04 00:03
快速回复:关于调用API函数SendMessage的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016141 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved