In the dialog how to destroy a dynamically created control when other child control's got focus?
up vote
0
down vote
favorite
I have a MFC dialog based application, when click on CButton I am dynamically creating and displaying a list box. If I click on other child controls in the dialog or click on dialog's client area I have to destroy this list box. But I dont know how to get notification in the dialog when click on dialog's client area or click on child controls other than this list box in the dialog? my code snippet void CbtntestDlg::OnBnClickedButton1() { CRect rcBtn; m_ctrlbtn.GetWindowRect(rcBtn); int w = rcBtn.Width(); int h = rcBtn.Height(); POINT p; p.x=rcBtn.left; p.y=rcBtn.top; ::ScreenToClient(this->m_hWnd,&p); /*CRect r(rcBtn.right-100,rcBtn.bottom, rcBtn.right, rcBtn.bottom+30);*/ CRect r(p.x,p.y+h,p.x+100,p.y+h+150); //CRect rect(10