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!

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top