SplitContainer...Painting Order, WindowState Maximized...

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Okay,

This is just down right confusing, and I don't know if there is enough space here to give all the info necessary for anyone else to reciprocate this glitch.

I have a layout manager class hierarchy that I designed, that basically is given a list of control types which it seeks out recursively from a Form. It retains those controls that match the types listed (for this case the controls I'm seeking are SplitContainer and TabControl) and then given as well a list of Properties (in string name format) the collection tree uses reflection to retrieve the values for each of those controls that matched the provided types. For these purposes I am dealing with the SplitContainer, and specifically the SplitterDistance property. (I also save the Panel1/2Collapsed boolean, but it apparently is not affected.

Now I use this for multiple reasons, one being that the layout manager class is directly fused to the My.Settings object, and thus allows me to dynamically add these control values to the My.Settings object for saving and loading. So far this part works wonderfully. Secondly, during the program operation, there are several views that all use the same base interface, so the 3 different SplitContainers need to remember their SplitterDistance position for each view. Using the reflection of the LayoutManager class, I can GetControlValues() or SetControlValues() and thus when I change views, I can immediately update the interface to reflect the positions of each panel as appropriate to the view, as well when any splitter is moved, I can store the new splitterdistance value in the layoutmanager for the specific view and control. It all works quite wonderfully and I have not yet seen any problems.

However, I have only really gruelingly tested this in WindowState = Normal mode. Providing the ability for the WindowState to be saved as well as size and location, the user can have the Form Maximized for full view and that state is stored the same as the position/dimensions for normal mode.

So basically, my application loads up, and since this form is not the first form displayed, it is an additional form that the user can open when necessary, the mainform calls out to initialize the values of the form, creating all the my.Settings properties, loading their values, and setting the initial AdminForm.Size, .Location, and .WindowState.

Then the Form is Shown when requested, and upon attaching the view binding control to the combobox that allows the user to select the different views, the default view is selected which calls out to LayoutManager.EnforceLayout(), which sets all the SplitterDistance properties to their appropriate values.

But here is the issue: In normal mode this works just fine, but when the Window is initially shown Maximized (ie:
VB.NET:
 Form.WindowState=Maximized
Form.Show
in that order) these errors occur in sequence:

First:
the Primary SplitContainer (SplitterH_Tab1)
Intended SplitterDistance Value = 372
After EnforceLayout: Value = 312.
I have tried to use the watch window to manually change it to a random number like 400, or 550, and it accepts the changes but interprets them as 312. I hit <enter> and the number goes red and is set to 312 again no matter what i've actually typed.

Second:
after everything is set: the dataset has been filled from the db, the datasources have been assigned, the databindings have been assigned to all the controls, and the layout has been enforced:

SplitContainer_SplitterMoved() event is triggered for the SplitterH_Tab1 control with a e.SplitY value of 590

Note: This only happens when the form is maximized before it is first shown.

Any ideas as to why this is happening?
 
Back
Top