Is this a good use of MDI

A

Art

I'm developing a Windows Forms app that requires a fixed set of
graphical nav buttons along the top of the app window, then a number
of forms (or panels? or...?) that appear below, one at a time, based
on the selection the user makes from the nav bar. I've seen in other
postings refer to this a "MS Money navigation." I've looked at Money,
and that seems about right.

I've actually got everything up and running using an MDI parent to
contain the nav stuff, and then some child forms set to fill the rest
of the parent. The child forms are set to have no border, no max or
min buttons, etc.--they basically look like panels.

This works except for one major problem: I'm using show and hide
methods to control the appearance of each form, but when I execute the
methods, the title bar and border of the child forms briefly appear
then disappear--it's a flicker, very distracting and annoying. I've
searched for a solution, but haven't found one.

So, I'm now wondering if this is the best way to handle this app.
Perhaps MDI is not suited for this? If not, what would be a better
solution? It seems that panels would be right, except difficult to put
together at design time...

Any suggestions?

I'm on Visual Basic .Net 2003, 1.1 of the CLR, with the most recent
updates.

Many thanks,

Art
 
W

W.G. Rowland

Could you show a snippet of the code you use when you instantiate, set the
parenting and fill options for the form, and show them.. I'm doing something
similar in an app I'm working on, and haven't noticed the flicker problem..
I'm wonder if it is the order you're doing things in that causes the
problem..

WGR
 
A

Art

Hi WGR,

Here's the code I'm using to show my child forms:

First, here's a hashtable I use to store and create the forms (this
appears in the form load event handler:

With Formlist
.Add(1, New frmOne)
.Add(2, New frmTwo)
.Add(3, New frmThree)
.Add(4, New frmFour)
End With

Then here's the sub that's called to show a new form (the newFormID is
passed from the calling event and matches one of the keys in the
hashtable):

Private Sub ShowChildForm(ByVal newFormID As Integer)
Dim newForm As Form
Dim oldForm As Form

newForm = CType(Formlist(newFormID), Form)

If Not (Me.ActiveMdiChild Is Nothing) Then
oldForm = Me.ActiveMdiChild
End If

With newForm
.MdiParent = Me
.Location = New Point(0, 136)
.Show()
End With

If Not (oldForm Is Nothing) Then
oldForm.Hide()
End If

End Sub

The child forms all have their borderstyle set to "none", are sized to
fit into the empty space in the parent, and have their StartPosition
set to "manual".

I've tried changing all sorts of properties, and just am not having
any luck. I'd appreciate any insights you might have!

Thanks!

Art
 
W

W.G. Rowland

Ack, I hate to admit failure, but I put together your code and I see what
you mean. It took me a few tries before I started noticing the little
flicker.. It doesn't do it consistently, but it does do it. Worse I
couldn't get rid of it. I experimented with suspending the layout, but it's
not what's on the form it's the drawing of the form itself that's buggy.

It doesn't do anything to fix your problem, but wanted to mention that if
you're MDI form isn't a fixed size you might get more mileage out of setting
the childform's .dock property. If you set it to "fill" it will fill up the
parent form space that isn't already filled by any docked controls or panels
in the parent form. And unlike setting the form's state to Maximize it
doesn't add the extra Close/Min/Max buttons that you're used to seeing with
MDI forms..

Good luck.. I hope someone wiser has an answer...

WGR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top