日期:2014-05-20  浏览次数:21049 次

Sendmessage(句柄,消息常量,参数3,参数4)
关于消息常量 不懂。网上找了好多关于sendmessage的 消息常量老是不明白。现在需要使用BM_SETCHECK这些。给另一个应用程序中的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);

}
}
}


}

}