Well, when you click on one of your Edit controls it will handle the WM_LBUTTONDOWN message itself. So if you need to do custom handling of this message you will need to use subclassing.
But when you click on an Edit control it will be given the keyboard focuses which causes it to send its parent window a WM_COMMAND message with the EN_SETFOCUS notification code, plus its control ID and HWND.
So this sort of thing might work in your case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// get command ID and notification code
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if((start_id <= id) && (id < (start_id + ctrl_count)))
if(code == EN_SETFOCUS)
focus_id = (id - start_id);
(where the meaning of the variables start_id and ctrl_count is hopefully clear enough?)
But the real problem is that I don't know when to call this. It has to happen exactly when focus is changed to another window. I thought the message WM_SETFOCUS is called whenever I click inside one of the text edit windows, but it turns out it's only called once, at the program's startup.