怎样设置焦点,已知该控件的handle 发送WM_SETFOCUS消息或者:::SetFocus 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是用WM_SETFOCUS产生的结果。而::setfocus用不成。 The SetFocus function sets the keyboard focus to the specified window. The window must be attached to the calling thread's message queue. 不是同一个进程的话可能因为输入模型而有点问题,你试一下以下步骤:1. 对目标窗口SetActiveWindow2. 对Edit发送WM_KILLFOCUS3. 对Button发送WM_SETFOCUS. 找到办法了,使用AttachThreadInput挂到目标线程上,然后::SetFocus,完了以后再解开挂接 HWND hActiveWnd,hHasFocusWnd; DWORD IDActive,IDthis; BringWindowToTop((HWND)al_windowhandle);//使其成为focus之window hActiveWnd=::GetForegroundWindow();//获取当前窗口handle IDthis=GetWindowThreadProcessId((HWND)al_windowhandle,NULL);//获取线程号 IDActive=GetWindowThreadProcessId(hActiveWnd,NULL);// AttachThreadInput(IDActive,IDthis,TRUE); hHasFocusWnd=::GetFocus();//获取焦点 AttachThreadInput(IDActive,IDthis,FALSE);al_windowhandle是我的窗口的handle还是没有用 HWND SetFocus( HWND hWnd // handle to window to receive focus); 你需要的是控件的HWND, 而不是整个窗口的HWND,甚至前面的BringWindowToTop这些都不用假设你的控件HWND是hCtrl,那么AttachThreadInput(IDActive,IDthis,TRUE);// 这里应该是SetFocus::SetFocus(hCtrl);AttachThreadInput(IDActive,IDthis,FALSE); 调用CListCtrl::SetImageList 后,能取消绑定吗 CPing::Ping 的问题.. 学习用VC做数据库开发需要哪些知识点?(开发工具的?数据库的?) DLL基本问题 请教关于datagrid数据绑定的问题 急!在线等待!请问高手,如何通过代码得到文本输入框中选中的文字? zzyx过来拿分,我答应给你的!(其他人勿进,谢谢了!) 我写一个音频程序,测试时,把音箱拔了,再插上没声音了。 C++MFC关于制作登陆界面的问题 VC++的串口通信 急:CObList对象Serialize的问题,帮忙看看怎么回事?提示保存文档失败。 关于PC与单片机虚拟串口通讯的问题
1. 对目标窗口SetActiveWindow
2. 对Edit发送WM_KILLFOCUS
3. 对Button发送WM_SETFOCUS.
DWORD IDActive,IDthis; BringWindowToTop((HWND)al_windowhandle);//使其成为focus之window hActiveWnd=::GetForegroundWindow();//获取当前窗口handle
IDthis=GetWindowThreadProcessId((HWND)al_windowhandle,NULL);//获取线程号
IDActive=GetWindowThreadProcessId(hActiveWnd,NULL);//
AttachThreadInput(IDActive,IDthis,TRUE);
hHasFocusWnd=::GetFocus();//获取焦点
AttachThreadInput(IDActive,IDthis,FALSE);al_windowhandle是我的窗口的handle
还是没有用
HWND hWnd // handle to window to receive focus
);
AttachThreadInput(IDActive,IDthis,TRUE);
// 这里应该是SetFocus
::SetFocus(hCtrl);
AttachThreadInput(IDActive,IDthis,FALSE);