Using WM_SETFOCUS and WM_KILLFOCUS

前端 未结 1 1190
误落风尘
误落风尘 2021-01-21 17:31

In Delphi, I have two edit boxes and a button.

Edit1 is selected by default. I want to change focus using messages. But if I do as below, it all gets messed up with sel

相关标签:
1条回答
  • 2021-01-21 18:12

    WM_SETFOCUS and WM_KILLFOCUS are both notification messages that Windows sends to window handles when they receive and lose input focus, respectively, and you should not post those yourself. Instead, simply call SetFocus(edit2.handle) or edit2.SetFocus() to set the focus.

    If for some reason you can't do that synchronously from your button click handler, you can post a custom message to a local message handler in your own form and make the SetFocus call from that message handler.

    0 讨论(0)
提交回复
热议问题