Sendmessage(句柄,消息常量,参数3,参数4) 关于消息常量 不懂。网上找了好多关于sendmessage的 消息常量老是不明白。现在需要使用BM_SETCHECK这些。给另一个应用程序中的checkbox发送消息使其选中 。谁能给一个详细的说明 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 刚测试了下。C#下用sendmessage 发BM_SETCHECK 消息,控件似乎不响应。不过重载了控件的winproc函数后就可以了。protected override void WndProc(ref Message m) { switch (m.Msg ) { case 0x00F1: if (m.WParam == (IntPtr)1) { this.Checked = true; } else { this.Checked = false; } break; } base.WndProc(ref m); } C# 使用SendMessage 函数 http://blog.csdn.net/sbz0409/article/details/3772965++1 http://hi.baidu.com/myitblog2010/blog/item/632335b6876750dd36d3cad8.html 谢谢 我是新手 这是重载那个控件的函数。我要控制的应用程序是不能动的。我想写一个应用程序来操作它我使用了SendMessage(checkbox的句柄, BM_CLICK, 1, 0)能控制了。但是遇到了一个新的问题。无法判断checkbox是否选中 如果没有选中我要选中。选中了再走这个方法就变成未选中了 望解答。谢谢 http://www.cnblogs.com/karoc/archive/2006/11/29/576253.html。 string lpszParentWindow = "FrmTest"; //窗口标题 IntPtr hwd = API.FindWindow(null, lpszParentWindow); if (hwd != IntPtr.Zero) { IntPtr checkhwd = API.FindWindowEx(hwd, new IntPtr(0), null, "checkBox1"); if (checkhwd != IntPtr.Zero) { Guid guidCOM = new Guid(0x618736E0, 0x3C3D, 0x11CF, 0x81, 0xC, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71); Accessibility.IAccessible IACurrent = null; API.AccessibleObjectFromWindow(checkhwd, (int)API.OBJID_CLIENT, ref guidCOM, ref IACurrent); IACurrent = (IAccessible)IACurrent.accParent; int childCount = IACurrent.accChildCount; object[] windowChildren = new object[childCount]; int pcObtained; API.AccessibleChildren(IACurrent, 0, childCount, windowChildren, out pcObtained); string accName; int accRole; foreach (IAccessible child in windowChildren) { accRole = (int)child.get_accRole(API.CHILDID_SELF); accName = child.get_accName(API.CHILDID_SELF); if (accRole == 44) { if (accName == "checkBox1") { child.accDoDefaultAction(0); } } } } } 参考http://www.cnblogs.com/karoc/archive/2006/11/29/576253.html String转二进制输出 winform中如何实现form1和form2之间的传值 仿做 任务管理器 C#操作DBF数据库? 线程监控程序 【请教】如何获得当前应用程序的路径? 怎样判断SelectedItem的类型 使用NDoc1.3生成文档时,LangID选了2052后,有些空格的地方变成了“?”,怎么解决? Winform 中嵌入外部exe程序 c#里面的字典Dictionary,调试的时候看不到字典的内容 lock Dictionary 对象中的项能否达到预期 根据已存在的文件生成PL/SQL脚本的工具怎么写?
不过重载了控件的winproc函数后就可以了。
protected override void WndProc(ref Message m)
{
switch (m.Msg )
{
case 0x00F1:
if (m.WParam == (IntPtr)1)
{
this.Checked = true;
}
else
{
this.Checked = false;
}
break;
}
base.WndProc(ref m);
}
C# 使用SendMessage 函数
++1
我使用了SendMessage(checkbox的句柄, BM_CLICK, 1, 0)能控制了。但是遇到了一个新的问题。无法判断checkbox是否选中 如果没有选中我要选中。选中了再走这个方法就变成未选中了 望解答。谢谢
string lpszParentWindow = "FrmTest"; //窗口标题
IntPtr hwd = API.FindWindow(null, lpszParentWindow);
if (hwd != IntPtr.Zero)
{
IntPtr checkhwd = API.FindWindowEx(hwd, new IntPtr(0), null, "checkBox1");
if (checkhwd != IntPtr.Zero)
{ Guid guidCOM = new Guid(0x618736E0, 0x3C3D, 0x11CF, 0x81, 0xC, 0x0, 0xAA, 0x0, 0x38, 0x9B, 0x71);
Accessibility.IAccessible IACurrent = null; API.AccessibleObjectFromWindow(checkhwd, (int)API.OBJID_CLIENT, ref guidCOM, ref IACurrent); IACurrent = (IAccessible)IACurrent.accParent;
int childCount = IACurrent.accChildCount;
object[] windowChildren = new object[childCount];
int pcObtained;
API.AccessibleChildren(IACurrent, 0, childCount, windowChildren, out pcObtained);
string accName;
int accRole; foreach (IAccessible child in windowChildren)
{
accRole = (int)child.get_accRole(API.CHILDID_SELF);
accName = child.get_accName(API.CHILDID_SELF);
if (accRole == 44)
{
if (accName == "checkBox1")
{
child.accDoDefaultAction(0);
}
}
}
}
}