c#通过SendMessage发送消息,改变其他程序的下拉框控件(ComboBox)的值
IntPtrmwh=(IntPtr)Convert.ToInt32(handle);//ComboBox的句柄intresult=SendMessage(mwh,0x01...
IntPtr mwh = (IntPtr)Convert.ToInt32(handle); //ComboBox的句柄
int result = SendMessage(mwh, 0x014D, -1, selectStr); //改变ComboBox的值,selectStr为预期的下拉框选项
int mwh_p = GetWindowLong(mwh, -8); //获取ComboBox所属窗口的句柄
IntPtr mwh2 = (IntPtr)Convert.ToInt32(mwh_p); //转换ComboBox所属窗口的句柄
string cbn_selchange;
int cb_id = GetWindowLong(mwh, -12); //获取ComboBox的控件ID
cbn_selchange = "0001" + string.Format("{0:X4}", cb_id);
IntPtr s1 = (IntPtr)Convert.ToInt32(Tools.ToD(cbn_selchange, 16));
SendMessage(mwh2, 0x0111, s1, mwh); //给ComboBox所属窗口发送WM_COMMAND命令,第3个参数wParam是(CBN_SELCHANGE(高位) + 控件ID(低位))
SendMessage(mwh2, 0x0111, s1, mwh);可以参考SPY++捕捉的消息日志
此语句中"IntPtr s1 = (IntPtr)Convert.ToInt32(Tools.ToD(cbn_selchange, 16));"
Tools.ToD的地方报错,需要什么引用吗?求解答 展开
int result = SendMessage(mwh, 0x014D, -1, selectStr); //改变ComboBox的值,selectStr为预期的下拉框选项
int mwh_p = GetWindowLong(mwh, -8); //获取ComboBox所属窗口的句柄
IntPtr mwh2 = (IntPtr)Convert.ToInt32(mwh_p); //转换ComboBox所属窗口的句柄
string cbn_selchange;
int cb_id = GetWindowLong(mwh, -12); //获取ComboBox的控件ID
cbn_selchange = "0001" + string.Format("{0:X4}", cb_id);
IntPtr s1 = (IntPtr)Convert.ToInt32(Tools.ToD(cbn_selchange, 16));
SendMessage(mwh2, 0x0111, s1, mwh); //给ComboBox所属窗口发送WM_COMMAND命令,第3个参数wParam是(CBN_SELCHANGE(高位) + 控件ID(低位))
SendMessage(mwh2, 0x0111, s1, mwh);可以参考SPY++捕捉的消息日志
此语句中"IntPtr s1 = (IntPtr)Convert.ToInt32(Tools.ToD(cbn_selchange, 16));"
Tools.ToD的地方报错,需要什么引用吗?求解答 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询