Click to See Complete Forum and Search --> : CCombBox Subclassing and KillFocus


Chris Hudson
May 13th, 1999, 09:58 AM
I have subclassed a Combo Box, and am having problems with the KillFocus event.

When I click on the dropdown button, the KillFocus event is being fired. Not a problem in itself, but I am using the killfocus to destroy the control when focus goes outside the control.

The problem is that the dropdown button does not seem to be a child of the combo. I have put code in the killfocus to check this, but am not sure how this works.

Any help would be greatly appreciated.

Thanks

Chris Hudson

Chris Hudson
Senior Technical Consultant
Xetius Services Ltd

Marqy
May 13th, 1999, 11:43 AM
Not sure if I understand, but I think you want this...

CPoint cPoint;
CRect rect;

// Find out where the mouse is
::GetCursorPos(&cPoint);

// Find out where the combo box is.
m_comboBox.GetWindowRect(&rect);

// If the user has set the focus to the combo box, don't hide it!

if(!rect.PtInRect(cPoint))
m_comboBox.ShowWindow(SW_HIDE);

This code ives in the KillFocus() handler of the conttrol 'under' the combo, so when your control which is 'under' the combo box loses the focus, you only hide the combo if it's not receiving the focus.

MJA