This message is sent to the window receiving or losing the focus, thereby giving it the opportunity to perform some appropriate processing.

Note: Except in the instance of WM_ACTIVATE, with usactive set to TRUE, an application processing WM_SETFOCUS or WM_ACTIVATE messages should not change the focus window or active window. If it does, the focus and active window must be restored before the application returns from processing the message. For this reason, any dialog boxes or windows brought up during the processing of WM_SETFOCUS or WM_ACTIVATE messages should be system modal.