C#真的没法解决用SendMessage获取checkbox状态吗
推荐于2017-10-06 · 知道合伙人影视综艺行家
关注
展开全部
public const UInt32 BM_GETCHECK = 0x00F0;
public const UInt32 BM_SETCHECK = 0x00F1;
public const UInt32 BM_GETSTATE = 0x00F2;
private void button4_Click(object sender, EventArgs e)
{
IntPtr hWndParent = FindWindow("WindowsForms10.Window.8.app.0.2bf8098_r16_ad1", "Form3");
IntPtr h = FindWindowEx(hWndParent, IntPtr.Zero, "WindowsForms10.BUTTON.app.0.2bf8098_r16_ad1", "checkBox1");
Message msg = Message.Create(h, BM_CLICK, new IntPtr(0), new IntPtr(0));
//点击hwnd_button句柄对应的按钮
//PostMessage(msg.HWnd, msg.Msg, msg.WParam, msg.LParam);
SendMessage(msg.HWnd, BM_SETCHECK, new IntPtr(0), null);
int i = SendMessage(msg.HWnd, BM_GETSTATE, new IntPtr(0), null);
}
一些API函数的申明我就不写了。我搜遍了所有的资料,有2个问题无解。
1.发送BM_CLICK可以选中checkbox。但是发送BM_SETCHECK就不行。
2.发送BM_GETSTATE无法获取checkbox的状态。
public const UInt32 BM_SETCHECK = 0x00F1;
public const UInt32 BM_GETSTATE = 0x00F2;
private void button4_Click(object sender, EventArgs e)
{
IntPtr hWndParent = FindWindow("WindowsForms10.Window.8.app.0.2bf8098_r16_ad1", "Form3");
IntPtr h = FindWindowEx(hWndParent, IntPtr.Zero, "WindowsForms10.BUTTON.app.0.2bf8098_r16_ad1", "checkBox1");
Message msg = Message.Create(h, BM_CLICK, new IntPtr(0), new IntPtr(0));
//点击hwnd_button句柄对应的按钮
//PostMessage(msg.HWnd, msg.Msg, msg.WParam, msg.LParam);
SendMessage(msg.HWnd, BM_SETCHECK, new IntPtr(0), null);
int i = SendMessage(msg.HWnd, BM_GETSTATE, new IntPtr(0), null);
}
一些API函数的申明我就不写了。我搜遍了所有的资料,有2个问题无解。
1.发送BM_CLICK可以选中checkbox。但是发送BM_SETCHECK就不行。
2.发送BM_GETSTATE无法获取checkbox的状态。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询