views:

24

answers:

2

The title pretty much says it all. A Windows Form is a type of Control, and Controls are UI elements that have a Size property along with size-related methods such as OnResize and OnSizeChanged.

But Forms also have OnResizeBegin (and OnResizeEnd), which are not found in Control. Is this omission an oversight, a prescient design decision, or something else entirely?

+1  A: 

OnResizeBegin event is raised when form size is changed by user, not by programmaticaly changing Form properties (like Size). Most of controls can't be sized in such way, so it hasn't OnResizeBegin event.

STO
Your explanation makes sense, but the split container control (which is user re-sizable) doesn't have those events either. Seems like an oversight, but I would guess that it has more to do with the way the re-size functionality for a split container is implemented. Watch the animation to see what I mean. (I'm not saying you're wrong, btw; I expect your explanation is 100% right. I was just looking into it some more as I happen have a project with a split container open ATM.)
Tim Coker
A: 

When you add something to a base class like Control that has such a huge number of descendents, it's going to get inherited by everything whether it makes sense or not (e.g. would many programmers care that a radio button is starting to get resized?). Every method, property and event you add makes an API that much more complicated.

Now there are plenty of other examples of things in Control that don't make sense for every child (e.g. a Leave event on a Label control), but that's part of the contradictory morass that is Forms. The attached property system used in WPF is much more elegant.

Tim Trout
I disagree. It is consistency that makes an API uncomplicated. Inconsistencies are what take up brain space and clutter the mind, and the API.
I. J. Kennedy
That was part of my point, the inconsistency in Forms. You disagree that adding methods/properties/events to parent controls that make no sense for their children does not complicate an API?
Tim Trout