Here is quick example I tried:
Dialog app with CListCtrl (with Always Show Selection = TRUE, and View set to list). CListCtrl member variable added (m_List)
In initdialog under the todo comments I added following:
When running the program the 1st 5 items are selected and the 1st item has focus, so it should work for you.Code:// TODO: Add extra initialization here m_List.SetFocus(); CString sLabel; // add 10 items to list for(int i = 0;i < 9; i++) { sLabel.Format("Item%d", i); m_List.InsertItem(i, sLabel); } // select 1st 5 items for(int i = 0;i < 5; i++) m_List.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED ); // set focus to first item m_List.SetItemState(0, LVIS_FOCUSED , LVIS_FOCUSED ); // return false because I set focus to a control return false; // return TRUE unless you set the focus to a control




Reply With Quote