Reputation: 546
I have a dialog box with several combobox
es in it as a member variables. The control wizard lets me create handlers for the combobox
es for the CBN_KILLFOCUS
message. For example, one such handler is automatically called
void MyDlg::OnKillfocusMyCombo()
My expectation is that this handler would be called just as soon as I tab out of it. But it doesn't get called.
Upvotes: 3
Views: 1482
Reputation: 22285
I ran into the same issue. This is a bug in MFC. (It's over 4 years later and it is still there.) Somehow ON_CBN_KILLFOCUS
handler is never called although the Win32 CBN_KILLFOCUS
notification itself is broadcast.
To fix this override the WindowProc
for the dialog manually (Win32-way):
LRESULT CMyDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
//Fix for the bug in MFC
if(message == WM_COMMAND)
{
if(HIWORD(wParam) == CBN_KILLFOCUS &&
LOWORD(wParam) == Your_ComboBox_ID)
{
OnCbnKillfocusComboBox();
}
}
return CDialog::WindowProc(message, wParam, lParam);
}
Upvotes: 1