CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    1

    CCombBox Subclassing and KillFocus

    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

  2. #2
    Join Date
    May 1999
    Location
    UK
    Posts
    59

    Re: CCombBox Subclassing and KillFocus

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured