Frage

I'm trying to add the ListViewItemEventListener I have in a class called Main to a class named Search so I can handle the events for the classes in the same listener. But I don't know how I can achieve this goal, or if even is possible?

This of course works:

__pList->AddListViewItemEventListener(*this);

But then it will use the listener for the Search-class. I want something like:

__pList->AddListViewItemEventListener(Main ListViewItemEventListener);

Hope someone knows how to do this.

Thanks for any help!

War es hilfreich?

Lösung

Main and Search are not subclasses of one another, are they?

It's possible. In your Search, keep a pointer to an instance of Main, and designate it as the listener for the list.

If you do that, the derivation of Main from IListViewItemEventListener should be public:

 class Main: ..., public IListViewItemEventListener 

Otherwise casting a Main to a IListViewItemEventListener would be disallowed, except inside Main's own member functions.

That, and read on up on the basics of C++. Looks like you're confused about the basic relationships between classes and objects. There's nothing bada-specific about your issue.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top