Programming Tips - How respond to a user's click on a disabled control?

Date: 2010feb24 Platform: Windows Language: C/C++ Q. How respond to a user's click on a disabled control? After I have done m_MyControl.EnableWindow(FALSE) it does nothing. (I want a user click to "wake it up"). A. You need to receive the click in the containing dialog. With MFC:
BEGIN_MESSAGE_MAP(CMyDialog, CDialog) ON_WM_LBUTTONDOWN() END_MESSAGE_MAP() // Helper function void GetNormalRect(const CWnd &wnd, CRect &rect) { WINDOWPLACEMENT wp; wnd.GetWindowPlacement(&wp); rect = wp.rcNormalPosition; } void CMyDialog::OnLButtonDown(UINT nFlags, CPoint point) { CRect rect; GetNormalRect(m_MyControl, rect); if (rect.PtInRect(point)) { // The user clicked on my disabled control. // Do whatever I want - eg enable the control: m_MyControl.EnableWindow(TRUE); } }