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
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.