I’m trying to use GetFocus() on a ComboBox control in a dialog box, but for some reason it isn’t working.
Even if I set focus with the SetFocus() function it doesn’t work, but it looks like it has keyboard focus.
SetFocus(hKeysComboBox);
if (GetFocus() == hKeysComboBox) // This is false
Maybe because it’s in a dialog box? I don’t know, this seems so simple.
Is this an editable combo? Those actually contain a child Edit control, and when you focus the combo, the combo in turn focuses the child edit control (so that it can receive manage the keyboard input). You can use Spy++ to see this parent/child structure.
So to check if the combo has focus, you could check if the parent of GetFocus is the Combo.