开发者

capture delete key in CListCtrl and do soem processing

I have a class which inhe开发者_C百科rits from CListCtrl class, say class list. I have another class dlg, which inherits from CDialog.

Class dlg contains an instance of class list.

I have got a delete button in class dlg, on which I delete the selected item in listCtrl and do lots of other processing. I want the same functionality on delete key.

I added OnKeyDown() fn is my class list, where I can capture VK_DELETE key. But my problem is that, how do I do otehr processing that I need to do in dialog class. All that processing is dlg class based not list class based. I have many such dlg classes with different data and in every dlg class processing is different.

I tried capturing VK_DELETE in dialog class, but it doesn't capture it if focus is on list class.

I am totally stuck and have no idea, how to do this.

Please give me some idea how i can do this.

Thanks, SG


What about delegating the call captured in the List class to the parent Dialog class. Thus you capture the VK_DELETE on the List class and say to the parent that you received a Delete command. Thus you can keep all your processing on the parent Dialog class if you wish.

((CMyParentDialog*) GetParent())->OnDeleteKeyPressed(this);

Or better, create a custom message and post it to the parent window.

#define W_DELETE_PRESSED_ON_LIST (WM_USER + 1)

GetParent()->PostMessage(WM_DELETE_PRESSED_ON_LIST);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜