开发者

CListCtrl - how to find it is selected

I have got a CDialog Class, inside which there are two ClistCtrl classes. I want to find out which of the listCtrl's is selected at the moment. say, listCtrl A and B. Even when I 开发者_JS百科move between A and B, suppose first I go to A and select a row. Then even when I go to B and select an item there, item in A remains selected as I don't come to know that I have gone in other list.

Any suggestions, how I can find this.


If understand you correctly, you need to know which one of list boxes has a focus. You could do that by calling GetFocus(), it returns a pointer to the focused control.

The problem you might have though is when your dialog is not an active window and then focus would be somewhere else. In this case you should be tracking WM_SETFOCUS and WM_KILLFOCUS messages and keeping record of which of the list boxes was activated last. In MFC there are callbacks CWnd::OnSetFocus and CWnd::OnKillFocus that could be used to achieve that.


I found a way of doing this. I can register for NM_Click notifications on both the lists When list A is selected, I set curSel of list B to -1 and vice versa.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜