I had an opportunity to use CListbox. The scenario was that I had to pre populate the list box and display it in a pop up window.
Its very to use listbox when using it in a parent window but when you want to display it in a standalone pop up window, you would get an error.
This is because the data is present only after the window comes into picture completely and is gone when the window disappears. In order to rectify this you would need to over rider the Initdialog method as below:
//check if the parent window dialog is also initialized
//enter the values into the listbox here
By the above code you can enter into a listbox before its displayed.
Declare the below methods in the header file for getting the list selection changes:
afx_msg void OnLbnSelchangeList1();
afx_msg void OnLbnDblclkList1();
Add them to the message map in the class as below:
Over ride them with the functionalities you need as below:
// TODO: Add your control notification handler code here
Use CArray to get the values:
int indexVal = 0;
for(int i=0;i 0)
int *pSels = new int[Count];
for (int i = 0; i < Count;i++)
//pSels[i] this is the index of the item that was selected
delete  pSels;