The link above is a thread showing the application I'm working on. (2008 Pro)
I have since created an MDI Parent form which holds my 16 camera forms. What I am having trouble with is dividing the MDIParent's Width and Height by 4, to display 4 equal height/width camera forms within it.
I've tried all the available properties (Rectangle, ClientArea, etc) and none seem to calculate correctly. Using Me.Width and Me.Height ALMOST worked, but again, it was about an inch too skinny and short.
What do I need to do in order to retrieve the exact size of the MDIParent's Client Area?
Thanks.
I did search, but did not find much in the way of a resolution.
I have not tried the MDIClient. I only tried the properties of the MDIParent form itself, wasn't aware of the MDIClient object.
I don't have the solution on this computer, but will try it when available.
The MDIParent won't be "maximized" per se, but will remain a fixed size at runtime. the camera forms within it will always fill this parent form which may be in a 2x2 format, a single form, 4x4 format or selected cameras.
Just did a bit of experimentation. The trick is that the MdiClient occupies the form's ClientRectangle but it has a 3D border of its own, so you have to use its ClientSize too. I just tried this and it worked as expected:
vb.net Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 1 To 16
With New Form
.MdiParent = Me
.Show()
End With
Next
End Sub
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Me.ArrangeChildren()
End Sub
Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
Me.ArrangeChildren()
End Sub
Private Sub ArrangeChildren()
Dim containerSize = DirectCast(Me.Controls(0), MdiClient).ClientSize
Dim childWidth = containerSize.Width \ 4
Dim childHeight = containerSize.Height \ 4
Dim children = Me.MdiChildren
For index = 0 To children.GetUpperBound(0)
children(index).SetBounds((index Mod 4) * childWidth, _
That worked a charm jmc!! and it's a helluva lot cleaner than the way I was doing it to set the .Top and .Left properties. The SetBounds Method allows you to set all for parameters at once? I completely removed my .Top and .Left Select Case thing and they still size perfectly.
I have a new question (I'll post in a new thread) regarding dis-allowing the movement of these forms
Screenshot: