brigadoon 0 Newbie Poster

How to capture the WM_RBUTTONDOWN event from the Listbox part of a Combobox control?

I have a MFC dialog based application. A CComboBoxEx control is defined as m_comboBox1, it has a dropdown list of a few items.
When the drop down list is shown, I want to cancel the list by click
the right mouse button anywhere inside the dialog area. However, ComboBox has no response to right click at all.

You can cancel the drop down list by left click any place out of the list area, no matter if you are in the dialog area or not.
You can cancel it by right click out of dialog area also. But then the combobox will select your last highlighted item first. I am not sure what message was posted on each case and how is it posted.

I tried to subclass CComboBox and overload WindowProc so I can capture right click event:

LRESULT CSubComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    if (wParam == WM_RBUTTONDOWN)
    {
        .....
        return TRUE;
    }
    return CComboBoxEx::WindowProc(message, wParam, lParam);
}

However the control will only capture right mouse click when the drop down list didn't show.

Thanks for any help.