Destroying window of dynamically created CListbox when clicking outside of CListBox's client area

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
Hi,

I have a MFC dialog based application.

When clicking a button I am displaying a dynamically created CListbox. When clicking outside of CListbox client's area I have to destroy the clistbox window.

I don't know how to achieve it.

I tried below approaches but it didn't helped me.

1. I overrided WM_LBUTTONDOWN event in the dialog, when clicking on the dialog only this event is getting caught in the dialog, when clicking on other child controls , this event is not getting caught in the dialog.

2. I subclassed Clistbox and used SetCapture and called releaseCapture and destroywindow in the WM_LBUTTONDOWN event of CListBox but I faced below problem.

After selecting item in the listbox, If I click outside of the listbox the listbox is not getting destroyed.

Please help me to resolve my problem.

I have shared my application in the below path.

https://aspiresysinc-my.sharepoint....JEiSLiDqKVbi0Bogh8K2PZXlJZkhedtMqWFA?e=3Aoq89

Continue reading...
 
Back
Top