Similar things have been covered in the past, but I would like to kick the hornet’s nest again, just to see if anything may have changed in the past several years…
Here’s the (design) situation:
I need to group several sets of controls inside separate container controls in my main application window. In my situation, these containers will be displayed along one side of the application window and can be scrolled up and down so the user can gain access to each of them. Here is an example based on an the previous version of this application:
Each of these “containers” would be based on a standard “container” which, ideally, would have a set of common interface elements (e.g. the disclosure arrow to hide/show the contents, a “reset” button, and optionally a checkbox to activate/deactivate the child controls). For context:
Here is the place where I need advice:
In the old application, I was able to build this “Control Group” container object and place multiple instances of it on my window, programmatically spacing and scrolling them as needed. Because they were based on a standard ContainerControl, the sizes could vary, and the container could react to and raise events (e.g. changing its own size when the user used the disclosure triangle (DidResize), or raising an event when the user clicked the “reset” icon (DidReset)). The issue was that all the embedded controls within each and every “Control Group” (popup menus, sliders, etc.) belonged to the main window. The main window ended up with hundreds of controls, and their associate code on it.
In the new version of this application, I want to move the majority of the UI elements to individual containers, exposing the properties and events of each to the main window as needed. The problem is that a container control can not be subclassed from another container control (e.g. cntVideoDeviceOptions would be a subclass of the more generic “cntControlGroup”), inheriting it’s UI and behaviors. My current idea is to place a “Control Group” container (with the disclosure/check/reset UI) onto a second blank container control would then be placed on the main application window. All the unique UI controls would be children of this “master” container, which would serve to pass properties and events to the main application window. Unfortunately the “control group” events (DidResize, DidCheck, DidReset, etc.) could only be passed back to the main window if they were duplicated in each of the “master” containers, at which point I might as well just make entirely new container object for each of the groups.
How can I get around this? Essentially I want to create a new reusable UI object (a control group) that I can add to my main window at design time and then place custom UI controls on top of it.