2
votes

"Common Controls" send out a NM_SETFOCUS notification, but not basic controls like an edit control.

Is there a way in my CDialog-derived class to know when focus changes to ANY control in my dialog? If not within my dialog, then possibly ANY focus change (I can figure it out from the hwnd)?

1
I know I can brute-force it (gotta remember to set the "Notify" style flag for the button controls), but there should be a better way without having to map different types of control notification messages to every single control.franji1

1 Answers

0
votes

You should be able to handle CWnd::OnCommand and trap the command ID and notification message. I'd try something like this...

if((notificationCode == EN_KILLFOCUS)        ||   
            (notificationCode == LBN_KILLFOCUS) ||
            (notificationCode == CBN_KILLFOCUS) ||
            (notificationCode == NM_KILLFOCUS)  ||
            (notificationCode == WM_KILLFOCUS))

{

 // Here do whatever you want.

}

You can expand it by adding the equivalent _SETFOCUS notifications.