tags:

views:

29

answers:

1

Hi,

I have a class which inherits 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

+1  A: 

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);
smink
But my list class is generic which I am using inside many dlg classes.So, If I need to do this, I will need to get RTTI for parent and then cast it to specific parent class and then call its fn.Is there any other way, so that I don't have to use RTTI?
Thanks alot. It worked.
Glad to help. In SO is customary to accept the answer that help to solve your problem. You do that by clicking in the checked image near the score of each answer. It should turn green when you do.
smink