Solved

Displaying Two Children Forms In A MDI Form

Posted on 2002-04-28
10
329 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 84
VBA/SQL - Connect to SQL server and pull data 4 135
VB6 - Compare and highlight cell not the same 3 56
Macro problems with Excel file 6 26
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

733 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