开发者

How to detect when an application loses focus?

I created a usercontrol in c#, Leave and LostFocus are not fired if I switch to another prog开发者_开发问答ram. How can I detect if the app loses focus?


Try your mainform's Deactivate event


If you switch to a differnt app, your custom control DIDN'T lose focus. At least not within the app it is in.

If you come back to your app, such as hitting it on the taskbar (and not by clicking on another control on the same app), your control will still have "focus".

This is where Form.Deactivate comes in handy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜