Control's OnExit eats up mouseup event for new control when showing another window

前端 未结 3 1159
小鲜肉
小鲜肉 2020-12-12 04:08

I found this question on Experts-Exchange.

Control\'s OnExit eats up mouseup event for new control when showing another window

The probl

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 04:58

    I'm not so sure that the reason of the behavior is an eaten mouse message. Anyway, either that's the case or not, when you activate a window in an OnExit event of a control, what you're doing is, changing the focus while the focus is changing. That's because, the window is activated before WM_SETFOCUS for the newly focused control returns. This is discouraged, the below quote is from 'Best practices' section of 'Win32 Activation and Focus', a blog entry on MSDN:

    Avoid manually changing focus when getting and/or losing focus. This usually proves to be error prone.


    The fact that the controls are disabled during focus transfer due to the modal nature of the activated window certainly would not help. If you really must do this, an approach like Heinrich's answer would at least delay the launch of the window till the focus transfer completes.

提交回复
热议问题