-
October 12th, 2009, 02:43 AM
#1
Press space key in CListCtrl object
Hi,
I'm writing an app using CListCtrl. Each row got a check box at the front. The requirement is user can use keyboard to check/uncheck the items in the list.
Now I have a problem with following scenario:
1. User click Tab to move focus onto the list
2. Press space, the checkbox is NOT updated
3. Press up or down key for the first time, nothing happens
4. Press up or down key once again, the cursor (selected row) will move up/down accordingly
5. At this time, press space again, the checkbox will be updated
Does anyone knows why space key cannot work until press navigation key twice?
Thanks a lot!
-
October 12th, 2009, 02:55 AM
#2
Re: Press space key in CListCtrl object
Originally Posted by wangee
... Each row got a check box at the front. The requirement is user can use keyboard to check/uncheck the items in the list.
...
Does anyone knows why space key cannot work until press navigation key twice?
Do you handle "press space key" yourself or there is some ListCtrl internal functionality?
Victor Nijegorodov
-
October 12th, 2009, 03:04 AM
#3
Re: Press space key in CListCtrl object
Originally Posted by VictorN
Do you handle "press space key" yourself or there is some ListCtrl internal functionality?
No. I don't have any modified OnKeyDown event control.
-
October 12th, 2009, 03:31 AM
#4
-
October 13th, 2009, 12:53 AM
#5
Re: Press space key in CListCtrl object
Originally Posted by VictorN
Well, I presume you answered the first part of my question, not the second!
I have just tested a similar control in one of my projects... It does work as expected: checkbox state of the item that has a focus (LVIS_FOCUSED state) changes after each space key press.
Thanks Victor.
To your 2nd part of ur question, I think there's an internal functionaly that changes checkbox when space key pressed. Actually I use CMFCListCtrl class in my project.
I'm very interested your way to control the state of the checkbox? I tried "SetCheck" function, but it not always works. Do you mean you use "SetCheck" together with "SetItemState(i,LVIS_FOCUSED,LVIS_FOCUSED)"?
-
October 13th, 2009, 02:41 AM
#6
Re: Press space key in CListCtrl object
Originally Posted by wangee
To your 2nd part of ur question, I think there's an internal functionaly that changes checkbox when space key pressed. Actually I use CMFCListCtrl class in my project.
OK, good! I also use the " internal functionality that changes checkbox" when I press space key.
As for the CMFCListCtrl class - I never used it and have no idea whether something was changed in checkbox behaviour.
Originally Posted by wangee
I tried "SetCheck" function, but it not always works. Do you mean you use "SetCheck" together with "SetItemState(i,LVIS_FOCUSED,LVIS_FOCUSED)"?
1. Define "not always works".
2. No I didn't mean "I use "SetCheck" together with "SetItemState" nor used I SetItemState to change checkbox state.
However, when I need to check/uncheck an item from my code I do use SetCheck.
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|