Solved

Displaying Two Children Forms In A MDI Form

Posted on 2002-04-28
10
324 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
Comment Utility
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
Comment Utility
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
Comment Utility
Is the BorderStyle of your form Sizeable ?
0
 
LVL 18

Author Comment

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

Accepted Solution

by:
RichardCorrie earned 50 total points
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:n_narayanan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ajit77, where can I get the Splitter control from ??
0
 
LVL 18

Author Comment

by:Sethi
Comment Utility
Thanks. It works excellently.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now