Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Displaying Two Children Forms In A MDI Form

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
Sethi
Asked:
Sethi
1 Solution
 
raizonCommented:
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
 
SethiAuthor Commented:
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
 
corvanderlindenCommented:
Is the BorderStyle of your form Sizeable ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SethiAuthor Commented:
Yes, MDI doesn't accept any other border style.
0
 
RichardCorrieCommented:
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
 
n_narayananCommented:
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
 
ajit77Commented:
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
 
corvanderlindenCommented:
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
 
SethiAuthor Commented:
Ajit77, where can I get the Splitter control from ??
0
 
SethiAuthor Commented:
Thanks. It works excellently.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now