CListCtrl - clearing all selections
bstadnyk@creo.bc.ca Wednesday, July 03, 1996 Environment: NT 3.51, MSVC 4.0 Problem: I need to programmatically clear all selections in the CListCtrl. Why I am doing this: I'm trying to write a "file open" and "file save" dialogs similar to windows's. But instead of a list box displaying items to select, I am using a CListCtrl to display additional item information and allow sorting by columns, sizing columns, etc. But I only want the item in the CListCtrl to be focused on, not selected (i.e. see notepad's file save and file open). That item's "name" is then copied to the Open/Save name edit box (i.e. see how notepad's open/save works). Design constraints: I am creating a derived CListCtrl to encapsulate these enhancement and add the owner draw "full item line" selection (as shown in the MSVC4.1 MFC sample ROWLIST). I need to actually clear the selection in the CListCtrl, not just "turn off" the highlighting. I understand how LVS_SHOWSELALWAYS works. What I have tried: 1) Scanning through the CListCtrl for selected items and removing the LVNI_SELECTED state. Did not work. 2) As the item is being changed, remove its LVNI_SELECTED state. Did not work (remained selected), and I don't like this solution. 3) After the item is changed, remove its LVNI_SELECTED state. Did not work (remained selected), and I'm not surprised. Again I don't like this solution. 4) Checked MSDN. 5) Checked the mfc-l website. 6) Checked the MFC FAQ. So can this be done? If so, has anyone successfully done it? Thanks in advance, Bruce Stadnyk Creo Products Inc. Burnaby, B.C. Canada bstadnyk@creo.bc.ca
David.Lowndes@bj.co.uk Monday, July 08, 1996 [Mini-digest: 2 responses] > Problem: > I need to programmatically clear all selections in the CListCtrl. > > LVS_SHOWSELALWAYS works. > > What I have tried: > 1) Scanning through the CListCtrl for selected items and removing the > LVNI_SELECTED state. Did not work. > 2) As the item is being changed, remove its LVNI_SELECTED state. Did > not work (remained selected), and I don't like this solution. > 3) After the item is changed, remove its LVNI_SELECTED state. Did not > work (remained selected), and I'm not surprised. Again I don't like > this solution. > > So can this be done? If so, has anyone successfully done it? Bruce, As nothing you have tried with this problem has worked, could you post a snippet of your code, perhaps there's something missing. Dave Lowndes -----From: "Kalon R. Kelley"It seems to me that a variant on your 2nd try is the most appropriate solution. I assume that you created a handler for the LVN_ITEMCHANGING notification. Instead of trying to remove the LVNI_SELECTED state during the change operation, why not simply deny the change (by returning a TRUE result value) if the state is changing to selected? Cheers, Kalon.
| Вернуться в корень Архива |