Interaction Betwen MDI Child Windows
I have around 8 MDI Child Windows each doing a unique 'job', each Window is represented by a Class and has its own Message Proc. Many of these classes are required to interact with each other. What is the best way to communicate between them all? I have had ideas including:
1. Initialising each class with pointers to other classes.
2. Registering messages with Windows and sending data to different WndProc's.
3. Having a central class deal with interactions between each of the Child Windows.
I am having trouble decided which one is best or if there is a better solution. Any and all ideas welcome, thanks.
It entirely depends on your (code) style and liking.
1) tightly couples your windows with each other. Depending on your app this must not be a bad thing.
2) is pretty much 3 but using existing Win32 functionality.
3) can be done with an observer/listener pattern, there being decoupled from Win32.
1) tightly couples your windows with each other. Depending on your app this must not be a bad thing.
2) is pretty much 3 but using existing Win32 functionality.
3) can be done with an observer/listener pattern, there being decoupled from Win32.
How about decoupling your work from the UI and using an observer pattern or the like? If you have 8 worker classes doing different jobs, you could link the classes to eachother using a ProgressObserver, or a DirtyJobObserver, a SimpleButMindlessJobObserver, etc. These observer classes are nothing but an interface and make it easy for you to break the dependancy of the other worker classes.
Of course, in the end, the UI just uses the observers to get their information from the real classes, and the other 8 classes communicate through them aswell. It requires some more work, but it's cleaner.
Toolmaker
Of course, in the end, the UI just uses the observers to get their information from the real classes, and the other 8 classes communicate through them aswell. It requires some more work, but it's cleaner.
Toolmaker
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement