Derek007
Derek007

Reputation: 53

WM_SETFOCUS message and NULL wParam

I've a simple Win32 Windows app with a single, main window. Inside the window procedure I'd like to investigate a WM_SETFOCUS message. The doc says:

A handle to the window that has lost the keyboard focus. This parameter can be NULL.

This is my case - I'm getting just NULL. What does it mean and why dont I get a handle to for e.g the desktop when the desktop was a previos top, active window?

Upvotes: 1

Views: 347

Answers (1)

IInspectable
IInspectable

Reputation: 51413

32-bit Windows introduced an asynchronous input model. One consequence of this change is that the focus window is now recorded per thread (or input-attached group of threads).

Initially, a thread attached to an input queue doesn't have a focus window, so the first time a program sees a WM_SETFOCUS message, its wParam is NULL. There are other reasons why WM_SETFOCUS can have NULL as its parameter, but those aren't interesting here.


Bonus reading:

Upvotes: 1

Related Questions