I want to find out where the focus belongs after EN
Now I have build my application like this: it runs in the container of Internet browser(IE, FireFox, Chrome and so on). There is a modeless dialog in my program, the dialog contains one CEdit control.
Here is my problem: when user activate the Edit control to type into something, the edit control get the focus. When the edit control loses the focus, I must check whether the input is valid. If not, I will display a model dialog with
AfxMessageBox
. But now I cannot determine whether my edit control loses in my own application. Because the edit control may loses focus by a lot of means, for example, when user close the browser, when user open a text program. In these cases, I will just skip the invalidation check.
Any one can tell me how to find that in which way my edit control loses focus.
调用GetFocus()并查看焦点是否已返回到线程中的另一个窗口。
HWND hwndFocus = ::GetFocus();
if (hwndFocus != 0 && ::GetWindowThreadProcessId(hwndFocus, NULL) == ::GetCurrentThreadId())
{
// focus still in our thread
}
链接地址: http://www.djcxy.com/p/39258.html
上一篇: 单击相邻CheckBox后的WPF TextBox偷取焦点
下一篇: 我想知道在EN之后焦点所在的位置