Sign in to follow this  
Funkymunky

convoluted function pointer, or...?

Recommended Posts

I'm working on an editor program that uses two classes; one controls the main window functionality, and one controls the 3d-display panel on the main window. As such, the second class is a member of the first class. I have a listbox control on the window that I want to update when the user performs an action on the 3d-display panel. Since the panel is a member of the main-window class, I'm having trouble figuring out how to call a function of the main-window class from the 3d-display panel class. I thought maybe a function pointer would do the trick, but I can't use the class name of the main-window from within the 3d-display. How should I go about doing this?

Share this post


Link to post
Share on other sites
You could have the "main window" register callback functions (in the form of function pointers) with the 3d-display window. Peruse these Google results to find some ideas of how to implement callbacks using class methods. It's very doable, and the 3d-window doesn't have to know anything about the "main window"... It just invokes whatever callbacks you give it.

Of course, if you are using a .NET/Mono language, you can use events/delegates, which are a very elegant solution.

Share this post


Link to post
Share on other sites
Damn that's pretty complicated! Much more than I felt like dealing with right now; I just rigged up a quick workaround. Definitely some good material for a rainy day though...

Good lookin' out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this