Solved

Displaying Two Children Forms In A MDI Form

Posted on 2002-04-28
10
328 Views
Last Modified: 2010-05-02
Displaying Two Children Forms In A MDI Form

Hi,

I want to create a user interface in VB where in the left side of the application displays a
TreeView control displaying the heirarchy of other forms in the application.

I exercised this option with SDI forms but it considerably slows down the application as the
Treeview control has to be created on every form.

In MDI application I am not able to persist two forms at the same time. i.e. when an MDI
application is run, the first form that consists the Tree View control is loaded on the left side
of the Parent window and occupies 20% of the MDI Parent's space.
On click of a node on the Treeview I want to display a form in the remaining 80% right side of
the MDI form.

However it is not happening and the second form when displayed occupies the whole MDI area, thereby
shadowing the form contianing TreeView control.

I have tried the Left and Top properties while displaying the second form, but they are not
working.

Please suggest.

Thanks.
0
Comment
Question by:Sethi
10 Comments
 
LVL 5

Expert Comment

by:raizon
ID: 6976175
have you tried calling the form_resize event from the form_load event in the second child form.  And in the form_resize set the left and top
0
 
LVL 18

Author Comment

by:Sethi
ID: 6976320
It gives an error in For_Resize event.
'Form cant't be move or resized in Maximize and Minimize state'...I have ensured that the Windows state is vbNormal, but still the error persists.
0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6976502
Is the BorderStyle of your form Sizeable ?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 18

Author Comment

by:Sethi
ID: 6976705
Yes, MDI doesn't accept any other border style.
0
 
LVL 10

Accepted Solution

by:
RichardCorrie earned 50 total points
ID: 6976716
In the MDI form put a Picture box (picParent) ensure the Align property = 3 - align Left.  

Put the Tree view control (treParent) into the picture Box

In the MDIForm_Resize event put:

if me.windowsate <> vbminimized then
  picParent.width = me.width *.2
  with treParent
      .left = 0
      .top = 0
      .width = picParent.width
     .height = picparent.height
  end with
end if

In the Form_Open event of the child windows put

me.windowsate = vbMaximized

When any child form opens it will occupy the remaining 80% of the MDI form.  

Richard
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6976718
You can not use the form for displaying the Treeview.

Put a Picture box with align property set to left. Draw a Treeview control in that. Size the picture box to 20% of your mdi form.

Now all the other forms will occupy 80%of the remaining area.


Cheers

Narayanan.
0
 

Expert Comment

by:ajit77
ID: 6976745
Hi Sethi,

I've did this last year...i used MDI application..but instead of using a form to hold the tree control, i used a 'Splitter' control instead (Sheridan)..its much easier, all u have to do is drop the Splitter control on your MDI form, the form will automatically divide into 2, so then u can drop the tree control, it will fit nicely in the container (left side of the split)...furthermore u can resize the width of the tree control during runtime just like wondows file explorer....and ure child forms will be loaded to the right side of the splitter...

0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6977049
Works fine for me.
Be sure to set Sub Main or MDIForm as startup form

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   Begin MSComctlLib.TreeView tretREE
      Height          =   2655
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   4683
      _Version        =   393217
      Style           =   7
      Appearance      =   1
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

VERSION 5.00
Begin VB.Form Form2
   Caption         =   "Form2"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form2"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


VERSION 5.00
Begin VB.MDIForm MDIForm1
   BackColor       =   &H8000000C&
   Caption         =   "MDIForm1"
   ClientHeight    =   7320
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10170
   LinkTopic       =   "MDIForm1"
   StartUpPosition =   3  'Windows Default
End
Attribute VB_Name = "MDIForm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub MDIForm_Load()

Dim f As Form1
Dim f2 As Form2


    Set f = New Form1
    With f
        .Top = 0
        .Left = 0
        .Width = 500
        .Height = Me.ScaleHeight
        .Show
    End With
   
    Set f2 = New Form2
    With f2
        .Left = f.Width
        .Top = 0
        .Width = Me.ScaleWidth - f.Width
        .Height = Me.ScaleHeight
    End With
End Sub
0
 
LVL 18

Author Comment

by:Sethi
ID: 6977903
Ajit77, where can I get the Splitter control from ??
0
 
LVL 18

Author Comment

by:Sethi
ID: 7002980
Thanks. It works excellently.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question